Esempio n. 1
0
        /// <summary>
        /// Add an edge with a label
        /// </summary>
        /// <param name="label">The label to add</param>
        /// <param name="destNode">The destination node</param>
        /// <returns>The edge configuration</returns>
        public LineConfig AddEdge(string label, BaseNodeConfig destNode)
        {
            LineConfig edge = AddEdge(destNode);

            edge.Label = label;

            return(edge);
        }
Esempio n. 2
0
        /// <summary>
        /// Update the graph factory from list of nodes and lines
        /// </summary>
        /// <param name="nodes">The list of nodes</param>
        /// <param name="lines">The list of lines</param>
        public void UpdateGraph(BaseNodeConfig[] nodes, LineConfig[] lines)
        {
            lock (_lockObject)
            {
                _nodes = (BaseNodeConfig[])nodes.Clone();
                _lines = (LineConfig[])lines.Clone();

                foreach (BaseNodeConfig node in _nodes)
                {
                    node.Document = this;
                }

                RebuildFactory();
            }

            Dirty = true;
        }
Esempio n. 3
0
        private void PopulateDocumentFromGraph()
        {
            List<BaseNodeConfig> nodes = new List<BaseNodeConfig>();
            List<LineConfig> lines = new List<LineConfig>();
            GraphData graph = netEditor.Graph;

            foreach (var n in graph.Nodes)
            {
                BaseNodeConfig node = (BaseNodeConfig)n.Tag;
                node.X = n.Center.X;
                node.Y = n.Center.Y;
                node.Z = n.Z;

                nodes.Add(node);
            }

            foreach (var l in graph.Lines)
            {
                bool isWeak = false;
                if (l.Tag != null)
                {
                    isWeak = (bool)l.Tag;
                }
                LineConfig line = new LineConfig((BaseNodeConfig)l.SourceShape.Tag,
                    (BaseNodeConfig)l.DestShape.Tag, l.BiDirection, l.Label, isWeak);

                lines.Add(line);
            }

            _document.UpdateGraph(nodes.ToArray(), lines.ToArray());
        }