/// <summary> /// Constructor /// </summary> /// <param name="node">The node which was deleted</param> internal NodeDeletedEventArgs(GraphNode node) { Node = node; }
private void MoveNodeToBottom(GraphNode node) { _nodes.Remove(node); _nodes.Insert(0, node); }
private void MoveNodeToTop(GraphNode node) { _nodes.Remove(node); _nodes.Add(node); }
/// <summary> /// Overridable method to handle deletion of nodes /// </summary> /// <param name="node"></param> protected virtual void OnNodeDeleted(GraphNode node) { if (NodeDeleted != null) { NodeDeleted(this, new NodeDeletedEventArgs(node)); } }
private GraphLine AddNewLine(GraphNode sourceShape, GraphNode destShape, bool biDirection, string label) { GraphLine l = new GraphLine(); l.SourceShape = sourceShape; l.DestShape = destShape; l.LineColor = Color.Black; l.BiDirection = biDirection; l.Label = label; _lines.Add(l); return l; }
/// <summary> /// Delete a node from the graph /// </summary> /// <remarks>Will also deletes any lines attached to the node</remarks> /// <param name="node">The node to delete</param> public void DeleteNode(GraphNode node) { _lines.RemoveAll(l => ((l.SourceShape == node) || (l.DestShape == node))); _linkLines.RemoveAll(l => ((l.SourceShape == node) || (l.DestShape == node))); _nodes.Remove(node); if (_selectedObject == node) { SelectedObject = null; } OnNodeDeleted(node); Dirty = true; Invalidate(); }
/// <summary> /// Remove a link line which attaches to this node /// </summary> /// <param name="sourceShape">The node</param> public void RemoveLinkLine(GraphNode node) { _linkLines.RemoveAll(l => ((l.SourceShape == node) || (l.DestShape == node))); }
/// <summary> /// Add an annotation link line /// </summary> /// <param name="sourceShape">The source shape</param> /// <param name="destShape">The destination shape</param> /// <param name="lineColor">The line color</param> /// <param name="lineDashStyle">The line dash style</param> /// <param name="invalidate">Whether to invalid the control or not</param> public void AddLinkLine(GraphNode sourceShape, GraphNode destShape, Color lineColor, DashStyle lineDashStyle, bool invalidate) { if ((destShape != null) && (sourceShape != null)) { if (_linkLines.FindIndex(l => l.Matches(sourceShape, destShape)) < 0) { _linkLines.Add(new GraphLinkLine() { DestShape = destShape, SourceShape = sourceShape, LineColor = lineColor, LineDashStyle = lineDashStyle }); if (invalidate) { Invalidate(); } } } }
/// <summary> /// Add a new line to the graph between two nodes /// </summary> /// <remarks>If line already exists and direction matches will return the same line</remarks> /// <param name="source">The source node</param> /// <param name="dest">The destination node</param> /// <param name="biDirection">Indicates the line is bi-directional</param> /// <param name="label">Label for the line, can be null</param> /// <returns>The newly created line</returns> public GraphLine AddLine(GraphNode source, GraphNode dest) { // Check if we have already assigned this line or we have the other way foreach (GraphLine line in _lines) { if ((line.SourceShape == source) && (line.DestShape == dest)) { return line; } if ((line.SourceShape == dest) && (line.DestShape == source)) { if (AllowBidirectionLines) { line.BiDirection = true; Dirty = true; } return line; } } GraphLine l = AddNewLine(source, dest, false, null); Dirty = true; return l; }
internal bool Matches(GraphNode sourceShape, GraphNode destShape) { return ((sourceShape == SourceShape) && (destShape == DestShape)) || ((sourceShape == DestShape) && (destShape == SourceShape)); }
/// <summary> /// Setup the node factory object /// </summary> /// <param name="n">The node to configure</param> private void SetNode(GraphNode n) { BaseNodeConfig config = n.Tag as BaseNodeConfig; if (config != null) { n.Hatched = !config.Enabled; n.Label = config.Label; config.LabelChanged += new EventHandler(factory_LabelChanged); config.DirtyChanged += new EventHandler(factory_DirtyChanged); config.EnabledChanged += new EventHandler(config_EnabledChanged); config.PropertiesChanged += new EventHandler(config_PropertiesChanged); } }
private void AddLinkLine(GraphNode src, GraphNode dest) { netEditor.AddLinkLine(src, dest, Color.Blue, DashStyle.Dash, false); }