Represents an item in a graph.
Inheritance: INotifyPropertyChanged
Esempio n. 1
0
        static Point ComputeLocation(Node node1, Node node2)
        {
            // Initially set the location to the center of the first node.
            Point loc = new Point
            {
                X = node1.LocationX + node1.NodeWidth / 2,
                Y = node1.LocationY + node1.NodeHeight / 2
            };

            bool overlapY = Math.Abs(node1.LocationY - node2.LocationY) < node1.NodeHeight;
            if(!overlapY)
            {
                bool above = node1.LocationY < node2.LocationY;
                if(above)
                    loc.Y += node1.NodeHeight / 2;
                else
                    loc.Y -= node1.NodeHeight / 2;
            }

            bool overlapX = Math.Abs(node1.LocationX - node2.LocationX) < node1.NodeWidth;
            if(!overlapX)
            {
                bool left = node1.LocationX < node2.LocationX;
                if(left)
                    loc.X += node1.NodeWidth / 2;
                else
                    loc.X -= node1.NodeWidth / 2;
            }

            return loc;
        }
        void AddConnector(Node startNode, Node endNode)
        {
            var connector = new NodeConnector(startNode, endNode);

            _nodeConnectors.Add(connector);

            // Add the connector to the visual and logical tree so that
            // rendering and resource inheritance will work properly.
            AddVisualChild(connector);
            AddLogicalChild(connector);

        }
Esempio n. 3
0
        public NodeConnector(Node startNode, Node endNode)
        {
            _startNode = startNode;
            _endNode = endNode;

            SetIsPartOfCircularDependency();
            SetToolTip();
            UpdateLocations(false);

            startNode.PropertyChanged += StartNodePropertyChanged;
            endNode.PropertyChanged += EndNodePropertyChanged;
        }
Esempio n. 4
0
        public void Node_ToString_WhenNotBroken_ExpectStringNode()
        {
            //------------Setup for test--------------------------
            var node = new Node("Node 1", 100, 100, false, false);
            const string expected = @"<node id=""Node 1"" x=""100"" y=""100"" broken=""False""></node>";

            //------------Execute Test---------------------------
            var result = node.ToString();

            //------------Assert Results-------------------------
            StringAssert.Contains(result, expected);
        }
Esempio n. 5
0
        public void Node_ToString_WhenNodeContainsDependencies_ExpectStringNodeWithDependenices()
        {
            //------------Setup for test--------------------------
            var node = new Node("Node 1", 100, 100, true, true);
            node.NodeDependencies.Add(new Node("Dependant Node",200,100,false,false));
            const string expected = @"<node id=""Node 1"" x=""100"" y=""100"" broken=""True""><dependency id=""Dependant Node"" /></node>";

            //------------Execute Test---------------------------
            var result = node.ToString();

            //------------Assert Results-------------------------
            StringAssert.Contains(result, expected);
        }
Esempio n. 6
0
 public NodeInfo(Node node)
 {
     Node = node;
     _index = 0;
 }