Exemple #1
0
        public void DrawSelectionRectangle(Graphics graph, IpCursor selectCursor, IpCursor lastCursor)
        {
            if (selectCursor.X >= lastCursor.X && selectCursor.Y >= lastCursor.Y) // Правый нижний
            {
                x1 = lastCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y1 = lastCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
                x2 = selectCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y2 = selectCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
            }
            if (selectCursor.X <= lastCursor.X && selectCursor.Y >= lastCursor.Y) // Левый нижний
            {
                x1 = selectCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y1 = lastCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
                x2 = lastCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y2 = selectCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
            }
            if (selectCursor.X >= lastCursor.X && selectCursor.Y <= lastCursor.Y) // Правый верхний
            {
                x1 = lastCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y1 = selectCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
                x2 = selectCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y2 = lastCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
            }
            if (selectCursor.X <= lastCursor.X && selectCursor.Y <= lastCursor.Y) // Левый верхний
            {
                x1 = selectCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y1 = selectCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
                x2 = lastCursor.X * pic.ViewBox.scaleCoefficient - pic.ViewBox.xOffset;
                y2 = lastCursor.Y * pic.ViewBox.scaleCoefficient - pic.ViewBox.yOffset;
            }
            width  = x2 - x1;
            height = y2 - y1;

            graph.FillRectangle(brush, x1, y1, width, height);
        }
Exemple #2
0
 private void MagnetSplines(IpCursor cursor, bool ignoreSelected, float res)
 {
     for (int i = 0; i < pic.CounterSplines; ++i)
     {
         if (ignoreSelected)
         {
             if (pic.Splines[i].selected)
             {
                 continue;
             }
         }
         if (magnetPoints)
         {
             if (Math.Abs(pic.Splines[i].x1 - cursor.X) <= res && Math.Abs(pic.Splines[i].y1 - cursor.Y) <= res)
             {
                 cursor.X = pic.Splines[i].x1;
                 cursor.Y = pic.Splines[i].y1;
                 break;
             }
             if (Math.Abs(pic.Splines[i].x4 - cursor.X) <= res && Math.Abs(pic.Splines[i].y4 - cursor.Y) <= res)
             {
                 cursor.X = pic.Splines[i].x4;
                 cursor.Y = pic.Splines[i].y4;
                 break;
             }
         }
     }
 }
Exemple #3
0
        private void GridYPosition(IpCursor cursor, float yPos)
        {
            int LenghtLinesY = Convert.ToInt32(sizeY / countGridLines);
            int yT           = LenghtLinesY * Convert.ToInt16(yPos / LenghtLinesY);

            cursor.Y = yT;
        }
Exemple #4
0
        private void GridXPosition(IpCursor cursor, float xPos)
        {
            int LenghtLinesX = Convert.ToInt32(sizeX / countGridLines);
            int xT           = LenghtLinesX * Convert.ToInt16(xPos / LenghtLinesX);

            cursor.X = xT;
        }
Exemple #5
0
 public void Curve1(IpCursor selectCursor)
 {
     x2 = selectCursor.X;
     y2 = selectCursor.Y;
     x3 = selectCursor.X;
     y3 = selectCursor.Y;
     CalculatePoints();
 }
Exemple #6
0
        public GizmoLine(IpPicture pic, IpGrid grid) : base(pic, grid)
        {
            controllerPen         = new Pen(Color.Blue);
            selectedControllerPen = new Pen(Color.Violet);
            moveCursor            = new IpCursor(5, controllerPen);
            p1Cursor = new IpCursor(5, controllerPen);
            p2Cursor = new IpCursor(5, controllerPen);

            CreateGizmo();
        }
Exemple #7
0
 private bool ReDrawController(IpCursor cursor, int xPos, int yPos)
 {
     if (cursor.InCursorArea(xPos, yPos, pic.ViewBox.xOffset, pic.ViewBox.yOffset, pic.ViewBox.scaleCoefficient))
     {
         cursor.Pen = selectedControllerPen;
         return(true);
     }
     cursor.Pen = controllerPen;
     return(false);
 }
Exemple #8
0
 public void AddLine(IpCursor lastCursor, IpCursor selectCursor, Pen pen, int layer)
 {
     x1          = lastCursor.X;
     y1          = lastCursor.Y;
     x2          = selectCursor.X;
     y2          = selectCursor.Y;
     selected    = false;
     this.pen    = pen;
     selectedPen = new Pen(Color.Red);
     this.layer  = layer;
 }
Exemple #9
0
 public IpPicture(IpCursor selectCursor, IpCursor lastCursor, int sizeX, int sizeY, ViewBox viewBox)
 {
     lines             = new LinePic[counterLines];
     circles           = new Ellipse[counterCircles];
     splines           = new IpSpline[counterSplines];
     this.selectCursor = selectCursor;
     this.lastCursor   = lastCursor;
     vectorPicture     = new VectorPicture();
     this.sizeX        = sizeX;
     this.sizeY        = sizeY;
     this.ViewBox      = viewBox;
 }
Exemple #10
0
 public void AddCircle(IpCursor lastCursor, IpCursor selectCursor, Pen pen, int layer)
 {
     xR   = lastCursor.X;
     yR   = lastCursor.Y;
     radX = Math.Abs(lastCursor.X - selectCursor.X);
     radY = Math.Abs(lastCursor.Y - selectCursor.Y);
     CalculatePoints();
     this.pen    = pen;
     selectedPen = new Pen(Color.Red);
     this.layer  = layer;
     selected    = false;
 }
 public GizmoSpline(IpPicture pic, IpGrid grid) : base(pic, grid)
 {
     sectorBrush           = new SolidBrush(Color.FromArgb(50, 150, 0, 150));
     textBrush             = new SolidBrush(Color.Black);
     gizmoPen              = new Pen(Color.Gray);
     controllerPen         = new Pen(Color.Blue);
     selectedControllerPen = new Pen(Color.Violet);
     moveCursor            = new IpCursor(5, controllerPen);
     p1Cursor              = new IpCursor(5, controllerPen);
     p2Cursor              = new IpCursor(5, controllerPen);
     p3Cursor              = new IpCursor(5, controllerPen);
     p4Cursor              = new IpCursor(5, controllerPen);
     rotationCursor        = new IpCursor(10, controllerPen);
     CreateGizmo();
 }
Exemple #12
0
 public void AddSpline(IpCursor lastCursor, IpCursor selectCursor, Pen pen, int layer)
 {
     x1          = lastCursor.X;
     y1          = lastCursor.Y;
     x4          = selectCursor.X;
     y4          = selectCursor.Y;
     x2          = (x1 + x4) / 2;
     y2          = (y1 + y4) / 2;
     x3          = (x1 + x4) / 2;
     y3          = (y1 + y4) / 2;
     this.pen    = pen;
     selectedPen = new Pen(Color.Red);
     this.layer  = layer;
     CalculatePoints();
     selected = false;
 }
Exemple #13
0
 public GizmoMixed(IpPicture pic, IpGrid grid) : base(pic, grid)
 {
     gizmoPen              = new Pen(Color.Green);
     controllerPen         = new Pen(Color.Violet);
     selectedControllerPen = new Pen(Color.Blue);
     sectorBrush           = new SolidBrush(Color.FromArgb(50, 150, 0, 150));
     textBrush             = new SolidBrush(Color.Black);
     moveCursor            = new IpCursor(5, controllerPen);
     xScaleR        = new IpCursor(5, controllerPen);
     xScaleL        = new IpCursor(5, controllerPen);
     yScaleU        = new IpCursor(5, controllerPen);
     yScaleD        = new IpCursor(5, controllerPen);
     xyScaleUR      = new IpCursor(5, controllerPen);
     rotationCursor = new IpCursor(10, controllerPen);
     CreateGizmo();
 }
Exemple #14
0
        public void MirrorX(IpCursor cursor)
        {
            if (x1 < cursor.X)
            {
                x1 = x1 + Math.Abs(cursor.X - x1) * 2;
            }
            else
            {
                x1 = x1 - Math.Abs(cursor.X - x1) * 2;
            }

            if (x2 < cursor.X)
            {
                x2 = x2 + Math.Abs(cursor.X - x2) * 2;
            }
            else
            {
                x2 = x2 - Math.Abs(cursor.X - x2) * 2;
            }
        }
Exemple #15
0
        public void MirrorY(IpCursor cursor)
        {
            if (y1 < cursor.Y)
            {
                y1 = y1 + Math.Abs(cursor.Y - y1) * 2;
            }
            else
            {
                y1 = y1 - Math.Abs(cursor.Y - y1) * 2;
            }

            if (y2 < cursor.Y)
            {
                y2 = y2 + Math.Abs(cursor.Y - y2) * 2;
            }
            else
            {
                y2 = y2 - Math.Abs(cursor.Y - y2) * 2;
            }
        }
Exemple #16
0
 private void MagnetEllipses(IpCursor cursor, bool ignoreSelected, float res)
 {
     for (int i = 0; i < pic.CounterEllipses; ++i)
     {
         if (ignoreSelected)
         {
             if (pic.Ellipses[i].selected)
             {
                 continue;
             }
         }
         if (magnetCenter)
         {
             if (Math.Abs(pic.Ellipses[i].xR - cursor.X) <= res && Math.Abs(pic.Ellipses[i].yR - cursor.Y) <= res)
             {
                 cursor.X = pic.Ellipses[i].xR;
                 cursor.Y = pic.Ellipses[i].yR;
             }
         }
     }
 }
Exemple #17
0
        public void MirrorY(IpCursor cursor)
        {
            if (y1 < cursor.Y)
            {
                y1 = y1 + Math.Abs(cursor.Y - y1) * 2;
            }
            else
            {
                y1 = y1 - Math.Abs(cursor.Y - y1) * 2;
            }

            if (y2 < cursor.Y)
            {
                y2 = y2 + Math.Abs(cursor.Y - y2) * 2;
            }
            else
            {
                y2 = y2 - Math.Abs(cursor.Y - y2) * 2;
            }

            if (y3 < cursor.Y)
            {
                y3 = y3 + Math.Abs(cursor.Y - y3) * 2;
            }
            else
            {
                y3 = y3 - Math.Abs(cursor.Y - y3) * 2;
            }

            if (y4 < cursor.Y)
            {
                y4 = y4 + Math.Abs(cursor.Y - y4) * 2;
            }
            else
            {
                y4 = y4 - Math.Abs(cursor.Y - y4) * 2;
            }
            CalculatePoints();
        }
Exemple #18
0
        public void MirrorX(IpCursor cursor)
        {
            if (x1 < cursor.X)
            {
                x1 = x1 + Math.Abs(cursor.X - x1) * 2;
            }
            else
            {
                x1 = x1 - Math.Abs(cursor.X - x1) * 2;
            }

            if (x2 < cursor.X)
            {
                x2 = x2 + Math.Abs(cursor.X - x2) * 2;
            }
            else
            {
                x2 = x2 - Math.Abs(cursor.X - x2) * 2;
            }

            if (x3 < cursor.X)
            {
                x3 = x3 + Math.Abs(cursor.X - x3) * 2;
            }
            else
            {
                x3 = x3 - Math.Abs(cursor.X - x3) * 2;
            }

            if (x4 < cursor.X)
            {
                x4 = x4 + Math.Abs(cursor.X - x4) * 2;
            }
            else
            {
                x4 = x4 - Math.Abs(cursor.X - x4) * 2;
            }
            CalculatePoints();
        }
Exemple #19
0
        public void MoveCursor(IpCursor cursor, float xPos, float yPos, bool ignoreSelected, IpCursor pivot)
        {
            if (EnableGrid)
            {
                if (xPos != -1)
                {
                    GridXPosition(cursor, (xPos + viewBox.xOffset) / viewBox.scaleCoefficient);
                }
                if (yPos != -1)
                {
                    GridYPosition(cursor, (yPos + viewBox.yOffset) / viewBox.scaleCoefficient);
                }
            }
            else
            {
                if (xPos != -1)
                {
                    if (xPos < sizeX)
                    {
                        cursor.X = (xPos + viewBox.xOffset) / viewBox.scaleCoefficient;
                    }
                }
                if (yPos != -1)
                {
                    if (yPos < sizeY)
                    {
                        cursor.Y = (yPos + viewBox.yOffset) / viewBox.scaleCoefficient;
                    }
                }
            }
            if (EnableMagnet)
            {
                if (ignoreSelected)
                {
                    MagnetCursorPosition(cursor, (xPos + viewBox.xOffset) / viewBox.scaleCoefficient, (yPos + viewBox.yOffset) / viewBox.scaleCoefficient, true, 5);
                }
                else
                {
                    MagnetCursorPosition(cursor, (xPos + viewBox.xOffset) / viewBox.scaleCoefficient, (yPos + viewBox.yOffset) / viewBox.scaleCoefficient, false, 5);
                }
            }

            if (xPos != -1)
            {
                if (xPos >= sizeX)
                {
                    cursor.X = (sizeX + viewBox.xOffset) / viewBox.scaleCoefficient;
                }
                if (xPos < 0)
                {
                    cursor.X = viewBox.xOffset / viewBox.scaleCoefficient;
                }
            }
            if (yPos != -1)
            {
                if (yPos >= sizeY)
                {
                    cursor.Y = (sizeY + viewBox.yOffset) / viewBox.scaleCoefficient;
                }
                if (yPos < 0)
                {
                    cursor.Y = viewBox.yOffset / viewBox.scaleCoefficient;
                }
            }

            if (rotationGrid && pivot != null)
            {
                float xp     = pivot.X * viewBox.scaleCoefficient - viewBox.xOffset - xPos;
                float yp     = pivot.Y * viewBox.scaleCoefficient - viewBox.yOffset - yPos;
                float raduis = (float)Math.Sqrt(Math.Pow(xp, 2) + Math.Pow(yp, 2));
                float angle  = (float)Math.Atan2(-xp, -yp);
                angle    = GridRotation(angle);
                cursor.X = pivot.X + raduis / viewBox.scaleCoefficient * (float)Math.Sin(angle);
                cursor.Y = pivot.Y + raduis / viewBox.scaleCoefficient * (float)Math.Cos(angle);
            }
        }
Exemple #20
0
 private void MagnetCursorPosition(IpCursor cursor, float xPos, float yPos, bool ignoreSelected, float res)
 {
     MagnetLines(cursor, ignoreSelected, res);
     MagnetSplines(cursor, ignoreSelected, res);
     MagnetEllipses(cursor, ignoreSelected, res);
 }
Exemple #21
0
 private bool ResetControl(IpCursor cursor)
 {
     cursor.Pen = controllerPen;
     return(false);
 }
Exemple #22
0
        private void ScaleSelectedLinesX(bool right, float xPos)
        {
            float    mR  = 0;
            IpCursor pos = new IpCursor();

            grid.MoveCursor(pos, xPos, -1, true, null);
            float kX = pos.X;

            for (int i = 0; i < pic.CounterLines; ++i)
            {
                if (pic.Lines[i].selected)
                {
                    float coeff1 = 0;
                    float coeff2 = 0;
                    if (right)
                    {
                        mR     = xScaleR.X;
                        coeff1 = 1 - ((xScaleR.X - pic.Lines[i].x1) / width);
                        coeff2 = 1 - ((xScaleR.X - pic.Lines[i].x2) / width);
                    }
                    else
                    {
                        mR     = xScaleL.X;
                        coeff1 = 1 - ((pic.Lines[i].x1 - xScaleL.X) / width);
                        coeff2 = 1 - ((pic.Lines[i].x2 - xScaleL.X) / width);
                    }
                    pic.Lines[i].x1 += (kX - mR) * coeff1;
                    pic.Lines[i].x2 += (kX - mR) * coeff2;
                    pic.Lines[i].CalculateRotationAxes(moveCursor.X, moveCursor.Y);
                }
            }

            for (int i = 0; i < pic.CounterEllipses; ++i)
            {
                if (pic.Ellipses[i].selected)
                {
                    float coeffyR = 0;
                    float coeffxR = 0;
                    float coeff1  = 0;

                    float coeff2 = 0;
                    if (right)
                    {
                        mR      = xScaleR.X;
                        coeffxR = 1 - ((xScaleR.X - pic.Ellipses[i].xR) / width);
                        coeffyR = 1 - ((xScaleR.Y - pic.Ellipses[i].yR) / height);
                        //coeff1 = 1 - pic.Ellipses[i].radX / width;
                        coeff1 = (pic.Ellipses[i].radX / width);
                        coeff2 = (pic.Ellipses[i].radY / height);
                    }
                    else
                    {
                        //mR = xScaleL.X;
                        //coeff1 = 1 - ((pic.Ellipses[i].xR - xScaleL.X) / width);
                    }
                    //pic.Ellipses[i].radX += (kX - mR)/2 * coeff1;
                    pic.Ellipses[i].xR   += (kX - mR) * coeffxR * (float)Math.Cos(pic.Ellipses[i].pAlpha);
                    pic.Ellipses[i].radY += (kX - mR) * coeff2 * (float)Math.Sin(pic.Ellipses[i].pAlpha);
                    pic.Ellipses[i].radX += (kX - mR) * coeff1 * (float)Math.Cos(pic.Ellipses[i].pAlpha);
                    //pic.Ellipses[i].yR += (kX - mR) * coeffyR * (float)Math.Sin(pic.Ellipses[i].pAlpha);
                    pic.Ellipses[i].CalculatePoints();
                    pic.Ellipses[i].CalculateRotationAxes(moveCursor.X, moveCursor.Y);
                }
            }

            for (int i = 0; i < pic.CounterSplines; ++i)
            {
                if (pic.Splines[i].selected)
                {
                    float coeff1 = 0;
                    float coeff2 = 0;
                    float coeff3 = 0;
                    float coeff4 = 0;
                    if (right)
                    {
                        mR     = xScaleR.X;
                        coeff1 = 1 - ((xScaleR.X - pic.Splines[i].x1) / width);
                        coeff2 = 1 - ((xScaleR.X - pic.Splines[i].x2) / width);
                        coeff3 = 1 - ((xScaleR.X - pic.Splines[i].x3) / width);
                        coeff4 = 1 - ((xScaleR.X - pic.Splines[i].x4) / width);
                    }
                    else
                    {
                        mR     = xScaleL.X;
                        coeff1 = 1 - ((pic.Splines[i].x1 - xScaleL.X) / width);
                        coeff2 = 1 - ((pic.Splines[i].x2 - xScaleL.X) / width);
                        coeff3 = 1 - ((pic.Splines[i].x3 - xScaleL.X) / width);
                        coeff4 = 1 - ((pic.Splines[i].x4 - xScaleL.X) / width);
                    }
                    pic.Splines[i].x1 += (kX - mR) * coeff1;
                    pic.Splines[i].x2 += (kX - mR) * coeff2;
                    pic.Splines[i].x3 += (kX - mR) * coeff3;
                    pic.Splines[i].x4 += (kX - mR) * coeff4;
                    pic.Splines[i].CalculatePoints();
                    pic.Splines[i].CalculateRotationAxes(moveCursor.X, moveCursor.Y);
                }
            }

            if (right)
            {
                width += kX - mR;
                x2     = x1 + width;
            }
            else
            {
                x1   += kX - mR;
                width = x2 - x1;
            }
            DefaultControllerPosition(true, true);
        }
Exemple #23
0
        private void ScaleSelectedLinesY(bool up, float yPos)
        {
            float    mR  = 0;
            IpCursor pos = new IpCursor();

            grid.MoveCursor(pos, -1, yPos, true, null);
            float kY = pos.Y;

            for (int i = 0; i < pic.CounterLines; ++i)
            {
                if (pic.Lines[i].selected)
                {
                    float coeff1 = 0;
                    float coeff2 = 0;
                    if (up)
                    {
                        mR     = yScaleU.Y;
                        coeff1 = 1 - ((pic.Lines[i].y1 - yScaleU.Y) / height);
                        coeff2 = 1 - ((pic.Lines[i].y2 - yScaleU.Y) / height);
                    }
                    else
                    {
                        mR     = yScaleD.Y;
                        coeff1 = 1 - ((yScaleD.Y - pic.Lines[i].y1) / height);
                        coeff2 = 1 - ((yScaleD.Y - pic.Lines[i].y2) / height);
                    }
                    pic.Lines[i].y1 += (kY - mR) * coeff1;
                    pic.Lines[i].y2 += (kY - mR) * coeff2;
                    pic.Lines[i].CalculateRotationAxes(moveCursor.X, moveCursor.Y);
                }
            }

            for (int i = 0; i < pic.CounterSplines; ++i)
            {
                if (pic.Splines[i].selected)
                {
                    float coeff1 = 0;
                    float coeff2 = 0;
                    float coeff3 = 0;
                    float coeff4 = 0;
                    if (up)
                    {
                        mR     = yScaleU.Y;
                        coeff1 = 1 - ((pic.Splines[i].y1 - yScaleU.Y) / height);
                        coeff2 = 1 - ((pic.Splines[i].y2 - yScaleU.Y) / height);
                        coeff3 = 1 - ((pic.Splines[i].y3 - yScaleU.Y) / height);
                        coeff4 = 1 - ((pic.Splines[i].y4 - yScaleU.Y) / height);
                    }
                    else
                    {
                        mR     = yScaleD.Y;
                        coeff1 = 1 - ((yScaleD.Y - pic.Splines[i].y1) / height);
                        coeff2 = 1 - ((yScaleD.Y - pic.Splines[i].y2) / height);
                        coeff3 = 1 - ((yScaleD.Y - pic.Splines[i].y3) / height);
                        coeff4 = 1 - ((yScaleD.Y - pic.Splines[i].y4) / height);
                    }
                    pic.Splines[i].y1 += (kY - mR) * coeff1;
                    pic.Splines[i].y2 += (kY - mR) * coeff2;
                    pic.Splines[i].y3 += (kY - mR) * coeff3;
                    pic.Splines[i].y4 += (kY - mR) * coeff4;
                    pic.Splines[i].CalculatePoints();
                    pic.Splines[i].CalculateRotationAxes(moveCursor.X, moveCursor.Y);
                }
            }
            if (up)
            {
                y1     += kY - mR;
                height += mR - kY;
            }
            else
            {
                height += kY - mR;
                y2      = y1 + height;
            }
            DefaultControllerPosition(true, true);
        }
Exemple #24
0
 private void MagnetLines(IpCursor cursor, bool ignoreSelected, float res)
 {
     for (int i = 0; i < pic.CounterLines; ++i)
     {
         if (ignoreSelected)
         {
             if (pic.Lines[i].selected)
             {
                 continue;
             }
         }
         if (magnetPoints)
         {
             if (Math.Abs(pic.Lines[i].x1 - cursor.X) <= res && Math.Abs(pic.Lines[i].y1 - cursor.Y) <= res)
             {
                 cursor.X = pic.Lines[i].x1;
                 cursor.Y = pic.Lines[i].y1;
                 break;
             }
             if (Math.Abs(pic.Lines[i].x2 - cursor.X) <= res && Math.Abs(pic.Lines[i].y2 - cursor.Y) <= res)
             {
                 cursor.X = pic.Lines[i].x2;
                 cursor.Y = pic.Lines[i].y2;
                 break;
             }
         }
         if (magnetCenter)
         {
             if (Math.Abs((pic.Lines[i].x1 + pic.Lines[i].x2) / 2 - cursor.X) <= res && Math.Abs((pic.Lines[i].y1 + pic.Lines[i].y2) / 2 - cursor.Y) <= res)
             {
                 cursor.X = (pic.Lines[i].x1 + pic.Lines[i].x2) / 2;
                 cursor.Y = (pic.Lines[i].y1 + pic.Lines[i].y2) / 2;
                 break;
             }
         }
         if (magnetCross && pic.CounterLines > 1)
         {
             float x1 = pic.Lines[i].x1;
             float x2 = pic.Lines[i].x2;
             float y1 = pic.Lines[i].y1;
             float y2 = pic.Lines[i].y2;
             for (int k = i + 1; k < pic.CounterLines; ++k)
             {
                 if (pic.Lines[k].selected && ignoreSelected)
                 {
                     continue;
                 }
                 float x3    = pic.Lines[k].x1;
                 float x4    = pic.Lines[k].x2;
                 float y3    = pic.Lines[k].y1;
                 float y4    = pic.Lines[k].y2;
                 float delta = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
                 if (delta != 0)
                 {
                     float xP = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / delta;
                     float yP = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / delta;
                     float t1 = (x2 - x1 != 0) ? Math.Abs((xP - x1) / (x2 - x1)) : 0;
                     float t2 = (x4 - x3 != 0) ? Math.Abs((xP - x3) / (x4 - x3)) : 0;
                     float t3 = (y2 - y1 != 0) ? Math.Abs((yP - y1) / (y2 - y1)) : 0;
                     float t4 = (y4 - y3 != 0) ? Math.Abs((yP - y3) / (y4 - y3)) : 0;
                     if (t1 <= 1 && t2 <= 1 && t3 <= 1 && t4 <= 1)
                     {
                         if (Math.Abs(xP - cursor.X) <= res && Math.Abs(yP - cursor.Y) <= res)
                         {
                             cursor.X = xP;
                             cursor.Y = yP;
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
 public void SetCursorSettings(IpCursor cursor, int size, Pen pen)
 {
     cursor.Size = size;
     cursor.Pen  = pen;
 }