Page Index Toggle Pages: [1] 2 3 ... 6 Send TopicPrint
Very Hot Topic (More than 25 Replies) Undo and groups (Read 58797 times)
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Undo and groups
Nov 3rd, 2005 at 7:51am
Print Post  
I have a group defined with the main node a box and an attached table.  I select the group and delete it.  I then do an 'Undo' and the group reappears, but with the table missing.  If I select the box, the table appears, but as soon as the box loses the selection, the table disappears???
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo and groups
Reply #1 - Nov 3rd, 2005 at 9:11am
Print Post  
Probably only the deletion of the box is undone with the Undo call, and the table's deletion isn't because it is in the history queue as a separate command. You might try creating a composite undo command to undo/redo the whole group creation as an atomic operation, e.g.

Code
Select All
CompositeCmd cmd = fc.UndoManager.StartComposite("Create group");
Box b = fc.CreateBox(0, 0, 30, 40);
Table t = fc.CreateTable(25, 35, 30, 40);
t.AttachTo(b, AttachToNode.BottomRight);
cmd.Execute();
 



Stoyan
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #2 - Nov 3rd, 2005 at 11:52am
Print Post  
I must be missing a setting somewhere.  When I execute the following:

Dim cmd As Commands.CompositeCmd = flwChart.UndoManager.StartComposite("BoxAdd" + miUniqueCmdCount.ToString)


cmd always ends up = Nothing.

Any ideas?

  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #3 - Nov 3rd, 2005 at 11:58am
Print Post  
don't worry ... sorted it.  Smiley

did have

flwChart.UndoManager.UndoEnabled = True

but somehow setting got lost, so have added it into form load event to be doubly sure!
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #4 - Nov 3rd, 2005 at 12:05pm
Print Post  
Original problem still around though, even tho I am doing the composite command via the undo manager.

I have a group defined with the main node a box and an attached table.  I select the group and delete it.  I then do an 'Undo' and the group reappears, but with the table appearing to be missing.  If I select the box, the table appears, but as soon as the box loses the selection, the table disappears.

Maybe a z-order issue?

???
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo and groups
Reply #5 - Nov 3rd, 2005 at 12:21pm
Print Post  
Hm, I still cannot reproduce that here. Are you sure the StartComposite and Execute calls enclose all of the group creation stuff ? Could you copy the code here ?

Thanks
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #6 - Nov 3rd, 2005 at 12:36pm
Print Post  
'Imports MindFusion.FlowChartX
'Imports System.Drawing
'Imports System.Drawing.Drawing2D


Private miUniqueCmdCount as Integer = 1
Private WFNodeWidth as Single = 40
Private WFNodeHeight as Single = 30

    Private Sub btnWFUndo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWFUndo.Click
       flwChart.UndoManager.Undo()
    End Sub

    Private Sub btnWFAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWFAdd.Click

       Dim iTopLeft As Single = (flwChart.GridSize / 2) + flwChart.GridSize
       miUniqueCmdCount += 1
       Dim cmd As Commands.CompositeCmd = flwChart.UndoManager.StartComposite("BoxAdd" + miUniqueCmdCount.ToString)
       Dim bx As MindFusion.FlowChartX.Box = flwChart.CreateBox(iTopLeft, iTopLeft, Constants.WFNodeWidth, Constants.WFNodeHeight)
       InitialiseWorkflowNode(flwChart, bx, System.Guid.NewGuid.ToString, True)
       cmd.Execute()
              
    End Sub


    Public Sub InitialiseWorkflowNode(ByRef flwChart As FlowChart, ByRef bx As MindFusion.FlowChartX.Box, ByVal csiID as String, ByVal newBox As Boolean)

       Dim alEmpty As New ArrayList
       Dim i As Integer
       Dim tbl As Table
       Dim grp As Group


       bx.Tag = csiID
       bx.Text = vbCrLf + vbCrLf + csi.ProcessName

       If newBox Then

           bx.MnpHandlesMask = 256
           bx.Resize(WFNodeWidth, WFNodeHeight)
           bx.SelStyle = ESelStyle.sstHatchHandles3

           Dim alBX As New ArrayList

           alBX.Add(New AnchorPoint(0, 0, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(25, 0, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(50, 0, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(75, 0, True, True, EMarkStyle.msCircle, Color.Black))

           alBX.Add(New AnchorPoint(0, 25, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(0, 50, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(0, 75, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(0, 100, True, True, EMarkStyle.msCircle, Color.Black))

           alBX.Add(New AnchorPoint(100, 0, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(100, 25, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(100, 50, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(100, 75, True, True, EMarkStyle.msCircle, Color.Black))

           alBX.Add(New AnchorPoint(25, 100, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(50, 100, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(75, 100, True, True, EMarkStyle.msCircle, Color.Black))
           alBX.Add(New AnchorPoint(100, 100, True, True, EMarkStyle.msCircle, Color.Black))

           bx.AnchorPattern = New AnchorPattern(alBX.ToArray(GetType(AnchorPoint)))

           tbl = flwChart.CreateTable(bx.BoundingRect.Location.X, bx.BoundingRect.Location.Y, WFNodeWidth, WFTableHeight)
           tbl.CaptionHeight = 8
           tbl.RowsCount = 0
           tbl.Locked = True
           tbl.Style = ETableStyle.tsRect
           tbl.ZIndex = bx.ZIndex + 1
           tbl.AnchorPattern = Nothing
           tbl.ShadowOffsetX = 0
           tbl.ShadowOffsetY = 0

           tbl.PicturePos = EImagePos.imgCenterLeft
           Dim tbrush As New MindFusion.FlowChartX.LinearGradientBrush(Color.White, Color.DarkGoldenrod, 90)
           Dim blend As New ColorBlend(3)

           blend.Colors(0) = Color.DarkGoldenrod
           blend.Colors(1) = Color.White
           blend.Colors(2) = Color.DarkGoldenrod

           blend.Positions(0) = 0
           blend.Positions(1) = 0.5
           blend.Positions(2) = 1

           tbrush.InterpolationColor = blend
           tbl.Brush = tbrush

           grp = flwChart.CreateGroup(bx)
           grp.AttachToCorner(tbl, 0)
           grp.AutoDeleteItems = True

       Else

           tbl = bx.SubordinateGroup.AttachedObjects(0)

       End If

       tbl.Caption = "My Caption"
       'tbl.Picture = SomePicture

       bx.ToolTip = "My Tooltip"

    End Sub
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo and groups
Reply #7 - Nov 3rd, 2005 at 1:15pm
Print Post  
I've copied that code in a new VB.NET project using all default Flowchart properties and undo works fine. So the value of some property might affect that... Could you copy here the InitializeComponent() code related to the flowChart initialization ?

Btw what Flowchart.NET version do you use ?

Thanks
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #8 - Nov 3rd, 2005 at 1:23pm
Print Post  
I am evaluating Flowchart.Net at the moment - version is 3.2.3.28513 downloaded from your website about 14 days ago.

Flowchart is initialised after form load using method below:

    Public Sub SetWorkflowDefaults(ByRef flwChart As MindFusion.FlowChartX.FlowChart)

       flwChart.AllowDrop = True
       flwChart.AllowLinksRepeat = False
       flwChart.AllowUnanchoredArrows = False
       flwChart.ArrowColor = Color.DarkOrange
       flwChart.ArrowCrossings = MindFusion.FlowChartX.EArrowCrossings.acArcs
       flwChart.ArrowHead = MindFusion.FlowChartX.EArrowHead.ahPointerArrow
       flwChart.ArrowHeadSize = 3.5!
       flwChart.ArrowIntermSize = 2.0!
       flwChart.ArrowPen = New MindFusion.FlowChartX.Pen("1;#FFFF8C00;1.4;0;0;")
       flwChart.ArrowSegments = CType(2, Short)
       flwChart.ArrowStyle = MindFusion.FlowChartX.EArrowStyle.asBezier
       flwChart.AutoSizeDoc = MindFusion.FlowChartX.EAutoSize.asRightAndDown
       flwChart.BackBrush = New MindFusion.FlowChartX.SolidBrush("#FFF1EFE2")
       flwChart.BoxBrush = New MindFusion.FlowChartX.LinearGradientBrush("228.3665;#FFC0C0FF;#FFC0C0FF")
       flwChart.BoxFrameColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(0, Byte))
       flwChart.BoxPen = New MindFusion.FlowChartX.Pen("0;#FF000000;0;0;0;")
       flwChart.BoxStyle = MindFusion.FlowChartX.EBoxStyle.bsRect
       flwChart.CurArrowCannotCreate = System.Windows.Forms.Cursors.No
       flwChart.CurArrowEnd = System.Windows.Forms.Cursors.Hand
       flwChart.CurArrowStart = System.Windows.Forms.Cursors.Hand
       flwChart.CurCannotCreate = System.Windows.Forms.Cursors.No
       flwChart.CurHorzResize = System.Windows.Forms.Cursors.SizeWE
       flwChart.CurMainDgnlResize = System.Windows.Forms.Cursors.SizeNWSE
       flwChart.CurModify = System.Windows.Forms.Cursors.SizeAll
       flwChart.CurPointer = System.Windows.Forms.Cursors.Arrow
       flwChart.CurSecDgnlResize = System.Windows.Forms.Cursors.SizeNESW
       flwChart.CurVertResize = System.Windows.Forms.Cursors.SizeNS
       flwChart.ExteriorBrush = Nothing
       flwChart.GridSize = 5.0!
       flwChart.InplaceEditFont = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
       flwChart.Location = New System.Drawing.Point(0, 0)
       flwChart.RouteArrows = True
       flwChart.ShadowColor = System.Drawing.Color.DarkGray
       flwChart.ShadowOffsetX = 0.75!
       flwChart.ShadowOffsetY = 0.75!
       flwChart.SnapToAnchor = MindFusion.FlowChartX.ESnapToAnchor.saOnCreateOrModify
       flwChart.TableBrush = New MindFusion.FlowChartX.SolidBrush("#FFB4A0A0")
       flwChart.TableFrameColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(0, Byte))
       flwChart.TablePen = New MindFusion.FlowChartX.Pen("0;#FF000000;0;0;0;")
       flwChart.TextFormat.Alignment = System.Drawing.StringAlignment.Center
       flwChart.TextFormat.FormatFlags = System.Drawing.StringFormatFlags.NoFontFallback
       flwChart.TextFormat.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None
       flwChart.TextFormat.LineAlignment = System.Drawing.StringAlignment.Center
       flwChart.TextFormat.Trimming = System.Drawing.StringTrimming.Character
       flwChart.UndoManager.UndoEnabled = True

       flwChart.BoxBrush = New MindFusion.FlowChartX.LinearGradientBrush(Color.White, Color.PaleGoldenrod, 90)
       flwChart.BoxSelStyle = ESelStyle.sstHatchHandles3
       flwChart.BoxStyle = EBoxStyle.bsRect
       flwChart.ArrowBrush = New MindFusion.FlowChartX.SolidBrush(Color.DarkOrange)
       flwChart.ShowDisabledHandles = False
       flwChart.ModificationStart = EModificationStyle.mdAutoHandles
       flwChart.AntiAlias = SmoothingMode.HighQuality
       flwChart.PrpArrowStartOrnt = EOrientation.soAuto
       flwChart.SnapToAnchor = ESnapToAnchor.saOnCreateOrModify
       flwChart.GridSize = 5
       flwChart.Font = New Font("microsoft sans serif", 3, GraphicsUnit.World)

    End Sub

  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #9 - Nov 3rd, 2005 at 1:26pm
Print Post  
BTW, the undo 'looks' like it has worked, until you click away from the 'un-deleted' box, at which point the table seems to 'disappear'.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo and groups
Reply #10 - Nov 3rd, 2005 at 2:33pm
Print Post  
You are right, that's a problem with the ZIndex - the table is there but behind the box. The developer that works on the undo functions will try to fix that tomorrow. For now, you could try as a workaround setting the table's ZIndex again after undoing a "BoxAdd" command .
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #11 - Nov 3rd, 2005 at 3:02pm
Print Post  
what methods/properties do I access to determine which box was just 'un-deleted'?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo and groups
Reply #12 - Nov 3rd, 2005 at 5:11pm
Print Post  
I guess that would be the last box in the Boxes collection, i.e. fc.Boxes(fc.Boxes.Count-1).
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #13 - Nov 4th, 2005 at 9:08am
Print Post  
The 'ActionUndone' event is raising the following sequence of commands being undone:

"Ungroup"
"Delete"
"Detach from group"
"Delete"

Just for your info,  I have had to implement the following code:

    Private Sub flwChart_ActionUndone(ByVal sender As Object, ByVal e As MindFusion.FlowChartX.UndoEventArgs) Handles flwChart.ActionUndone
       If e.Command.Title.ToLower = "delete" Then
           Try
               Dim Cmd As Commands.RemoveItemCmd = e.Command
               ' try cast to a box
               Dim bx As Box = Cmd.Item
               ' if we get here, we're recovering a box
               ' need to handle workflow z-index bug
               Dim tbl As Table = bx.SubordinateGroup.AttachedObjects(0)
               tbl.ZIndex = bx.ZIndex + 1
           Catch
           End Try
       End If
    End Sub
  
Back to top
 
IP Logged
 
rusted
YaBB Newbies
*
Offline



Posts: 42
Joined: Nov 3rd, 2005
Re: Undo and groups
Reply #14 - Nov 4th, 2005 at 11:31am
Print Post  
Sad

I am afraid the saga continues.  I have now added an extra box to the group which initially is given a ZIndex of 1 greater than the table (which has a ZIndex 1 greater than the mainobject box.  If I select a main box, delete it, and then do an Undo, the 1st item added to the group (the table) appears correctly due to the workaround coded below, but with the main box selected, the 2nd item added to the group (the small box) is not visible.  If I de-activate the main box by clicking away from it, the small box now re-appears.  Whenever the main box gets re-selected, however, the small box once again disappears.

Another thing I have noticed is that items get added to the beginning of the main box subordinate objects list (iow, table gets added 1st, then small box, but small box ends up at offset 0 and the table at offset 1 in the list)?


Code to reproduce the problem is in the next post (as otherwise the message was to big) ...
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 3 ... 6
Send TopicPrint