internal void start(PointF point, FlowChart fc) { cycleRoots.Clear(); affectedArrows.Clear(); startPoint = currentPoint = point; if (action == Action.Split) { invalidRect = currentObject.getRepaintRect(true); return; } if (action == Action.Create) { fc.raiseInitEvent(currentObject); currentObject.startCreate(point); } if (action == Action.Modify) { fc.fireBeginModifyEvent(currentObject, point, selectionHandle); currentObject.startModify(point, selectionHandle, this); } invalidRect = currentObject.getRepaintRect(action == Action.Modify); }
public Overview() { // Set some styles SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.UserPaint, true); document = null; options = new MindFusion.FlowChartX.PrintOptions(null); smoothMode = SmoothingMode.Default; scaleFactor = 30; fitToAll = false; marginalColor = Color.FromArgb(35, Color.Black); // Initialize rendering options options.EnableShadows = true; options.EnableImages = true; options.EnableInterior = true; options.EnableBackground = true; options.EnableBackgroundImage = true; options.EnableText = true; options.PaintControls = true; // Auto scroll autoScroll = true; autoScrDX = autoScrDY = 0; }
/// <summary> /// Constructs a new graph representing /// the specified FlowChart diagram. /// </summary> public FCGraph(FlowChart chart, bool keepGroups, bool ignoreArrowDirection) { _chart = chart; directed = !ignoreArrowDirection; Build(keepGroups, ignoreArrowDirection); }
/// <summary> /// Initializes a new instance of the HtmlBuilder class. /// </summary> /// <param name="fc">The FlowChart object whose contents will generate the image map.</param> public HtmlBuilder(FlowChart fc) { flowChart = fc; linkTarget = "_self"; areasForTableCells = false; expandBtnHyperLink = ""; }
internal void cancel(FlowChart fc) { if (currentObject != null) { cycleRoots.Clear(); affectedArrows.Clear(); if (action == Action.Create && !completing) { if (currentObject == fc.Selection) { fc.Selection.cancelCreate(); } else { currentObject.onRemove(); currentObject.freeResources(); } currentObject = null; } if (action == Action.Modify) { currentObject.cancelModify(this); fc.UndoManager.onCancelModify(); RectangleF rcAdd = currentObject.getRepaintRect(true); invalidRect = Utilities.unionRects(invalidRect, rcAdd); } } }
/// <summary> /// initialize the routing grid /// </summary> internal RoutingGrid(FlowChart flowChart) { this.flowChart = flowChart; costGrid = null; closedGrid = null; openGrid = null; }
public VariableNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart, CalculatorNodeType nodeType) : base(ngm, guid, flowChart, nodeType) { Header = typeof(T).Name; HeaderBackgroundColor = Brushes.Black; HeaderFontColor = Brushes.White; AllowCircularConnection = false; }
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); FlowChart flowChart = ViewModel.Model.Owner; FlowChartView flowChartView = flowChart.ViewModel.View; Keyboard.Focus(flowChartView); NodeGraphManager.EndConnection(); NodeGraphManager.EndDragNode(); NodeGraphManager.EndDragSelection(false); NodeGraphManager.MouseLeftDownNode = ViewModel.Model; NodeGraphManager.BeginDragNode(flowChart); Node node = ViewModel.Model; _DraggingStartPos = new Point(node.X, node.Y); flowChart.History.BeginTransaction("Moving node"); _ZoomAndPanStartMatrix = flowChartView.ZoomAndPan.Matrix; e.Handled = true; }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { base.OnMouseLeftButtonUp(e); if (null == ViewModel) { return; } FlowChart flowChart = ViewModel.Model; NodeGraphManager.EndConnection(); NodeGraphManager.EndDragNode(); if (NodeGraphManager.IsSelecting) { bool bChanged = false; flowChart.History.BeginTransaction("Selecting"); { bChanged = NodeGraphManager.EndDragSelection(false); } Point mousePos = e.GetPosition(this); if ((0 != ( int )(mousePos.X - _LeftButtonDownPos.X)) || (0 != ( int )(mousePos.Y - _LeftButtonDownPos.Y))) { flowChart.History.AddCommand(new History.ZoomAndPanCommand( "ZoomAndPan", ViewModel.Model, _ZoomAndPanStartMatrix, ZoomAndPan.Matrix)); bChanged = true; } flowChart.History.EndTransaction(!bChanged); } }
public StartNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart) { // Header = "Start Node"; HeaderFontColor = Brushes.White; HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(92, 20, 15)); }
public FrmPrintPreview(FlowChart fc, string docName) { InitializeComponent(); Landscape = false; flowChart = fc; DocumentName = docName; toolBarBtnActPrint.ToolTipText = "Print"; toolBarBtnActZoomAuto.ToolTipText = "Zoom"; toolBarBtnOnePage.ToolTipText = "One Page"; toolBarBtnTwoPages.ToolTipText = "Two Pages"; toolBarBtnThreePages.ToolTipText = "Three Pages"; toolBarBtnFourPages.ToolTipText = "Four Pages"; toolBarBtnSixPages.ToolTipText = "Six Pages"; toolBarBtnFirstPage.ToolTipText = "First Page"; toolBarBtnPrevPage.ToolTipText = "Previous Page"; toolBarBtnNextPage.ToolTipText = "Next Page"; toolBarBtnLastPage.ToolTipText = "Last Page"; toolBarBtnScale.ToolTipText = "Fit to Page"; toolBarBtnOrientation.ToolTipText = "Landscape"; fitToPage = false; orgScaleFactor = flowChart.PrintOptions.Scale; scaleChange = flowChart.PrintOptions.Scale / 5; // add the installed printers to the printers menu EventHandler printerHandler = new EventHandler(miPrinterMenu_Click); foreach (String printerName in PrinterSettings.InstalledPrinters) { printerMenu.MenuItems.Add(printerName, printerHandler); } }
internal void setCursor(PointF point, FlowChart fc) { if (action == Action.Create) { Cursor cursor = currentObject.allowCreate(point) ? currentObject.getCanDropCursor() : currentObject.getCannotDropCursor(); if (cursor != null) { fc.Cursor = cursor; } } if (action == Action.Modify) { Cursor cursor = currentObject.allowModify(point) ? currentObject.getCanDropCursor() : currentObject.getCannotDropCursor(); if (cursor != null) { fc.Cursor = cursor; } else { fc.Cursor = fc.getCurrBehavior().getCurrentCursor(); } } }
internal void Remove(FlowChart flowChart) { if (Arrow != null) { flowChart.DeleteObject(Arrow); } }
/// <summary> /// create an image for the given shape /// </summary> private void createImage(ShapeTemplate template, System.Drawing.Brush brush, FlowChart chart) { if (template == null) { return; } Box b = chart.CreateBox(1, 1, imageSize.Width - 4, imageSize.Height - 4); b.Style = BoxStyle.Shape; b.Shape = template; b.PenWidth = 0; b.ShadowColor = Color.FromArgb(40, Color.Black); b.ShadowOffsetX = 1; b.ShadowOffsetY = 1; b.FillColor = ShapeFillColor; b.CustomDraw = CustomDraw.Additional; Bitmap image = new Bitmap(imageSize.Width, imageSize.Height); Graphics g = Graphics.FromImage(image); g.SmoothingMode = SmoothingMode.AntiAlias; g.FillRectangle(brush, -1, -1, imageSize.Width + 1, imageSize.Height + 1); b.Draw(g, true); b.Draw(g, false); images.Images.Add(image); g.Dispose(); }
public void BuildCurveData(Point mousePos) { Connector connector = ViewModel.Model; FlowChart flowChart = connector.FlowChart; FlowChartView flowChartView = flowChart.ViewModel.View; NodePort startPort = connector.StartPort; NodePort endPort = connector.EndPort; Point start = (null != startPort) ? ViewUtil.GetRelativeCenterLocation(startPort.ViewModel.View.PartPort, flowChartView) : mousePos; Point end = (null != endPort) ? ViewUtil.GetRelativeCenterLocation(endPort.ViewModel.View.PartPort, flowChartView) : mousePos; Point center = new Point((start.X + end.X) * 0.5, (start.Y + end.Y) * 0.5); if (start.X > end.X) { Point temp = start; start = end; end = temp; } double ratio = Math.Min(1.0, (center.X - start.X) / 100.0); Point c0 = start; Point c1 = end; c0.X += 100 * ratio; c1.X -= 100 * ratio; CurveData = string.Format("M{0},{1} C{0},{1} {2},{3} {4},{5} " + "M{4},{5} C{4},{5} {6},{7} {8},{9}", ( int )start.X, ( int )start.Y, // 0, 1 ( int )c0.X, ( int )c0.Y, // 2, 3 ( int )center.X, ( int )center.Y, // 4, 5 ( int )c1.X, ( int )c1.Y, // 6, 7 ( int )end.X, ( int )end.Y); // 8.9 }
public OpStringConcat(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart, CNodeType.OpIntegerAdd) { var color = Color.FromRgb(0x64, 0xDD, 0x17); var gradient = new LinearGradientBrush(); gradient.GradientStops.Add(new GradientStop() { Color = color, Offset = 0 }); gradient.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(255, color.R, color.G, color.B), Offset = 0.8 }); gradient.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(80, color.R, color.G, color.B), Offset = 0.96 }); gradient.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(40, color.R, color.G, color.B), Offset = 1.0 }); Header = "Op: String + String"; HeaderBackgroundColor = gradient; }
private void ConnectorView_LayoutUpdated(object sender, EventArgs e) { FlowChart flowChart = ViewModel.Model.FlowChart; FlowChartView flowChartView = flowChart.ViewModel.View; BuildCurveData(Mouse.GetPosition(flowChartView)); }
private List <Guid> copySelection(FlowChart doc) { if (doc.Selection.Objects.Count == 0) { return(null); } List <Guid> copyGuids = new List <Guid>(); foreach (Box box in doc.Selection.Boxes) { GraphicNode graphicNode = frmFlowChart.State.GraphicNode(box); if (graphicNode != null) { copyGuids.Add(graphicNode.Guid); } } foreach (Arrow arrow in doc.Selection.Arrows) { GraphicLink graphicLink = frmFlowChart.State.GraphicLink(arrow); if (graphicLink != null) { copyGuids.Add(graphicLink.Guid); } } return(copyGuids); }
public ControlHost(FlowChart parent) : base(parent) { ctrlMouseAction = parent.HostedCtrlMouseAction; mouseDownHandler = null; mouseUpHandler = null; // ChartObject expects these to be valid pen = (Pen)parent.BoxPen.Clone(); brush = parent.BoxBrush; brush.AddRef(); System.Type controlType = parent.DefaultControlType; _control = null; if (controlType != null) { // Instantiate the control ConstructorInfo ctorInfo = controlType.GetConstructor(System.Type.EmptyTypes); Control ctrl = (System.Windows.Forms.Control)ctorInfo.Invoke(null); if (ctrl != null) { ctrl.Visible = false; } setControl(ctrl); } setExpandable(parent.ControlHostsExpandable); setExpanded(true); selStyle = parent.ControlHostHandlesStyle; }
public VarConstantIntegerNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart, CNodeType.VarConstantInteger) { #endif // //HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(157, 248, 67)); HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(71, 146, 0)); }
public override object Serialize( IDesignerSerializationManager manager, object value) { CodeDomSerializer baseSerializer = manager.GetSerializer( typeof(FlowChart).BaseType, typeof(CodeDomSerializer)) as CodeDomSerializer; object codeObject = baseSerializer.Serialize(manager, value); if (codeObject is CodeStatementCollection) { CodeStatementCollection code = codeObject as CodeStatementCollection; FlowChart chart = value as FlowChart; // Brushes SerializeBrush(code, "BackBrush", chart, chart.BackBrush); SerializeBrush(code, "BoxBrush", chart, chart.BoxBrush); SerializeBrush(code, "TableBrush", chart, chart.TableBrush); SerializeBrush(code, "ArrowBrush", chart, chart.ArrowBrush); // Pens SerializePen(code, "BoxPen", chart, chart.BoxPen); SerializePen(code, "TablePen", chart, chart.TablePen); SerializePen(code, "ArrowPen", chart, chart.ArrowPen); // Text alignment SerializeTextFormat(code, "TextFormat", chart, chart.TextFormat); } return(codeObject); }
internal void saveCommand(Command cmd, FlowChart flowChart) { if (maxDepth == 0 || !flowChart.confirmRecordAction(cmd)) { cmd.freeUndoResources(); return; } if (currCmd < commands.Count - 1) { for (int i = currCmd + 1; i < commands.Count; ++i) { commands[i].freeRedoResources(); } commands.RemoveRange(currCmd + 1, commands.Count - currCmd - 1); } commands.Add(cmd); currCmd++; if (commands.Count > maxDepth) { commands[0].freeUndoResources(); commands.RemoveAt(0); currCmd--; } flowChart.fireActionRecorded(cmd); }
private void SerializePen(CodeStatementCollection code, string property, FlowChart chart, MindFusion.FlowChartX.Pen pen) { string representation; CodeExpression left = null; CodeExpression right = null; CodeStatement line = null; representation = Pen.Serialize(pen); left = new CodePropertyReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), chart.Name), property); right = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeTypeReferenceExpression("MindFusion.FlowChartX.Pen"), "Deserialize"), new CodeExpression[] { new CodePrimitiveExpression(representation) }); line = new CodeAssignStatement(left, right); code.Add(line); }
public FinishNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart) { // Header = "Return"; HeaderFontColor = Brushes.White; HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(51, 20, 30)); }
/// <summary> /// Constructs a new graph representing /// the specified FlowChart diagram. /// </summary> public FCGraph(FlowChart chart, bool keepGroups) { _chart = chart; directed = true; Build(keepGroups, false); }
/// <summary> /// Constructs an empty graph. /// </summary> public FCGraph(FlowChart chart) { _chart = chart; directed = true; _nodes = new NodeCollection(); _links = new LinkCollection(); }
////////////////// // Constructors // ////////////////// /// <summary> /// Creates a new index. Dependency free /// </summary> /// <param name="name">Name of the index</param> /// <param name="description">Description of the index</param> /// <param name="value">Independent value of the index</param> public Index(string name, string description, float value) { Name = name; Description = description; Value = value; // Must be done aftter dependencies is initiallized, otherwise it will throw a exception ID = idCounter++; FlowChart.AddIndex(this); }
void gridControl1_CellClick(FlowChart flowChart, PK.Grid.Def.ColumnDef <FlowChart> column) { if (column.HeaderText == "Undo") { blnRestoring = true; nPanel1.SetFlatModeJSON(JSONUtil.Serialize(flowChart)); blnRestoring = false; } }
public CompositeCmd(FlowChart flowChart, string title, bool saveZOrder) : base(title) { this.flowChart = flowChart; zOrder = null; if (saveZOrder) zOrder = flowChart.Objects.Clone(); }
public void FitNodesToView(bool bOnlySelected) { double minX; double maxX; double minY; double maxY; NodeGraphManager.CalculateContentSize(ViewModel.Model, bOnlySelected, out minX, out maxX, out minY, out maxY); if ((minX == maxX) || (minY == maxY)) { return; } FlowChart flowChart = ViewModel.Model; flowChart.History.BeginTransaction("Destroy Selected Nodes"); { _ZoomAndPanStartMatrix = ZoomAndPan.Matrix; double vsWidth = _ZoomAndPan.ViewWidth; double vsHeight = _ZoomAndPan.ViewHeight; Point margin = new Point(vsWidth * 0.05, vsHeight * 0.05); minX -= margin.X; minY -= margin.Y; maxX += margin.X; maxY += margin.Y; double contentWidth = maxX - minX; double contentHeight = maxY - minY; _ZoomAndPan.StartX = (minX + maxX - vsWidth) * 0.5; _ZoomAndPan.StartY = (minY + maxY - vsHeight) * 0.5; _ZoomAndPan.Scale = 1.0; Point vsZoomCenter = new Point(vsWidth * 0.5, vsHeight * 0.5); Point zoomCenter = _ZoomAndPan.MatrixInv.Transform(vsZoomCenter); double newScale = Math.Min(vsWidth / contentWidth, vsHeight / contentHeight); _ZoomAndPan.Scale = Math.Max(0.1, Math.Min(1.0, newScale)); Point vsNextZoomCenter = _ZoomAndPan.Matrix.Transform(zoomCenter); Point vsDelta = new Point(vsZoomCenter.X - vsNextZoomCenter.X, vsZoomCenter.Y - vsNextZoomCenter.Y); _ZoomAndPan.StartX -= vsDelta.X; _ZoomAndPan.StartY -= vsDelta.Y; if (0 != ( int )(_ZoomAndPan.Matrix.OffsetX - _ZoomAndPanStartMatrix.OffsetX) || 0 != ( int )(_ZoomAndPan.Matrix.OffsetX - _ZoomAndPanStartMatrix.OffsetX)) { flowChart.History.AddCommand(new History.ZoomAndPanCommand( "ZoomAndPan", ViewModel.Model, _ZoomAndPanStartMatrix, ZoomAndPan.Matrix)); } } flowChart.History.EndTransaction(false); }
void nPanel1_Change(string strJSON) { if (!blnRestoring) { FlowChart flowChart = JSONUtil.Deserialize <FlowChart>(strJSON); flowChart.Timestamp = DateTime.Now.ToString("hh:mm:ss"); undoList.Add(flowChart); gridControl1.Invalidate(); } }
internal ModifyBehavior(FlowChart fc) : base(fc) {}
public virtual bool Arrange(FlowChart chart) { chart.UndoManager.onStartLayout("Grid layout"); // Build the graph FCGraph graph = new FCGraph(chart, _keepGroupLayout); // Find the root adapter Layout.INode rootNode = null; if (_root != null) { foreach (FCNode node in graph.Nodes) { if (node.Node == _root) { rootNode = node; break; } } } // Split graph to subgraphs Layout.IGraph[] subgraphs = null; if (_splitGraph) { subgraphs = Layout.GraphSplitter.Split( graph, new FCGraphBuilder(chart, false)); } else { subgraphs = new Layout.IGraph[] { graph }; } // Create the layouter Layout.GridLayout layout = new Layout.GridLayout(); Layout.LayoutProgress progress = null; if (_progress != null) progress = new Layout.LayoutProgress(this.OnLayoutProgress); Layout.GridLayoutInfo info = new Layout.GridLayoutInfo(); info.GridSize = this.GridSize; info.Iterations = this.Iterations; info.XGap = this.XGap; info.YGap = this.YGap; info.RndSeed = this.RndSeed; float xOffset = XGap; foreach (FCGraph subgraph in subgraphs) { // If a root node is specified and the subgraph // does not contain that node, do not arrange // the subgraph if (rootNode != null) { if (!subgraph.Nodes.Contains(rootNode)) continue; } // Set the start and end nodes info.StartNode = null; info.EndNode = null; foreach (FCNode node in subgraph.Nodes) { if (node.Node == _startNode) info.StartNode = node; if (node.Node == _endNode) info.EndNode = node; } // Ensure both start and end nodes are set if (info.StartNode == null || info.EndNode == null) { info.StartNode = null; info.EndNode = null; } layout.Arrange(subgraph, info, progress); // Translate the whole subgraph RectangleF graphBounds = subgraph.GetBounds(false); float xToMove = xOffset - graphBounds.X; float yToMove = info.YGap - graphBounds.Y; foreach (FCNode node in subgraph.Nodes) { RectangleF nodeBounds = node.Bounds; RectangleF oldBounds = node.Node.BoundingRect; nodeBounds.X += xToMove; nodeBounds.Y += yToMove; node.Bounds = nodeBounds; if (_layoutNode != null) _layoutNode(node.Node, oldBounds); } xOffset += graphBounds.Width + info.GridSize; // Update arrows foreach (FCLink link in subgraph.Links) { if (link.Arrow.IgnoreLayout) continue; link.Arrow.arrangePoints(_anchoring); if (_layoutLink != null) _layoutLink(link.Arrow); } } chart.RouteAllArrows(); chart.Invalidate(); chart.UndoManager.onEndLayout(); return true; }
public virtual bool Arrange(FlowChart chart) { chart.UndoManager.onStartLayout("Anneal layout"); // Build the graph FCGraph graph = new FCGraph(chart, _keepGroupLayout); // Find the root adapter Layout.INode rootNode = null; if (_root != null) { foreach (FCNode node in graph.Nodes) { if (node.Node == _root) { rootNode = node; break; } } } // Split graph to subgraphs Layout.IGraph[] subgraphs = null; if (_splitGraph) { subgraphs = Layout.GraphSplitter.Split( graph, new FCGraphBuilder(chart, false)); } else { subgraphs = new Layout.IGraph[] { graph }; } // Create the layouter Layout.AnnealLayout layout = new Layout.AnnealLayout(); Layout.LayoutProgress progress = null; if (_progress != null) progress = new Layout.LayoutProgress(this.OnLayoutProgress); Layout.AnnealLayoutInfo info = new Layout.AnnealLayoutInfo(); info.DistributionFactor = this.DistributionFactor; info.BoundaryFactor = this.BoundaryFactor; info.EdgeLengthFactor = this.ArrowLengthFactor; info.CrossingEdgesCost = this.CrossingArrowsCost; info.NodeEdgeDistFactor = this.NodeArrowDistFactor; info.IterationsPerStage = this.IterationsPerStage; info.Stages = this.Stages; info.Temperature = this.InitialTemperature; info.TemperatureScale = this.TemperatureScale; info.LayoutArea = this.LayoutArea; info.WidthHeightRatio = this.WidthHeightRatio; info.Randomize = this.Randomize; float xOffset = 0; foreach (FCGraph subgraph in subgraphs) { // If a root node is specified and the subgraph // does not contain that node, do not arrange // the subgraph if (rootNode != null) { if (!subgraph.Nodes.Contains(rootNode)) continue; } layout.Arrange(subgraph, info, progress); // Translate the whole subgraph RectangleF graphBounds = subgraph.GetBounds(false); float xToMove = xOffset - graphBounds.X; float yToMove = -graphBounds.Y; foreach (FCNode node in subgraph.Nodes) { RectangleF nodeBounds = node.Bounds; RectangleF oldBounds = node.Node.BoundingRect; nodeBounds.X += xToMove; nodeBounds.Y += yToMove; node.Bounds = nodeBounds; if (_layoutNode != null) _layoutNode(node.Node, oldBounds); } xOffset += graphBounds.Width; // Update arrows foreach (FCLink link in subgraph.Links) { Arrow arrow = link.Arrow; if (arrow.IgnoreLayout) continue; // If the arrow being arranged is dynamic, // ignore the anchoring flag? if (arrow.Dynamic) arrow.updatePosFromOrgAndDest(false); arrow.arrangePoints(_anchoring); if (_layoutLink != null) _layoutLink(arrow); } } chart.Invalidate(); chart.UndoManager.onEndLayout(); return true; }
/// <summary> /// Performs the arrangement. /// </summary> public virtual bool Arrange(FlowChart chart) { if (_ignoreArrowDirection && _root == null) return false; chart.UndoManager.onStartLayout("Tree layout"); // Build the graph FCGraph graph = null; if (_reversedArrows) { graph = new ReversedFCGraph(chart, _keepGroupLayout, _ignoreArrowDirection); } else { graph = new FCGraph(chart, _keepGroupLayout, _ignoreArrowDirection); } // Get the root node within the graph Layout.INode rootNode = null; if (_root != null) { foreach (FCNode node in graph.Nodes) { if (node.Node == _root) { rootNode = node; break; } } } CalculateAnchors(); // Split graph to subgraphs Layout.IGraph[] subgraphs = Layout.GraphSplitter.Split(graph, new FCGraphBuilder(chart, _reversedArrows)); float xOffset = this.XGap; foreach (FCGraph subgraph in subgraphs) { Layout.INode theRoot = null; if (subgraph.Nodes.Contains(rootNode)) { // The root node of the user is within this // subgraph - respect the user's wishes theRoot = rootNode; } else { // If the user specified a root node, // arrange only the graph, containing // that node if (rootNode != null) continue; // If the subgraph has root node, use it, // otherwise select the first node as root Layout.INode subRoot = subgraph.Root; if (subRoot == null) theRoot = subgraph.Nodes[0]; else theRoot = subRoot; } // Check if the root is layoutable if ((theRoot as FCNode).Node.Frozen) continue; Layout.LayoutProgress progress = null; if (_progress != null) progress = new Layout.LayoutProgress( this.OnLayoutProgress); Layout.TreeLayoutInfo info = new Layout.TreeLayoutInfo(); info.Direction = (Layout.TreeLayoutDirection)this.Direction; info.KeepRootPosition = this.KeepRootPosition; info.LevelDistance = this.LevelDistance; info.NodeDistance = this.NodeDistance; info.StretchFactor = this.StretchFactor; info.XGap = this.XGap; info.YGap = this.YGap; if (_layoutNode != null) { // remember the old positions foreach (FCNode node in subgraph.Nodes) node.Node.setData(Constants.OLD_BOUNDS, node.Node.BoundingRect); } // Arrange the subgraph switch (_type) { case TreeLayoutType.Cascading: new Layout.BorderTreeLayout().Arrange( theRoot, info, progress); break; case TreeLayoutType.Centered: new Layout.CenterTreeLayout().Arrange( theRoot, info, progress); break; case TreeLayoutType.Radial: new Layout.RadialTreeLayout().Arrange( theRoot, info, progress); break; } // If the root is not at fixed position, translate the whole tree if (!this.KeepRootPosition) { RectangleF graphBounds = subgraph.GetBounds(false); float xToMove = xOffset - graphBounds.X; float yToMove = this.YGap - graphBounds.Y; foreach (FCNode node in subgraph.Nodes) { RectangleF nodeBounds = node.Bounds; nodeBounds.X += xToMove; nodeBounds.Y += yToMove; node.Bounds = nodeBounds; } xOffset += graphBounds.Width + this.XGap; } if (_layoutNode != null) { // raise the LayoutNode event for each node foreach (FCNode node in subgraph.Nodes) _layoutNode(node.Node, (RectangleF)node.Node.getData(Constants.OLD_BOUNDS)); chart.clearRuntimeData(Constants.OLD_BOUNDS); } // Update the arrows in this particular subgraph ArrayList visitedLinks = new ArrayList(); ArrayList nodes = new ArrayList(); nodes.Add(theRoot); while (nodes.Count > 0) { FCNode node = nodes[0] as FCNode; nodes.RemoveAt(0); if (node.Node.Frozen) continue; foreach (FCLink link in node.OutLinks) { if (!visitedLinks.Contains(link)) { visitedLinks.Add(link); if (!link.Arrow.IgnoreLayout) { if (link.Destination == node) { UpdateArrow(link.Arrow, true); nodes.Add(link.Origin); } else { UpdateArrow(link.Arrow, false); nodes.Add(link.Destination); } if (_layoutLink != null) _layoutLink(link.Arrow); } } } } } chart.Invalidate(); chart.UndoManager.onEndLayout(); return true; }
internal TableRelationsBehavior(FlowChart fc) : base(fc) {}
public virtual bool Arrange(FlowChart chart) { chart.UndoManager.onStartLayout("Layered layout"); // Disable undo to prevent unneeded actions. // For example: RouteAllArrows is invoked each time // when a new dummy box is created, which is a very // expensive operation even with no AutoRoute arrows present. bool undo = chart.UndoManager.UndoEnabled; chart.UndoManager.enable(false); // Build the graph FCGraph graph = new FCGraph(chart, _keepGroupLayout); // Find the root adapter Layout.INode rootNode = null; if (_root != null) { foreach (FCNode node in graph.Nodes) { if (node.Node == _root) { rootNode = node; break; } } } // Split graph to subgraphs Layout.IGraph[] subgraphs = Layout.GraphSplitter.Split( graph, new FCGraphBuilder(chart, false)); // Make sure all arrows are polylines with 1 segment. // Arrows' AutoRoute flag is also undesired. // Note: Process only the arrows belonging to // the subgraph, which contains the specified root (if any) if (rootNode == null) { foreach (Arrow arrow in chart.Arrows) { if (arrow.isReflexive()) continue; arrow.AutoRoute = false; arrow.Style = MindFusion.FlowChartX.ArrowStyle.Polyline; arrow.SegmentCount = 1; } } else { foreach (FCGraph subgraph in subgraphs) { if (subgraph.Nodes.Contains(rootNode)) { foreach (FCLink link in subgraph.Links) { Arrow arrow = link.Arrow; if (arrow.isReflexive()) continue; arrow.AutoRoute = false; arrow.Style = MindFusion.FlowChartX.ArrowStyle.Polyline; arrow.SegmentCount = 1; } break; } } } // Create the layouter Layout.LayeredLayout layout = new Layout.LayeredLayout(); Layout.LayoutProgress progress = null; if (_progress != null) progress = new Layout.LayoutProgress(this.OnLayoutProgress); Layout.LayeredLayoutInfo info = new Layout.LayeredLayoutInfo(); info.ArrowsCompactFactor = this.ArrowsCompactFactor; info.Direction = (Layout.Direction)this.Direction; info.LayerDistance = this.LayerDistance; info.NodeDistance = this.NodeDistance; info.Orientation = (Layout.Orientation)this.Orientation; info.SplitLayers = this.SplitLayers; info.XGap = this.XGap; info.YGap = this.YGap; info.TimeLimit = this.TimeLimit; float xOffset = this.XGap; foreach (FCGraph subgraph in subgraphs) { // If a root node is specified and the subgraph // does not contain that node, do not arrange // the subgraph if (rootNode != null) { if (!subgraph.Nodes.Contains(rootNode)) continue; } layout.Arrange(subgraph, info, progress); // Translate the whole subgraph RectangleF graphBounds = subgraph.GetBounds(true); float xToMove = xOffset - graphBounds.X; float yToMove = this.YGap - graphBounds.Y; foreach (FCNode node in subgraph.Nodes) { RectangleF nodeBounds = node.Bounds; RectangleF oldBounds = node.Node.BoundingRect; nodeBounds.X += xToMove; nodeBounds.Y += yToMove; node.Bounds = nodeBounds; if (_layoutNode != null) _layoutNode(node.Node, oldBounds); } // Update arrows' inner points; the end points // must have already been offset by the loop above foreach (FCLink link in subgraph.Links) { // Arrows that retain form need not be updated if (link.Arrow.RetainForm) continue; for (int i = 1; i < link.Arrow.Points.Count - 1; i++) { PointF pt = link.Arrow.Points[i]; pt.X += xToMove; pt.Y += yToMove; link.Arrow.Points[i] = pt; } } xOffset += graphBounds.Width + this.XGap; // Update arrows foreach (FCLink link in subgraph.Links) { Arrow arrow = link.Arrow; if (arrow.IgnoreLayout) continue; // Update end points if (arrow.SegmentCount == 1) { arrow.arrangePoints(_anchoring); } else { int orgnAnchor = arrow.OrgnAnchor; int destAnchor = arrow.DestAnchor; arrow.Points[0] = arrow.getOrgnLink().getIntersection( arrow.Origin.getCenter(), arrow.Points[1]); arrow.Points[arrow.Points.Count - 1] = arrow.getDestLink().getIntersection( arrow.Points[arrow.Points.Count - 2], arrow.Destination.getCenter()); switch (_anchoring) { case Anchoring.Ignore: // Do nothing break; case Anchoring.Keep: if (orgnAnchor >= 0) { arrow.OrgnAnchor = -1; arrow.OrgnAnchor = orgnAnchor; } if (destAnchor >= 0) { arrow.DestAnchor = -1; arrow.DestAnchor = destAnchor; } break; case Anchoring.Reassign: arrow.Points[0] = arrow.Origin.getNearestAnchor( arrow.Points[0], arrow, false, ref orgnAnchor); arrow.Points[arrow.Points.Count - 1] = arrow.Destination.getNearestAnchor( arrow.Points[arrow.Points.Count - 1], arrow, true, ref destAnchor); arrow.setOrgnAnchor(orgnAnchor); arrow.setDestAnchor(destAnchor); break; } } arrow.UpdateFromPoints(); if (_layoutLink != null) _layoutLink(arrow); } } chart.Invalidate(); chart.UndoManager.enable(undo); chart.UndoManager.onEndLayout(); return true; }
internal NodeLinkBehavior(FlowChart fc) : base(fc) {}
public CompositeCmd(FlowChart flowChart, string title) : this(flowChart, title, false) { }
public CommandContext(FlowChart document) { this.document = document; }
public FCGraphBuilder(FlowChart chart, bool reversedArrows) { _chart = chart; _reversedArrows = reversedArrows; }
public ReversedFCGraph(FlowChart chart, bool keepGroups, bool ignoreArrowDirection) : base(chart, keepGroups, ignoreArrowDirection) { }
internal ControlHostBehavior(FlowChart fc) : base(fc) {}
public virtual bool Arrange(FlowChart chart) { chart.UndoManager.onStartLayout("Spring layout"); // Build the graph FCGraph graph = new FCGraph(chart, _keepGroupLayout); // Find the root adapter Layout.INode rootNode = null; if (_root != null) { foreach (FCNode node in graph.Nodes) { if (node.Node == _root) { rootNode = node; break; } } } // Split graph to subgraphs Layout.IGraph[] subgraphs = Layout.GraphSplitter.Split( graph, new FCGraphBuilder(chart, false)); // Create the layouter Layout.SpringLayout layout = new Layout.SpringLayout(); layout.Stretch = _stretch; Layout.LayoutProgress progress = null; if (_progress != null) progress = new Layout.LayoutProgress(this.OnLayoutProgress); Layout.SpringLayoutInfo info = new Layout.SpringLayoutInfo(); info.IterationCount = this.IterationCount; info.MinimizeCrossings = this.MinimizeCrossings; info.NodeDistance = this.NodeDistance; info.EnableClusters = this.EnableClusters; info.RepulsionFactor = this.RepulsionFactor; info.RndSeed = this.RndSeed; float xOffset = 0; foreach (FCGraph subgraph in subgraphs) { // If a root node is specified and the subgraph // does not contain that node, do not arrange // the subgraph if (rootNode != null) { if (!subgraph.Nodes.Contains(rootNode)) continue; } layout.Arrange(subgraph, info, progress); // Translate the whole subgraph RectangleF graphBounds = subgraph.GetBounds(false); float xToMove = xOffset - graphBounds.X; float yToMove = -graphBounds.Y; foreach (FCNode node in subgraph.Nodes) { RectangleF nodeBounds = node.Bounds; RectangleF oldBounds = node.Node.BoundingRect; nodeBounds.X += xToMove; nodeBounds.Y += yToMove; node.Bounds = nodeBounds; if (_layoutNode != null) _layoutNode(node.Node, oldBounds); } xOffset += graphBounds.Width + this.NodeDistance; // Update arrows foreach (FCLink link in subgraph.Links) { Arrow arrow = link.Arrow; if (arrow.IgnoreLayout) continue; // If the arrow being arranged is dynamic, // ignore the anchoring flag? if (arrow.Dynamic) arrow.updatePosFromOrgAndDest(false); arrow.arrangePoints(_anchoring); if (_layoutLink != null) _layoutLink(arrow); } } chart.Invalidate(); chart.UndoManager.onEndLayout(); return true; }
private void SerializeTextFormat(CodeStatementCollection code, string property, FlowChart chart, System.Drawing.StringFormat format) { // this.<fc>.<property> = CodeExpression left = null; CodeExpression right = null; CodeStatement line = null; string temp = ""; left = new CodePropertyReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), chart.Name), property); right = new CodeObjectCreateExpression( typeof(System.Drawing.StringFormat), new CodeExpression[] {}); line = new CodeAssignStatement(left, right); code.Add(line); switch (format.Alignment) { case System.Drawing.StringAlignment.Near: temp = "Near"; break; case System.Drawing.StringAlignment.Center: temp = "Center"; break; case System.Drawing.StringAlignment.Far: temp = "Far"; break; } left = new CodePropertyReferenceExpression( new CodePropertyReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), chart.Name), property), "Alignment"); right = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression("System.Drawing.StringAlignment"), temp); line = new CodeAssignStatement(left, right); code.Add(line); switch (format.LineAlignment) { case System.Drawing.StringAlignment.Near: temp = "Near"; break; case System.Drawing.StringAlignment.Center: temp = "Center"; break; case System.Drawing.StringAlignment.Far: temp = "Far"; break; } left = new CodePropertyReferenceExpression( new CodePropertyReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), chart.Name), property), "LineAlignment"); right = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression("System.Drawing.StringAlignment"), temp); line = new CodeAssignStatement(left, right); code.Add(line); }
internal CreateBoxBehavior(FlowChart fc) : base(fc) {}
internal CreateArrowBehavior(FlowChart fc) : base(fc) {}
public Behavior(FlowChart flowChart) { this.fc = flowChart; this.currentCursor = fc.CurModify; }
internal CreateTableBehavior(FlowChart fc) : base(fc) {}
public ReversedFCGraph(FlowChart chart) : base(chart) { }
internal FlowChartBehavior(FlowChart fc) : base(fc) {}