|
'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 mWFItems As New Hashtable 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, WFNodeWidth, WFNodeHeight) dim csiID as String = System.Guid.NewGuid.ToString InitialiseWorkflowNode(flwChart, bx, csiID, True) AddWorkflowItem(csiID) cmd.Execute() End Sub
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, is it the main one? If mWFItems.ContainsKey(bx.Tag) Then ' yep, this is the baby, so ... ' need to handle workflow z-index bug SetGroupZOrder(bx) End If Catch End Try End If End Sub
Private Sub flwChart_BoxActivated(ByVal sender As Object, ByVal e As MindFusion.FlowChartX.BoxEventArgs) Handles flwChart.BoxActivated If mWFItems.ContainsKey(e.Box.Tag) Then SetGroupZOrder(e.Box) End If End Sub
Private Sub flwChart_BoxDeactivated(ByVal sender As Object, ByVal e As MindFusion.FlowChartX.BoxEventArgs) Handles flwChart.BoxDeactivated If mWFItems.ContainsKey(e.Box.Tag) Then SetGroupZOrder(e.Box) End If End Sub Private Sub AddWorkflowItem(ByVal csiID As String) If Not mWFItems.ContainsKey(csiID) Then mWFItems.Add(csiID, csiID) End If End Sub Private Sub SetGroupZOrder(ByVal bx As Box) Try Dim tbl As Table = bx.SubordinateGroup.AttachedObjects(1) tbl.ZIndex = bx.ZIndex + 4 ' + 1 Dim bxImage As Box = bx.SubordinateGroup.AttachedObjects(0) bxImage.ZIndex = tbl.ZIndex + 8 ' + 1 Catch End Try 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 Dim bxPic As MindFusion.FlowChartX.Box bx.Tag = csiID bx.Text = vbCrLf + vbCrLf + csi.ProcessName If newBox Then bx.MnpHandlesMask = 256 bx.Resize(WFNodeWidth, WFNodeHeight) bx.SelStyle = ESelStyle.sstHatchHandles3 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.Tag = bx.Tag grp.AttachToCorner(tbl, 0) grp.AutoDeleteItems = True bxPic = flwChart.CreateBox(bx.BoundingRect.Location.X, bx.BoundingRect.Location.Y, 8, 8) bxPic.Style = EBoxStyle.bsRect bxPic.FillColor = Color.Transparent bxPic.FrameColor = Color.Transparent bxPic.PicturePos = EImagePos.imgCenterRight bxPic.ZIndex = tbl.ZIndex + 1 bxPic.AnchorPattern = Nothing bxPic.ShadowOffsetX = 0 bxPic.ShadowOffsetY = 0 bxPic.Locked = True grp.AttachToCorner(bxPic, 0) Else bxPic = bx.SubordinateGroup.AttachedObjects(0) tbl = bx.SubordinateGroup.AttachedObjects(1) End If tbl.Caption = "My Caption" bxPic.Picture = SomePicture bx.ToolTip = "My Tooltip" End Sub
|