private void panel1_MouseUp(object sender, MouseEventArgs e) { undo = new UndoClass(new List<int[]>(edges), new Dictionary<string, int>(points), new Dictionary<int, string>(reverse_points)); finishpointx = e.X; finishpointy = e.Y; b[0] = finishpointx / 20; b[1] = finishpointy/20; counter++; string key = String.Format("{0}, {1}", b[0], b[1]); if (!points.ContainsKey(key) && checkBox1.Checked) { MessageBox.Show("Setting is 'don't create new vertices' - can't draw new vertex"); return; } formGraphics.DrawLine(myPen, startpointx, startpointy, finishpointx, finishpointy); points_count++; string beginkey = String.Format("{0}, {1}", a[0], a[1]); string key2 = String.Format("{0}, {1}", finishpointx, finishpointy); if (!points.ContainsKey(key)) { points.Add(key, points_count); reverse_points.Add(points_count, key2); formGraphics.DrawEllipse(myPen, finishpointx - 8, finishpointy - 8, 16, 16); formGraphics.FillEllipse(myBrush, finishpointx - 8, finishpointy - 8, 16, 16); } int[] edg = { points[beginkey], points[key] }; edges.Add(edg); button7.Enabled = true; }
private void Undo() { UndoClass undo2 = new UndoClass(new List<int[]>(edges), new Dictionary<string, int>(points), new Dictionary<int, string>(reverse_points)); points = undo.points; edges = undo.edges; reverse_points = undo.reverse_points; Redraw(); undo = undo2; }
private void panel1_Click(object sender, MouseEventArgs e) { undo = new UndoClass(new List<int[]>(edges), new Dictionary<string, int>(points), new Dictionary<int,string>(reverse_points)); startpointx = e.X; startpointy = e.Y; a[0] = startpointx / 20; a[1] = startpointy/20; counter++; points_count++; string key = String.Format("{0}, {1}", a[0], a[1]); string key2 = String.Format("{0}, {1}", startpointx, startpointy); if (!points.ContainsKey(key)) { if (!(counter > 1)) { formGraphics.DrawEllipse(myPen, startpointx - 8, startpointy - 8, 16, 16); formGraphics.FillEllipse(myBrush, startpointx - 8, startpointy - 8, 16, 16); points.Add(key, points_count); reverse_points.Add(points_count, key2); } else { MessageBox.Show("Graph must be coherent!"); } } // } }