private TreeNode FindTreeNode(PlaneStructure structure) { //polygons foreach (GeometricNode node in treeView.Nodes) { if (node.Structure == structure) { return(node); } //edges foreach (GeometricNode edgeNode in node.Nodes[0].Nodes) { if (edgeNode.Structure == structure) { return(edgeNode); } } //vertices foreach (GeometricNode vertexNode in node.Nodes[1].Nodes) { if (vertexNode.Structure == structure) { return(vertexNode); } } } return(null); }
public void DeleteStructure(PlaneStructure structure) { if (structure is Polygon) { polygons.Remove(structure as Polygon); return; } var polygon = structure.UnderlyingPolygon; if (polygon == null) { return; } if (structure is Edge) { polygon.DeleteEdge(structure as Edge); } else if (structure is Vertex) { polygon.DeleteVertex(structure as Vertex); } if (polygon.GetEdges().Count <= 2) { DeleteStructure(polygon); } }
private void ItemSelected(object sender, TreeViewEventArgs e) { //close currently drawn polygon polygonManager.HandleMouseDown(); var node = e.Node as GeometricNode; if (node.Type == NodeType.EdgesList || node.Type == NodeType.VerticesList) { structureSelected = null; return; } StructureSelected(node.Structure); }
private void StructureSelected(PlaneStructure structure) { polygonManager.ClearDrawColor(Color.Black); structureSelected = structure; if (structure != null) { structure.DrawingColor = Color.Red; } else { treeView.SelectedNode = null; } polygonManager.UpdateSelectedStructure(structureSelected); }
public void InitPolygonAdd() { if (mouseState == MouseState.Drawing && currentStructure is Polygon) { TryClosePolygon(currentStructure as Polygon); } if (mouseState != MouseState.Normal) { return; } mouseState = MouseState.Drawing; var polygon = new Polygon(); currentStructure = polygon; polygons.Add(polygon); Update(); OnStructureChanged?.Invoke(this, polygon); }
public GeometricNode(String name, NodeType type, PlaneStructure structure) : base(name) { Structure = structure; Type = type; }
public void UpdateSelectedStructure(PlaneStructure structure) { currentStructure = structure; Update(); }