Example #1
0
        private GeometricNode CreatePolygonNode(Polygon polygon, int i)
        {
            var polygonNode = new GeometricNode($"Polygon{i}", NodeType.Polygon, polygon);

            var edgesNode    = new GeometricNode("Edges", NodeType.EdgesList, null);
            var verticesNode = new GeometricNode("Vertices", NodeType.VerticesList, null);

            var edges = polygon.GetEdges();

            for (int j = 0; j < edges.Count; j++)
            {
                edgesNode.Nodes.Add(new GeometricNode("", NodeType.Edge, edges[j]));
            }

            UpdateEdgesLabels(edgesNode.Nodes);

            var vertices = polygon.GetVertices();

            for (int j = 0; j < vertices.Count; j++)
            {
                verticesNode.Nodes.Add(new GeometricNode($"Vertex{j}", NodeType.Vertex, vertices[j]));
            }

            polygonNode.Nodes.Add(edgesNode);
            polygonNode.Nodes.Add(verticesNode);

            return(polygonNode);
        }
Example #2
0
        private void UpdateNode(GeometricNode node, Polygon polygon, int i)
        {
            if (!node.Structure.Equals(polygon))
            {
                node = CreatePolygonNode(polygon, i);
                return;
            }

            UpdateEdges(node.Nodes[0].Nodes, polygon.GetEdges());
            UpdateVertices(node.Nodes[1].Nodes, polygon.GetVertices());
        }
Example #3
0
        private ContextMenuStrip CreateContextMenu(GeometricNode node)
        {
            var contextMenu = new ContextMenuStrip();

            if (node != null)
            {
                if (node.Type == NodeType.Edge)
                {
                    var split = contextMenu.Items.Add("Split");
                    split.Click += SplitClick;

                    var edge = node.Structure as Edge;
                    if (edge.RelationType != EdgeRelation.None)
                    {
                        var removeRelation = contextMenu.Items.Add("Remove relation");
                        removeRelation.Click += RemoveRelationClick;
                    }

                    if (relationCreator.CanAddEdge(edge))
                    {
                        var addToCreator = contextMenu.Items.Add("Add to relation creator");
                        addToCreator.Click += AddToCreator;
                    }
                }

                if (node.Type == NodeType.Edge || node.Type == NodeType.Vertex || node.Type == NodeType.Polygon)
                {
                    var remove = contextMenu.Items.Add("Remove");
                    remove.Click += RemoveClick;
                }

                if (node.Type != NodeType.EdgesList && node.Type != NodeType.VerticesList)
                {
                    contextMenu.Items.Add("-");
                }
            }

            var addPolygon = contextMenu.Items.Add("Add polygon");

            addPolygon.Click += AddPolygonContextMenu;

            var addSamplePolygon = contextMenu.Items.Add("Add sample polygon");

            addSamplePolygon.Click += AddSamplePolygonContextMenu;

            return(contextMenu);
        }