private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { Point FreePoint = new Point(e.X, e.Y); if (ImageMatrix != null) { AnchorList.Add(FreePoint); } if (AnchorList.Count != 0 && ImageMatrix != null) { Graphics g = pictureBox1.CreateGraphics(); Pen pencil = new Pen(Brushes.Black); Assistant.DrawCircle(g, pencil, AnchorList[AnchorList.Count - 1].X, AnchorList[AnchorList.Count - 1].Y, 2); Assistant.FillCircle(g, Brushes.Black, AnchorList[AnchorList.Count - 1].X, AnchorList[AnchorList.Count - 1].Y, 2); } if (AnchorList.Count > 1 && ImageMatrix != null) { int Source = Assistant.Tabular(AnchorList[AnchorList.Count - 2].X, AnchorList[AnchorList.Count - 2].Y, ImageOperations.GetHeight(ImageMatrix)); int Dest = Assistant.Tabular(AnchorList[AnchorList.Count - 1].X, AnchorList[AnchorList.Count - 1].Y, ImageOperations.GetHeight(ImageMatrix)); List <Point> path = ShortestpathSubroutiens.DetermineShortestPath(Source, Dest, ImageMatrix); Assistant.AppendToList <Point>(MainSelection, path.ToArray()); Graphics g = pictureBox1.CreateGraphics(); Pen Pencil = new Pen(Color.Yellow); for (int i = 0; i < path.Count - 1; i++) { g.DrawLine(Pencil, path[i], path[i + 1]); } } }
private void closeShape_Click(object sender, EventArgs e) { if (ImageMatrix != null && AnchorList.Count > 1) { int src = Assistant.Tabular(AnchorList[0].X, AnchorList[0].Y, ImageOperations.GetHeight(ImageMatrix)); int dest = Assistant.Tabular(AnchorList[AnchorList.Count - 1].X, AnchorList[AnchorList.Count - 1].Y, ImageOperations.GetHeight(ImageMatrix)); List <Point> path = ShortestpathSubroutiens.DetermineShortestPath(src, dest, ImageMatrix); Assistant.AppendToList(MainSelection, path.ToArray()); Graphics g = pictureBox1.CreateGraphics(); Pen Pencil = new Pen(Color.Yellow); for (int i = 0; i < path.Count - 1; i++) { g.DrawLine(Pencil, path[i], path[i + 1]); } } }