Exemple #1
0
        private void loadButton_Click(object sender, RoutedEventArgs e)
        {
            RestartCanvas(_mainCanvas);
            List <NodeWithVisuals> nodes = new ServiceAccessLayer().GetNodes();
            var layoutAlgorythm          = new LayoutAlgorythms();

            _nodesWithVisuals = layoutAlgorythm.CreateGridlikeLayout(nodes, _mainCanvas);
            new NodesEventHandler(_nodesSelected, _nodesWithVisuals).CreateEventHandlers(_mainCanvas);
            new NodesVisualHelper().CreateConnectingLines(_nodesWithVisuals, _mainCanvas);
        }
Exemple #2
0
        public void CreateGridlikeLayout_InputNodes_NodesInRightCoordinates()
        {
            var layoutAlgorythms = new LayoutAlgorythms();
            var firstNode        = new NodeWithVisuals()
            {
                id = 1, adjacentNodes = new byte[1] {
                    2
                }
            };
            var secondNode = new NodeWithVisuals()
            {
                id = 2, adjacentNodes = new byte[1] {
                    3
                }
            };
            var thirdNode = new NodeWithVisuals()
            {
                id = 3, adjacentNodes = new byte[2] {
                    1, 2
                }
            };
            var nodesList = new List <NodeWithVisuals> {
                firstNode, secondNode, thirdNode
            };

            var nodesWithCoordinates = layoutAlgorythms.CreateGridlikeLayout(nodesList, new Canvas());
            var first = nodesWithCoordinates[firstNode.id];

            Assert.AreEqual(first.X, 0);
            Assert.AreEqual(first.Y, 0);

            var second = nodesWithCoordinates[secondNode.id];

            Assert.AreEqual(second.X, 90);
            Assert.AreEqual(second.Y, 0);

            var third = nodesWithCoordinates[thirdNode.id];

            Assert.AreEqual(third.X, 90);
            Assert.AreEqual(third.Y, 90);
        }