public SMCtlBase(SMContainerPanel containerPanel, SMFlowBase flowItem, Size ctlSize) { _containerPanel = containerPanel; _flowItem = flowItem; InitializeComponent(); this.Name = flowItem.Name; Size = ctlSize; Location = GridLocToLocation(); label.Size = new Size(ctlSize.Width - 8, label.Size.Height); this.Cursor = Cursors.Default; _fontBase = this.label.Font; _fontBold = new Font(this.label.Font, FontStyle.Bold); containerPanel.Controls.Add(this); Build(_flowItem[SMFlowBase.eDir.Up]); Build(_flowItem[SMFlowBase.eDir.Down]); Build(_flowItem[SMFlowBase.eDir.Left]); Build(_flowItem[SMFlowBase.eDir.Right]); delFlowHightlightedChanged = new SMFlowBase.DelHightedOnChange(HighlitedOnChanged); flowItem.evHighlightedOnChaged += delFlowHightlightedChanged; OnChanged(); BringToFront(); }
/// <summary> /// Constructor /// </summary> /// <param name="containerPanel"></param> /// <param name="flowItem"></param> /// <param name="ctlBase"></param> /// <param name="pathSeg"></param> public SegmentCtl(SMContainerPanel containerPanel, SMFlowBase flowItem, SMCtlBase ctlBase, SMPathSegment pathSeg) { _containerPanel = containerPanel; _flowItem = flowItem; _ctlBase = ctlBase; _pathSeg = pathSeg; if (pathSeg.First is SMPathOutError) { _penLine = new Pen(Color.Red, 2); _penSelected = new Pen(Color.Red, 6); _penNoTarget = new Pen(Color.Salmon, 6); } else if (pathSeg.First is SMPathOutStop) { _penLine = new Pen(Color.Black, 2); _penSelected = new Pen(Color.Blue, 6); _penNoTarget = new Pen(Color.DarkGray, 6); } else { _penLine = new Pen(Color.Green, 2); _penSelected = new Pen(Color.Green, 6); _penNoTarget = new Pen(Color.DarkGreen, 6); } _ctlBase.LocationChanged += new EventHandler(ctlBase_OnLocationChanged); InitializeComponent(); }
public TransitionCtl(SMContainerPanel containerPanel, SMFlowBase flowItem) : base(containerPanel, flowItem, global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.TransitionFlow.Size) { InitializeComponent(); U.RegisterOnChanged(() => (FlowItem as SMTransition).HasProblem, hasProblemOnChanged); OnChanged(); }
private void Build(SMFlowBase flowItem) { if (flowItem is SMStart || flowItem is SMExit) { new StartStopCtl(this, flowItem); } else if (flowItem is SMActionFlow) { new ActionCtl(this, flowItem); } else if (flowItem is SMDecision) { new DecisionCtl(this, flowItem); } else if (flowItem is SMSubroutine) { new SubroutineCtl(this, flowItem as SMSubroutine); } else if (flowItem is SMTransition) { new TransitionCtl(this, flowItem); } else if (flowItem is SMActTransFlow) { new ActTransCtl(this, flowItem); } else { throw new Exception(string.Format("'{0}' is not yet supported", flowItem.GetType().Name)); } }
public void DeleteFlowItem(SMFlowBase flowItem) { U.LogChangeRemoved(flowItem.Nickname); _flowChartCtlBasic.RemoveFlowContainer(flowItem as SMFlowContainer); flowItem.Delete(); Dispose(flowItem); Redraw(); }
public SMCtlBase GetFlowCtl(SMFlowBase flowItem) { if (flowItem == null) { return(null); } return(GetFlowCtl(flowItem.Name)); }
public void Dispose(SMFlowBase flowItem) { SMCtlBase ctlBase = GetFlowCtl(flowItem); if (ctlBase != null) { Dispose(ctlBase); } }
/// <summary> /// Move the arrow to the right position /// </summary> /// <param name="flowItem"></param> /// <param name="pathOut"></param> public void MoveIt(SMFlowBase flowItem, SMPathOut pathOut) { try { _ctrlBasefromPathOut = _containerPanel.GetFlowCtl(pathOut.Owner.Name); _ctlBaseTgt = _containerPanel.GetFlowCtl(pathOut.TargetID); if (_ctlBaseTgt == null) { return; } Size arrowSize = global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.ArrowUp.Size; Point borderLocation = _ctlBaseTgt.Location; Size borderSize = _ctlBaseTgt.Size; borderLocation.Offset(-arrowSize.Width, -arrowSize.Height); borderSize.Width += arrowSize.Width; borderSize.Height += arrowSize.Height; Rectangle rcBorder = new Rectangle(borderLocation, borderSize); PointF endPt = flowItem.FindEndPoint(pathOut); Point pixXY = SMContainerPanel.GridToPixel(endPt); SMPathSegment pathLastSeg = pathOut.Last; if (pathLastSeg.Vertical) { if (pathLastSeg.GridDistance < 0) { // Up SetBackgroundImage(global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.ArrowUp); Location = new Point(pixXY.X - arrowSize.Width / 2, rcBorder.Bottom); } else { // Down SetBackgroundImage(global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.ArrowDown); Location = new Point(pixXY.X - arrowSize.Width / 2, rcBorder.Top); } } else { if (pathLastSeg.GridDistance < 0) { // Left SetBackgroundImage(global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.ArrowLeft); Location = new Point(rcBorder.Right, pixXY.Y - arrowSize.Height / 2); } else { // Right SetBackgroundImage(global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.ArrowRight); Location = new Point(rcBorder.Left, pixXY.Y - arrowSize.Height / 2); } } _ctrlBasefromPathOut.LocationChanged += new EventHandler(ctrlBasefromPathOut_OnLocationChanged); _locOfstFromCtrlBase = new Point(_ctrlBasefromPathOut.Location.X - this.Location.X, _ctrlBasefromPathOut.Location.Y - this.Location.Y); Show(); } catch (Exception ex) { ex.ToString(); } }
public void AddNewFlowItem(Type flowItemType, PointF ptGridPt, string text) { SMFlowBase flowItem = Activator.CreateInstance(flowItemType, string.Empty) as SMFlowBase; flowItem.Text = text; flowItem.GridLoc = ptGridPt; _flowContainer.AddFlowItem(flowItem); U.LogChangeAdded(string.Format("{0}.{1}", flowItem.Nickname, text)); Build(flowItem); Redraw(flowItem); }
/// <summary> /// Constructor /// </summary> /// <param name="flowChart"></param> /// <param name="panel"></param> /// <param name="flowItem"></param> /// <param name="ctlBase"></param> /// <param name="pathSeg"></param> public SegmentCtl(SMGenericFlowChart flowChart, Panel panel, SMFlowBase flowItem, SMCtlBase ctlBase, SMPathSegment pathSeg) { _flowChart = flowChart; _panel = panel; _flowItem = flowItem; _ctlBase = ctlBase; _pathSeg = pathSeg; ArrowEnd = IsLast; InitializeComponent(); }
private void ClearAllSelection() { foreach (Control ctrl in this.Controls) { SMCtlBase smCtrl = ctrl is SMCtlBase ? ctrl as SMCtlBase : null; if (smCtrl != null) { smCtrl.FlowItem.Highlighted = false; } } _selectedCtrlList = null; _latestFlowItem = null; }
public void Redraw(SMFlowBase flowItem) { if (flowItem != null) { flowItem.DetermineAllPathTargets(); SMCtlBase ctlBase = GetFlowCtl(flowItem); if (ctlBase != null) { ctlBase.MoveItem(); ctlBase.OnChanged(); } } }
public void ShowContextMenu(SMFlowBase flowItem, PointF ptGridLoc) { tsmCopyItem.Enabled = !(flowItem == null); tsmPasteItem.Enabled = !(_copyFlowItem == null) && flowItem == null; tsmDeselectItem.Enabled = flowItem != null && flowItem.Highlighted; tsmDeleteItem.Enabled = flowItem != null; //|| _selectedCtrlList != null; //tsmCopyItem.Visible = false; //tsmPasteItem.Visible = false; _latestFlowItem = flowItem; _latestptGridLoc = ptGridLoc; contextMenuStrip.Show(MousePosition); }
/// <summary> /// Enter a flow item /// </summary> public void EnterFlowItem(SMFlowBase currentFlowItem) { lock (_listFlowPanels) { currentFlowItem.Highlighted = true; if (currentFlowItem.IncomingPath != null) { currentFlowItem.IncomingPath.Highlighted = true; } foreach (SMFlowChartCtlBase flowChartBase in _listFlowPanels) { flowChartBase.RefreshFlowItem(currentFlowItem, Mode == eMode.Pause); } } }
private void RecurseRebuild(SMFlowBase flow) { flow.Rebuild(); if (flow.ChildArray != null) { foreach (SMFlowBase childFlow in flow.ChildArray) { if (childFlow is SMFlowContainer) { RecurseRebuild(childFlow); } else { childFlow.Rebuild(); } } } }
/// <summary> /// Entry into a flow item /// </summary> public void RefreshFlowItem(SMFlowBase currentFlowItem) { SMCtlBase ctlBase = GetFlowCtl(currentFlowItem); if (ctlBase != null) { ctlBase.OnChanged(); if (currentFlowItem.IncomingPath != null) { SMFlowBase pathFlowItem = currentFlowItem.IncomingPath.Owner; ctlBase = GetFlowCtl(pathFlowItem); if (ctlBase != null) { ctlBase.MoveIt(currentFlowItem.IncomingPath); } } } }
public override void RefreshFlowItem(SMFlowBase currentFlowItem, bool stepping) { if (InvokeRequired) { try { BeginInvoke(new delFlowBase(RefreshFlowItem), currentFlowItem, stepping); } catch (ObjectDisposedException) { } return; } else if (!IsDisposed && _currentContainerPanel != null) { if (Visible && stepping) { ShowFlowContainer(currentFlowItem.ParentContainer); } _currentContainerPanel.RefreshFlowItem(currentFlowItem); } }
/// <summary> /// Initialize this segment /// </summary> /// <param name="vertical"></param> public virtual void Initialize(SMFlowBase flowBase, bool vertical) { _flowBase = flowBase; Initialize(this, vertical, 0); InitializeRecurse(); }
/// <summary> /// Enter a flow item /// </summary> /// <param name="currentFlowItem"></param> /// <param name="stepping"></param> public virtual void RefreshFlowItem(SMFlowBase currentFlowItem, bool stepping) { }
/// <summary> /// Initialize this PathSegment /// </summary> /// <param name="vertical"></param> public override void Initialize(SMFlowBase flowBase, bool vertical) { }
private void ReconnectPathLine(PointF ptGridPt, SMFlowBase targetFlow, eInsertGridMode insertMode) { switch (insertMode) { case eInsertGridMode.rowBefore: foreach (SMFlowBase flow in _flowContainer.ChildArray) { if (flow.GridLoc.Y >= ptGridPt.Y) { continue; } foreach (SMPathOut pathOut in flow.PathArray) { if (pathOut.TargetID == targetFlow.Name) { SMPathSegment verticalSecment = GetVerticalPathSecment(pathOut.Last, eVerticalDir.Down); if (verticalSecment != null) { verticalSecment.GridDistance += 1; } } } foreach (SMPathOut pathOut in targetFlow.PathArray) { if (pathOut.TargetID == flow.Name) { SMPathSegment verticalSecment = GetVerticalPathSecment(pathOut.Last, eVerticalDir.Up); if (verticalSecment != null) { verticalSecment.GridDistance -= 1; } } } } break; case eInsertGridMode.rowAfter: foreach (SMFlowBase flow in _flowContainer.ChildArray) { if (flow.GridLoc.Y >= ptGridPt.Y + 1) { continue; } foreach (SMPathOut pathOut in flow.PathArray) { if (pathOut.TargetID == targetFlow.Name) { SMPathSegment verticalSecment = GetVerticalPathSecment(pathOut.Last, eVerticalDir.Down); if (verticalSecment != null) { verticalSecment.GridDistance += 1; } } } foreach (SMPathOut pathOut in targetFlow.PathArray) { if (pathOut.TargetID == flow.Name) { SMPathSegment verticalSecment = GetVerticalPathSecment(pathOut.Last, eVerticalDir.Up); if (verticalSecment != null) { verticalSecment.GridDistance -= 1; } } } } break; case eInsertGridMode.columnBefore: foreach (SMFlowBase flow in _flowContainer.ChildArray) { if (flow.GridLoc.X >= ptGridPt.X) { continue; } foreach (SMPathOut pathOut in flow.PathArray) { if (pathOut.TargetID == targetFlow.Name) { SMPathSegment horizontalSecment = GetHorizontalPathSecment(pathOut.Last, eHorizontalDir.Right); if (horizontalSecment != null) { horizontalSecment.GridDistance += 1; } } } foreach (SMPathOut pathOut in targetFlow.PathArray) { if (pathOut.TargetID == flow.Name) { SMPathSegment horizontalSecment = GetHorizontalPathSecment(pathOut.Last, eHorizontalDir.Left); if (horizontalSecment != null) { horizontalSecment.GridDistance -= 1; } } } } break; case eInsertGridMode.columnAfter: foreach (SMFlowBase flow in _flowContainer.ChildArray) { if (flow.GridLoc.X >= ptGridPt.X + 1) { continue; } foreach (SMPathOut pathOut in flow.PathArray) { if (pathOut.TargetID == targetFlow.Name) { SMPathSegment horizontalSecment = GetHorizontalPathSecment(pathOut.Last, eHorizontalDir.Right); if (horizontalSecment != null) { horizontalSecment.GridDistance += 1; } } } foreach (SMPathOut pathOut in targetFlow.PathArray) { if (pathOut.TargetID == flow.Name) { SMPathSegment horizontalSecment = GetHorizontalPathSecment(pathOut.Last, eHorizontalDir.Left); if (horizontalSecment != null) { horizontalSecment.GridDistance -= 1; } } } } break; default: break; } }
//public StartStopCtl() //{ // InitializeComponent(); //} public StartStopCtl(SMContainerPanel containerPanel, SMFlowBase flowItem) : base(containerPanel, flowItem, global:: MCore.Comp.SMLib.SMFlowChart.Properties.Resources.StartStop.Size) { InitializeComponent(); }
public void AddToDecisionList(SMDecision decisionItem, SMFlowBase flowItemForPathOut, SMPathOut pathOut) { _decisionLoopList.Add(decisionItem); _pathLoopDict.Add(pathOut, flowItemForPathOut); }
public ActionCtl(SMContainerPanel containerPanel, SMFlowBase flowItem) : base(containerPanel, flowItem, global::MCore.Comp.SMLib.SMFlowChart.Properties.Resources.ActionFlow.Size) { InitializeComponent(); OnChanged(); }
private void contextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { contextMenuStrip.Close(); if (e.ClickedItem == tsmInsertGripUpper) { ClearAllSelection(); InsertGrid(_latestptGridLoc, eInsertGridMode.rowBefore); } else if (e.ClickedItem == tsmInsertGridBelow) { ClearAllSelection(); InsertGrid(_latestptGridLoc, eInsertGridMode.rowAfter); } else if (e.ClickedItem == tsmInsertGridLeft) { ClearAllSelection(); InsertGrid(_latestptGridLoc, eInsertGridMode.columnBefore); } else if (e.ClickedItem == tsmInsertGridRight) { ClearAllSelection(); InsertGrid(_latestptGridLoc, eInsertGridMode.columnAfter); } else if (e.ClickedItem == tsmCopyItem) { if (_latestFlowItem != null) { _copyFlowItem = _latestFlowItem.Clone("", true) as SMFlowBase; _latestFlowItem.ShallowCopyTo(_copyFlowItem); } } else if (e.ClickedItem == tsmPasteItem) { SMFlowBase newCopyflowItem = _copyFlowItem; newCopyflowItem.Name = ""; _flowContainer.AddFlowItem(newCopyflowItem); newCopyflowItem.Text = _copyFlowItem.Text; newCopyflowItem.GridLoc = _latestptGridLoc; U.LogChangeAdded(string.Format("{0}.{1}", newCopyflowItem.Nickname, _copyFlowItem.Text)); Build(newCopyflowItem); newCopyflowItem.Rebuild(); Redraw(newCopyflowItem); if (newCopyflowItem is SMFlowContainer) { RecurseRebuild(newCopyflowItem); } _copyFlowItem = null; } else if (e.ClickedItem == tsmDeleteItem) { if (MessageBox.Show("This Flow item will be deleted. Are you sure?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (_latestFlowItem != null && this._flowContainer.ChildArray.Contains(_latestFlowItem)) { SMCtlBase deleteFlowCtrl = GetFlowCtl(_latestFlowItem); if (_selectedCtrlList != null && _selectedCtrlList.Contains(deleteFlowCtrl)) { _selectedCtrlList.Remove(deleteFlowCtrl); } this.DeleteFlowItem(_latestFlowItem); } _latestFlowItem = null; } } else if (e.ClickedItem == tsmSelectItem) { SMCtlBase smCtrl = this.GetFlowCtl(_latestFlowItem); if (_selectedCtrlList == null) { _selectedCtrlList = new List <SMCtlBase>(); } _selectedCtrlList.Add(smCtrl); smCtrl.FlowItem.Highlighted = true; } else if (e.ClickedItem == tsmDeselectItem) { SMCtlBase smCtrl = this.GetFlowCtl(_latestFlowItem); smCtrl.FlowItem.Highlighted = false; _selectedCtrlList.Remove(smCtrl); if (_selectedCtrlList.Count == 0) { _selectedCtrlList = null; } } else if (e.ClickedItem == tsmClearSelection) { ClearAllSelection(); } }