public void LineEdgeMouseClick(object sender, MouseButtonEventArgs e) { //StringActionUndo(); Petzold.Media2D.ArrowLine line = new Petzold.Media2D.ArrowLine(); line = (Petzold.Media2D.ArrowLine)sender; if (DeleteingEdgeEnabled) { MainWindow_.InfoCurr.Clear(); RemoveEdge(line); DeleteingEdgeEnabled = false; MyCursors.DefaultCursor(); } if (IsOriented) { foreach (var edge in EdgesList) { if (edge.line == line) { GraphVertex StartV = edge.StartVertex; GraphVertex EndV = edge.EndVertex; ConnectVertex(EndV, StartV); RemoveEdge(line); break; } } } }
//private Line HelpLine = new Line(); //private void DrawHelpLineMouseMove(object sender, MouseEventArgs e) //{ // if (AddEdgeEnabled && VertexesInEdge == 1) // { // HelpLine.X2 = e.GetPosition(zoom).X; // HelpLine.Y2 = e.GetPosition(zoom).Y; // } //} public void DeactivateAll() { IsHolded = false; AddEdgeEnabled = false; VertexesInEdge = 0; DeletingVertexEnable = false; DeleteingEdgeEnabled = false; AStarVertexesEnumerator = 0; DijkstraEnabled = false; AStarEnabled = false; MainWindow_.InfoCurr.Clear(); MyCursors.DefaultCursor(); }
public void VertexLeftButtonUp(object sender, MouseButtonEventArgs e) { Ellipse ell = new Ellipse(); ell = (Ellipse)sender; IsHolded = false; ell.Cursor = Cursors.Arrow; if (DijkstraEnabled) { ShortestPathDijkstra(SearchVertexByEllipse(ell)); MyCursors.DefaultCursor(); } ell.ReleaseMouseCapture(); }
public MainWindow() { InitializeComponent(); InfoCurr.Visibility = System.Windows.Visibility.Hidden; this.KeyDown += new KeyEventHandler(KeyF12Click); WorkSpace.Background = Brushes.Gray; PlainIsCreated = false; IsDirected = false; CommandBindings.Add(new CommandBinding(HotKeys.UndoCommand, Undo_Click)); CommandBindings.Add(new CommandBinding(HotKeys.RedoCommand, Redo_Click)); CommandBindings.Add(new CommandBinding(HotKeys.NewCommand, NewGraph_Click)); CommandBindings.Add(new CommandBinding(HotKeys.SaveCommand, SaveButton_Click)); CommandBindings.Add(new CommandBinding(HotKeys.SaveAsCommand, SaveAs_Click)); CommandBindings.Add(new CommandBinding(HotKeys.OpenCommand, OpenFile_Click)); MyCursors.DefaultCursor(); }
public void EllipseLeftButtonDown(object sender, MouseButtonEventArgs e) { DisableTextBoxFocus(); Ellipse ell = new Ellipse(); ell = (Ellipse)sender; if (DeletingVertexEnable) { MainWindow_.InfoCurr.Clear(); DeleteVertex(ell); DeletingVertexEnable = false; MyCursors.DefaultCursor(); return; } if (AddEdgeEnabled != true) { IsHolded = true; RunUndo(); ell.CaptureMouse(); ell.Cursor = Cursors.Cross; } if (AddEdgeEnabled) { VertexesInEdge++; if (VertexesInEdge == 1) { FirstVertex = ell; FirstVertex.StrokeThickness = 5; FirstVertex.Stroke = Brushes.Red; MainWindow_.InfoCurr.Text = "Добавление ребра. Выберете 2-ую вершину.ESC - отмена"; // //HelpLine.StrokeThickness = 2; //HelpLine.Stroke = Brushes.Gray; //HelpLine.X1 = Canvas.GetLeft(FirstVertex) + FirstVertex.Width / 2; //HelpLine.Y1 = Canvas.GetTop(FirstVertex) + FirstVertex.Height / 2; //HelpLine.X2 = Canvas.GetLeft(FirstVertex) + FirstVertex.Width / 2; //HelpLine.Y2 = Canvas.GetTop(FirstVertex) + FirstVertex.Height / 2; //GraphPlain.Children.Add(HelpLine); } if (VertexesInEdge == 2) { MainWindow_.InfoCurr.Clear(); OnDefaultColor(); VertexesInEdge = 0; ConnectVertex(SearchVertexByEllipse(FirstVertex), SearchVertexByEllipse(ell)); AddEdgeEnabled = false; MyCursors.DefaultCursor(); } } if (AStarEnabled) { IsHolded = false; AStarVertexesEnumerator++; if (AStarVertexesEnumerator == 1) { FirstVertex = ell; MainWindow_.InfoCurr.Text = "A*. Выберете вторую вершину.ESC - отмена"; } if (AStarVertexesEnumerator == 2) { MainWindow_.InfoCurr.Clear(); AStarVertexesEnumerator = 0; SearchShortestPathAStar(SearchVertexByEllipse(FirstVertex), SearchVertexByEllipse(ell)); MyCursors.DefaultCursor(); AStarEnabled = false; } } }