Esempio n. 1
0
 private double calculateLength(MyPoint p1, MyPoint p2)
 {
     return(Math.Sqrt((p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y)));
 }
Esempio n. 2
0
 public override void movePoint(MyPoint p1, MyPoint p2, ref int dX, ref int dY)
 {
     p2.Y = p1.Y;
 }
Esempio n. 3
0
        private void DrawLine(MyPoint p1, MyPoint p2, PaintEventArgs e)
        {
            PointF drawPoint = new PointF(Math.Abs(p1.X - p2.X) / 2 + 5 + Math.Min(p1.X, p2.X), Math.Abs(p2.Y - p1.Y) / 2 + 5 + Math.Min(p1.Y, p2.Y));

            FindRestriction(p1, p2)?.drawIcon(e.Graphics, drawPoint);

            int x = p1.X;
            int y = p1.Y;
            int x2 = p2.X;
            int y2 = p2.Y;
            int w = x2 - x;
            int h = y2 - y;
            int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;

            if (w < 0)
            {
                dx1 = -1;
            }
            else if (w > 0)
            {
                dx1 = 1;
            }
            if (h < 0)
            {
                dy1 = -1;
            }
            else if (h > 0)
            {
                dy1 = 1;
            }
            if (w < 0)
            {
                dx2 = -1;
            }
            else if (w > 0)
            {
                dx2 = 1;
            }
            int longest  = Math.Abs(w);
            int shortest = Math.Abs(h);

            if (!(longest > shortest))
            {
                longest  = Math.Abs(h);
                shortest = Math.Abs(w);
                if (h < 0)
                {
                    dy2 = -1;
                }
                else if (h > 0)
                {
                    dy2 = 1;
                }
                dx2 = 0;
            }
            int numerator = longest >> 1;

            for (int i = 0; i <= longest; i++)
            {
                e.Graphics.FillRectangle(Brushes.White, x, y, 1, 1);
                numerator += shortest;
                if (!(numerator < longest))
                {
                    numerator -= longest;
                    x         += dx1;
                    y         += dy1;
                }
                else
                {
                    x += dx2;
                    y += dy2;
                }
            }
        }
Esempio n. 4
0
 abstract public void movePoint(MyPoint p1, MyPoint p2, ref int dX, ref int dY);