public graphNodeCS(node_view parentView) { InitializeComponent(); this.parentView = parentView; Canvas.SetZIndex(this, 2); this.point.Width = this.point.Height = NodeRadius; opaqueBrush = new SolidColorBrush(Colors.Black); opaqueBrush.Opacity = 0; }
public bool CheckTopNum(node_view top) { foreach (node_view model in TopList) { if (top.TopNum == model.TopNum && model != top) { return(false); } } return(true); }
public void AddTop(bool center) { node_view top = new node_view(this); if (center) { top.CNTRPosition(); } else { OnPointPositionChanged(top); } }
public edge_view(graph_viewCS _graph, node_view from_node, node_view to_node) { this._graph = _graph; if (from_node != to_node) { isLine = true; } else { isLine = false; } if (isLine) { Line = new Line(); } else { Line = new Ellipse(); } Line.MouseLeftButtonDown += new MouseButtonEventHandler(Line_MouseLeftButtonDown); Line.Stroke = Brushes.Black; Line.StrokeThickness = 1; if (isLine) { ((Line)Line).X1 = 0; ((Line)Line).Y1 = 0; } else { ((Ellipse)Line).Width = 50; ((Ellipse)Line).Height = 50; } if (Lines == null) { Lines = new List <Shape>(); Lines.Add(Line); } _graph.GRCanvas.Children.Add(Line); Canvas.SetZIndex(Line, 0); this.from_node = from_node; this.to_node = to_node; to_node.pointPositionChange += new graph_viewCS.PointPositionChanged(OnPointPositionChanged); from_node.pointPositionChange += new graph_viewCS.PointPositionChanged(OnPointPositionChanged); OnPointPositionChanged(to_node); if (isLine) { OnPointPositionChanged(from_node); } }
public void DeleteNode(node_view top) { if (TopList.Contains(top)) { for (int i = edgeList.Count - 1; i >= 0; i--) { if (edgeList[i].From == top || edgeList[i].To == top) { DeleteEdge(edgeList[i]); } } TopList.Remove(top); canvas.Children.Remove(top.View); } }
public void OnPointPositionChanged(node_view top) { if (isLine) { if (top == from_node) { Canvas.SetLeft(Line, from_node.RELPos.X + from_node.GRNode.Width / 2); Canvas.SetTop(Line, from_node.RELPos.Y + graphNode.Radius / 2); } ((Line)Line).X2 = to_node.RELPos.X - from_node.RELPos.X; ((Line)Line).Y2 = to_node.RELPos.Y - from_node.RELPos.Y; } else { Canvas.SetLeft(Line, from_node.RELPos.X); Canvas.SetTop(Line, from_node.RELPos.Y - 35); } }
public void AddEdge(node_view from_node, node_view to_node) { bool isExist = false; foreach (edge_view line0 in edgeList) { if ((line0.From == from_node && line0.To == to_node) || (line0.To == from_node && line0.From == to_node)) { MessageBox.Show("Дуга вже існує"); isExist = true; } } if (!isExist) { edge_view line = new edge_view(this, from_node, to_node); edgeList.Add(line); FirstTop = null; EndAddEdge(); } }
public edge_view(graph_viewCS _graph, node_view from_node, node_view to_node) { this._graph = _graph; if (from_node != to_node) isLine = true; else isLine = false; if (isLine) Line = new Line(); else Line = new Ellipse(); Line.MouseLeftButtonDown += new MouseButtonEventHandler(Line_MouseLeftButtonDown); Line.Stroke = Brushes.Black; Line.StrokeThickness = 1; if (isLine) { ((Line)Line).X1 = 0; ((Line)Line).Y1 = 0; } else { ((Ellipse)Line).Width = 50; ((Ellipse)Line).Height = 50; } if (Lines == null) { Lines = new List<Shape>(); Lines.Add(Line); } _graph.GRCanvas.Children.Add(Line); Canvas.SetZIndex(Line, 0); this.from_node = from_node; this.to_node = to_node; to_node.pointPositionChange += new graph_viewCS.PointPositionChanged(OnPointPositionChanged); from_node.pointPositionChange += new graph_viewCS.PointPositionChanged(OnPointPositionChanged); OnPointPositionChanged(to_node); if (isLine) OnPointPositionChanged(from_node); }
public void OnPointPositionChanged(node_view top) { top.UpdPos(); Canvas.SetLeft(top.GRNode, top.RELPos.X); Canvas.SetTop(top.GRNode, top.RELPos.Y); }
public void AddTop(double X, double Y, string id) { node_view top = new node_view(this); top.GivenPosition(X, Y, id); }
public void EndAddEdge() { edgeAdd = false; FirstTop = null; }