void factory_DirtyChanged(object sender, EventArgs e) { BaseNodeConfig config = sender as BaseNodeConfig; ILinkedNodeConfig linkedConfig = config as ILinkedNodeConfig; if (linkedConfig != null) { if (linkedConfig.LinkedNode == null) { GraphNode n = netEditor.GetNodeByTag(linkedConfig); netEditor.RemoveLinkLine(n); } else { GraphNode src = netEditor.GetNodeByTag(linkedConfig); GraphNode dest = netEditor.GetNodeByTag(linkedConfig.LinkedNode); netEditor.RemoveLinkLine(src); netEditor.RemoveLinkLine(dest); AddLinkLine(src, dest); } netEditor.Invalidate(); } netEditor.Dirty = true; }
private void PopulateGraphFromDocument(bool centre) { Dictionary <Guid, GraphNode> idToNode = new Dictionary <Guid, GraphNode>(); List <GraphNode> linkedNodes = new List <GraphNode>(); _populatingControl = true; netEditor.SuspendLayout(); netEditor.ClearGraph(); netEditor.DocumentWidth = NetGraphDocument.DEFAULT_DOCUMENT_WIDTH; netEditor.DocumentHeight = NetGraphDocument.DEFAULT_DOCUMENT_HEIGHT; foreach (var n in _document.Nodes) { idToNode[n.Id] = AddNode(n, new PointF(n.X, n.Y), n.Z); ILinkedNodeConfig linkedConfig = n as ILinkedNodeConfig; if ((linkedConfig != null) && (linkedConfig.LinkedNode != null)) { linkedNodes.Add(idToNode[n.Id]); } } foreach (GraphNode n in linkedNodes) { ILinkedNodeConfig config = n.Tag as ILinkedNodeConfig; if (idToNode.ContainsKey(config.LinkedNode.Id)) { AddLinkLine(n, idToNode[config.LinkedNode.Id]); } } foreach (LineConfig l in _document.Lines) { if ((idToNode.ContainsKey(l.SourceNode.Id) && (idToNode.ContainsKey(l.DestNode.Id)))) { GraphLine newLine = netEditor.AddLine(idToNode[l.SourceNode.Id], idToNode[l.DestNode.Id]); newLine.BiDirection = l.BiDirection; newLine.Label = l.PathName; newLine.Tag = l.WeakPath; newLine.LineDashStyle = l.WeakPath ? DashStyle.Dot : DashStyle.Solid; } } netEditor.SelectedObject = null; if (centre) { netEditor.CenterViewOfGraph(); } netEditor.ResumeLayout(); _populatingControl = false; }
/// <summary> /// /// </summary> protected virtual void RebuildFactory() { List <NetGraphFactory.GraphNodeEntry> graphNodes = new List <NetGraphFactory.GraphNodeEntry>(); List <NetGraphFactory.GraphLineEntry> graphLines = new List <NetGraphFactory.GraphLineEntry>(); HashSet <Guid> createdNodes = new HashSet <Guid>(); if (_factory == null) { _factory = new NetGraphFactory(); } if (_nodes != null) { foreach (BaseNodeConfig node in _nodes) { if (!createdNodes.Contains(node.Id)) { BaseNodeFactory factory = node.CreateFactory(); ILinkedNodeConfig linkedConfig = node as ILinkedNodeConfig; if ((linkedConfig != null) && (linkedConfig.LinkedNode != null)) { BaseNodeFactory linked = linkedConfig.CreateFactory(factory); createdNodes.Add(linkedConfig.LinkedNode.Id); graphNodes.Add(new NetGraphFactory.GraphNodeEntry(linked)); } graphNodes.Add(new NetGraphFactory.GraphNodeEntry(factory)); createdNodes.Add(node.Id); } } } if (_lines != null) { foreach (LineConfig line in _lines) { graphLines.Add(new NetGraphFactory.GraphLineEntry(line.SourceNode.Id, line.DestNode.Id, line.BiDirection, line.PathName, line.WeakPath)); } } _factory.Nodes = graphNodes.ToArray(); _factory.Lines = graphLines.ToArray(); foreach (KeyValuePair <string, string> pair in _properties) { _factory.Properties.Add(pair.Key, pair.Value); } }
private void PopulateGraphFromDocument() { Dictionary <Guid, GraphNode> idToNode = new Dictionary <Guid, GraphNode>(); List <GraphNode> linkedNodes = new List <GraphNode>(); netEditor.SuspendLayout(); netEditor.ClearGraph(); foreach (var n in _document.Nodes) { idToNode[n.Id] = AddNode(n, new PointF(n.X, n.Y), n.Z); ILinkedNodeConfig linkedConfig = n as ILinkedNodeConfig; if ((linkedConfig != null) && (linkedConfig.LinkedNode != null)) { linkedNodes.Add(idToNode[n.Id]); } } foreach (GraphNode n in linkedNodes) { ILinkedNodeConfig config = n.Tag as ILinkedNodeConfig; if (idToNode.ContainsKey(config.LinkedNode.Id)) { AddLinkLine(n, idToNode[config.LinkedNode.Id]); } } foreach (LineConfig l in _document.Lines) { if ((idToNode.ContainsKey(l.SourceNode.Id) && (idToNode.ContainsKey(l.DestNode.Id)))) { GraphLine newLine = netEditor.AddLine(idToNode[l.SourceNode.Id], idToNode[l.DestNode.Id]); newLine.BiDirection = l.BiDirection; newLine.Label = l.PathName; newLine.Tag = l.WeakPath; newLine.LineDashStyle = l.WeakPath ? DashStyle.Dot : DashStyle.Solid; } } netEditor.SelectedObject = null; netEditor.ResumeLayout(); }