public override void OnMouseUp(MouseEventArgs e) { var newP = WinManager.Instance.CreatePoint(e.X, CGUtils.ReversedY(e.Y)); if (newP == null) { //var currP = form.currPt; //if (form.Points.Count > 1 && CGUtils.SqrtLength(form.Points[0], currP) < 500) { // form.Points[0].pred = lastP; // lastP.succ = form.Points[0]; // Draw.DrawLine(lastP, form.Points[0]); // Draw.DrawImage(); // lastP = null; //} return; } Draw.DrawPoint(newP); Draw.DrawLine(lastP, newP); var edge = CGEdge.CreateEdge(lastP, newP); edges.Add(edge); lastP.owner = edge; newP.owner = edge; lastP.succ = newP; newP.pred = lastP; lastP = null; }
public override void OnMouseDown(MouseEventArgs e) { if (lastP == null) { lastP = WinManager.Instance.CreatePoint(e.X, CGUtils.ReversedY(e.Y)); Draw.DrawPoint(lastP); } Draw.DrawImage(); }
public static void DrawPoint(int x, int y, int radius = 4) { Rectangle rect = new Rectangle(x - radius / 2, CGUtils.ReversedY(y) - radius / 2, radius, radius); g.DrawEllipse(pen, rect); Brush b = new SolidBrush(pointColor); g.FillEllipse(b, rect); DrawImage(); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { currPt.X = e.X; currPt.Y = CGUtils.ReversedY(e.Y); toolStripStatusLabel1.Text = "Spt:" + Spt.X.ToString() + "," + Spt.Y.ToString(); toolStripStatusLabel2.Text = string.Format("CurrPoint: {0},{1}", currPt.X.ToString(), currPt.Y.ToString()); if (chapter != null) { chapter.OnMouseMove(e); } }
public static void DrawPoint(CGPoint point, bool drawInfo = true, int radius = 4) { if (point == null) { return; } DrawPoint((int)point.x, (int)point.y, radius); if (drawInfo) { g.DrawString(point.id.ToString(), new Font("Arial", 10), new SolidBrush(Color.Black), (float)point.x - 3, (float)CGUtils.ReversedY(point.y - 3)); } }
public override void OnMouseMove(MouseEventArgs e) { if (form.IsMouseDown) { var currP = form.currPt; for (int i = 0; i < form.Points.Count; i++) { if (form.Points[i] != lastP && CGUtils.SqrtLength(form.Points[i], currP) < 500) { currP.Y = CGUtils.ReversedY(currP.Y); Point p = form.PictureBox1.PointToScreen(new Point((int)form.Points[i].x, (int)CGUtils.ReversedY(form.Points[i].y))); SetCursorPos(p.X, p.Y); linkPoint = form.Points[i]; } } Draw.DrawImage(); } }
public override void OnMouseUp(MouseEventArgs e) { var newP = WinManager.Instance.CreatePoint(e.X, CGUtils.ReversedY(e.Y)); if (newP == null) { var currP = form.currPt; if (CGUtils.SqrtLength(linkPoint, currP) < 500) { linkPoint.pred = lastP; lastP.succ = linkPoint; Draw.DrawLine(lastP, linkPoint); Draw.DrawImage(); lastP = null; } return; } Draw.DrawPoint(newP); Draw.DrawLine(lastP, newP); lastP.succ = newP; newP.pred = lastP; lastP = newP; }
public static void DrawLine(float ax, float ay, float bx, float by, Graphics graphic = null) { graphic = graphic != null ? graphic : g; graphic.DrawLine(pen, ax, CGUtils.ReversedY(ay), bx, CGUtils.ReversedY(by)); }