Esempio n. 1
0
 protected virtual void Line_PointChanged(object sender, PointChangedEventArgs e)
 {
     ResizeHandles.ForEach(h => h.Dispose());
     ResizeHandles.Clear();
     InitializeResizeHandle(provider);
     IsGraphicsPathChanged = true;
 }
Esempio n. 2
0
 public override void RenderHandles(Graphics g)
 {
     if (bmpMove != null)
     {
         return;
     }
     if (editingOn && (isSelected || isInitializing))
     {
         SolidBrush brFill    = new SolidBrush(Color.White);
         Pen        penBorder = new Pen(Color.Black);
         for (short i = 0; i < 4; i++)
         {
             if (points[i].X != int.MaxValue)
             {
                 g.FillRectangle(brFill, points[i].X - 3, points[i].Y - 3, 6, 6);
                 g.DrawRectangle(penBorder, points[i].X - 3, points[i].Y - 3, 6, 6);
             }
         }
         penBorder.Dispose();
         brFill.Dispose();
     }
     else if (_isSelected && !editingOn)
     {
         //if the shape is selected, paint the resize handles
         ResizeHandles.Render(g);
     }
 }
Esempio n. 3
0
 public override void RenderHandles(Graphics g)
 {
     if (_isSelected && !editingOn && !isMoving)
     {
         //if the shape is selected, paint the resize handles
         ResizeHandles.Render(g);
     }
 }
Esempio n. 4
0
        public override void RenderHandles(Graphics g)
        {
            if (bmpMove != null)
            {
                return;
            }
            if (editingOn && (isSelected || isInitializing))
            {
                int   intNum   = 0;
                short intCount = (short)points.Count;
                for (short i = 0; i < intCount; i++)
                {
                    if (isAnchor[i]) //IS ANCHOR
                    {
                        g.FillRectangle(Brushes.White, points[i].X - 3, points[i].Y - 3, 6, 6);
                        if (nodeIsSelected(i))
                        {
                            g.DrawRectangle(Pens.Red, points[i].X - 3, points[i].Y - 3, 6, 6);
                        }
                        else
                        {
                            g.DrawRectangle(Pens.Black, points[i].X - 3, points[i].Y - 3, 6, 6);
                        }
                    }
                    else if (types[i] == BEZIER)
                    {
                        if (isAnchor[i - 1])
                        {
                            intNum = i - 1;
                        }
                        else
                        {
                            intNum = i + 1;
                        }
                        //Read: Note1 at the top of the page for more info
                        if (types[intNum] == BEZIER_END)
                        {
                            intNum = 0;
                        }

                        if (nodeIsSelected((short)intNum))
                        {
                            g.DrawLine(Pens.Black, points[intNum], points[i]);
                            //g.DrawLine(Pens.White, points[intNum].X + 2, points[intNum].Y+2, points[i].X + 2, points[i].Y+2);
                            g.FillEllipse(Brushes.White, points[i].X - 3, points[i].Y - 3, 6, 6);
                            g.DrawEllipse(Pens.Black, points[i].X - 3, points[i].Y - 3, 6, 6);
                        }
                    }
                }
            }
            else if (_isSelected && !editingOn)
            {
                //if the shape is selected, paint the resize handles
                ResizeHandles.Render(g);
            }
        }
Esempio n. 5
0
 public virtual void Drag(Point oldPointer, Point currentPointer)
 {
     if (ResizeHandles.ActiveHandle is not null)
     {
         SetBounds(ResizeHandles.Resize(currentPointer, Bounds));
         return;
     }
     var(dx, dy) = (currentPointer.X - oldPointer.X, currentPointer.Y - oldPointer.Y);
     SetBounds(new Rectangle(Bounds.Left + dx, Bounds.Top + dy, Bounds.Size.Width, Bounds.Size.Height));
 }
Esempio n. 6
0
        protected override void InitializeResizeHandle(IPrimitiveProvider provider)
        {
            var list = Enum.GetValues(typeof(CornerType))
                       .Cast <CornerType>().Where(t => t != CornerType.Center);
            var rect = __bound.GetBounds();

            foreach (var item in list)
            {
                var r = new RectResizeHandle(rect.GetCornerPoint(item), this, item, provider);
                ResizeHandles.Add(r);
            }
        }
Esempio n. 7
0
 public virtual HitResult HitTest(Point p)
 {
     if (IsSelected)
     {
         var hitResult = ResizeHandles.HitTest(p);
         if (hitResult is not HitResult.None)
         {
             return(hitResult);
         }
     }
     return(HitTestStrategy.HitTest(p, this) ? HitResult.Body : HitResult.None);
 }
Esempio n. 8
0
        public override bool MouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            doOperation = false;
            if (isSelected && !editingOn && !mouseIsPressed)
            {
                ResizeHandles.HitTest(e.Location);
            }
            if (mouseIsPressed)
            {
                if (isResizing)
                {
                    Rectangle oldBounds = InvalidationArea;
                    Resize(e.Location);
                    InvalidationArea = Rectangle.Union(oldBounds,
                                                       GetShapeBounds(true));
                    doOperation = true;
                }
                else
                {
                    if (bmpMove == null)
                    {
                        RectangleF rectBounds  = Path.GetBounds();
                        Point      tmpLocation = Point.Round(rectBounds.Location);
                        Size       tmpSize     = Size.Round(rectBounds.Size);
                        GeneratePath(new Rectangle(0, 0, (int)rectBounds.Width, (int)rectBounds.Height));

                        bmpMove = new Bitmap((int)rectBounds.Width, (int)rectBounds.Height);
                        Graphics g       = Graphics.FromImage(bmpMove);
                        bool     blnTemp = painter.PaintFill;
                        painter.PaintFill = false;
                        painter.Paint(g, Path);
                        painter.PaintFill = blnTemp;
                        g.Dispose(); g    = null;

                        Location = tmpLocation;
                        Size     = tmpSize;
                    }


                    Rectangle oldBounds = new Rectangle(pntBitmapPos, bmpMove.Size);

                    pntBitmapPos     = new Point((int)(e.X + mouseOffset.X), (int)(e.Y + mouseOffset.Y));
                    InvalidationArea = Rectangle.Union(oldBounds,
                                                       new Rectangle(pntBitmapPos, bmpMove.Size));
                    doOperation = true;
                }
            }
            return(doOperation);
        }
Esempio n. 9
0
 public override void Draw(IGraphics g)
 {
     if (Fill is not null)
     {
         g.FillOval(Bounds, Fill);
     }
     if (Stroke is not null)
     {
         g.DrawOval(Bounds, Stroke);
     }
     if (IsSelected)
     {
         g.DrawRectangle(Bounds, new Stroke(Color.Black, 1));
         ResizeHandles.Draw(g);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 初始化Line中的Handle
        /// </summary>
        protected override void InitializeResizeHandle(IPrimitiveProvider provider)
        {
            PointF        prePoint  = PointF.Empty;
            List <PointF> allPoints = __line.Points;

            foreach (PointF p in allPoints)
            {
                if (prePoint != PointF.Empty)
                {
                    float  x        = (p.X + prePoint.X) / 2;
                    float  y        = (p.Y + prePoint.Y) / 2;
                    PointF newPoint = new PointF(x, y);
                    ResizeHandles.Add(new LineResizeHandle(newPoint, this, LineResizeType.MiddlePoint, provider));
                }
                ResizeHandles.Add(new LineResizeHandle(p, this, LineResizeType.BreakPoint, provider));
                prePoint = p;
            }
        }
 public override bool MouseMove(System.Windows.Forms.MouseEventArgs e)
 {
     if (isSelected && !editingOn && !mouseIsPressed)
     {
         ResizeHandles.HitTest(e.Location);
     }
     doOperation = false;
     if (mouseIsPressed)
     {
         eventData.NeedsPainted = true;
         if (isResizing)
         {
             Rectangle oldBounds = ResizeHandles.Bounds;//InvalidationArea;
             Resize(e.Location);
             blnSuppressInflate = true;
             InvalidationArea   = Rectangle.Union(oldBounds, GetShapeBounds(true));
             blnSuppressInflate = false;
             doOperation        = true;
         }
         else
         {
             if (bmpMove == null)
             {
                 bmpMove = new Bitmap((int)Size.Width + 2, (int)Size.Height + 2);
                 Graphics g   = Graphics.FromImage(bmpMove);
                 Pen      pen = new Pen(Color.Black, 1f);
                 pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                 g.DrawRectangle(pen, new Rectangle(new Point(0, 0), Size));
                 pen.Color = Color.White;
                 g.DrawRectangle(pen, new Rectangle(1, 1, Size.Width - 2, Size.Height - 2));
                 pen.Dispose();
                 pen            = null;
                 g.Dispose(); g = null;
                 _Path          = null;
             }
             Rectangle oldBounds = new Rectangle(pntBitmapPos, bmpMove.Size);
             pntBitmapPos     = new Point((int)(e.X + mouseOffset.X), (int)(e.Y + mouseOffset.Y));
             InvalidationArea = Rectangle.Union(oldBounds,
                                                new Rectangle(pntBitmapPos, bmpMove.Size));
             doOperation = true;
         }
     }
     return(doOperation);
 }
Esempio n. 12
0
 public virtual void Draw(IGraphics g)
 {
     if (Fill is not null)
     {
         g.FillRectangle(Bounds, Fill);
     }
     if (Stroke is not null)
     {
         g.DrawRectangle(Bounds, Stroke);
     }
     if (IsSelected)
     {
         if (Stroke is null)
         {
             g.DrawRectangle(Bounds, new Stroke(Color.Black, 1));
         }
         ResizeHandles.Draw(g);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 线段Handle的移动
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="vector">移动大小</param>
        /// <param name="special">需要只水平垂直移动设置为true,否则为false</param>
        public void LineResize(LineResizeHandle handle, SizeF vector, bool special)
        {
            int handleIndex = ResizeHandles.IndexOf(handle);

            switch (handle.Type)
            {
            case LineResizeType.BreakPoint:
                MoveBreakPointHandle(special, handleIndex, vector);
                break;

            case LineResizeType.MiddlePoint:
                MoveMiddlePointHandle(special, handleIndex, vector);
                break;

            default:
                break;
            }
            UpdateResizeHandle();
            IsGraphicsPathChanged = true;
        }
Esempio n. 14
0
        public override bool MouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            doOperation = false;
            if (isSelected && !editingOn && !mouseIsPressed)
            {
                ResizeHandles.HitTest(e.Location);
            }

            if (!mouseIsPressed)
            {
                return(false);
            }

            if (!editingOn)
            {
                if (isResizing)
                {
                    Rectangle oldBounds = ResizeHandles.Bounds;//InvalidationArea;
                    Resize(e.Location);
                    blnSuppressInflate = true;
                    InvalidationArea   = Rectangle.Union(oldBounds,
                                                         GetShapeBounds(true));
                    blnSuppressInflate = false;
                    doOperation        = true;
                }
                else
                {
                    Rectangle oldBounds = new Rectangle(Location, Size);
                    oldBounds.Inflate(12, 12);
                    Location         = new Point((int)(e.X + mouseOffset.X), (int)(e.Y + mouseOffset.Y));
                    InvalidationArea = Rectangle.Union(oldBounds,
                                                       new Rectangle(Location, Size));
                    //invalidationArea.Inflate(4, 4);
                    isMoving    = true;
                    doOperation = true;
                    _Path       = new GraphicsPath();
                }
            }
            return(doOperation);
        }
Esempio n. 15
0
        public override EventData MouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            ResetEventData();

            eventData.WasHit = HitTest(e);
            if (eventData.WasHit)
            {
                if (!isSelected)
                {
                    isSelected = true;
                    GeneratePath();//draw the text: selected
                }
                if (e.Clicks > 1)
                {
                    OnEditorRequested();
                }
                else
                {
                    mouseIsPressed = true;
                    if (!editingOn)
                    {
                        mouseOffset     = new PointF(GetShapeBounds(true).X - e.X, GetShapeBounds(true).Y - e.Y);
                        pntMoveStartPos = Location;
                        rectOldBounds   = GetShapeBounds(true);
                        isResizing      = (ResizeHandles.HitTest(e.Location));
                    }
                }
                eventData.NeedsPainted = true;
            }
            else
            {
                if (isSelected)
                {
                    isSelected = false;
                    GeneratePath(); //redraw the text: unselected
                    eventData.NeedsPainted = true;
                }
            }
            return(eventData);
        }
Esempio n. 16
0
        public override bool MouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            doOperation = false;
            if (isSelected && !editingOn && !mouseIsPressed)
            {
                ResizeHandles.HitTest(e.Location);
            }

            if (!mouseIsPressed)
            {
                return(false);
            }



            if (!isInitializing && editingOn && selectedNode != -1)
            {
                RectangleF oldBounds = Path.GetBounds();
                points[selectedNode] = e.Location;

                _Path = null;
                if (Path.GetBounds().Contains(oldBounds))
                {
                    InvalidationArea = GetShapeBounds(true);
                }
                else
                {
                    InvalidationArea = Rectangle.Round(oldBounds);
                }
                doOperation = true;
            }
            else if (!editingOn)
            {
                if (isResizing)
                {
                    Rectangle oldBounds = InvalidationArea;
                    Resize(e.Location);
                    InvalidationArea = Rectangle.Union(oldBounds,
                                                       GetShapeBounds(true));
                    doOperation = true;
                }
                else
                {
                    if (bmpMove == null)
                    {
                        Rectangle rectBounds = GetShapeBounds(true);

                        bmpMove = new Bitmap((int)rectBounds.Width + 2, (int)rectBounds.Height + 2);
                        Graphics g = Graphics.FromImage(bmpMove);

                        PointF[] arrTmp = new PointF[4];
                        points.CopyTo(arrTmp, 0);

                        Point tmp = new Point(0 - rectBounds.X,
                                              0 - rectBounds.Y);
                        for (short i = 0; i < 4; i++)
                        {
                            arrTmp[i] = new PointF((points[i].X + tmp.X),
                                                   (points[i].Y + tmp.Y));
                        }
                        g.DrawCurve(Pens.MediumBlue, arrTmp);

                        arrTmp         = null;
                        g.Dispose(); g = null;
                    }

                    Rectangle oldBounds = new Rectangle(pntBitmapPos, bmpMove.Size);
                    pntBitmapPos     = new Point((int)(e.X + mouseOffset.X), (int)(e.Y + mouseOffset.Y));
                    InvalidationArea = Rectangle.Union(oldBounds,
                                                       new Rectangle(pntBitmapPos, bmpMove.Size));
                    doOperation = true;
                }
            }
            return(doOperation);
        }
Esempio n. 17
0
        public override EventData MouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            ResetEventData();
            if (isInitializing)
            {
                if (points[0].X == int.MaxValue && points[3].X == int.MaxValue)
                {
                    points[0]        = e.Location;
                    InvalidationArea = new Rectangle(Point.Ceiling(points[0]), new Size(2, 2));
                }
                else if (points[3].X == int.MaxValue)
                {
                    points[3] = e.Location;
                    for (int i = 1; i < 3; ++i)
                    {
                        float frac = (float)i / (float)(3);
                        Point mid  = new Point((int)(points[0].X + frac * (points[3].X - points[0].X)),
                                               (int)(points[0].Y + frac * (points[3].Y - points[0].Y)));
                        points[i] = mid;
                    }
                    _Path = null;
                    //InvalidationArea = GetShapeBounds(true);
                    eventData.FinalizeShape = true;
                    isInitializing          = false;
                }

                eventData.WasHit       = true;
                eventData.NeedsPainted = true;
            }
            else
            {
                selectedNode     = -1;
                eventData.WasHit = HitTest(e);
                if (eventData.WasHit)
                {
                    isSelected     = true;
                    mouseIsPressed = true;
                    if (!editingOn)
                    {
                        mouseOffset     = new PointF(Path.GetBounds().X - e.X, Path.GetBounds().Y - e.Y);
                        pntMoveStartPos = Point.Round(Path.GetBounds().Location);
                        rectOldBounds   = GetShapeBounds(true);
                        isResizing      = (ResizeHandles.HitTest(e.Location));
                    }
                    else
                    {
                        RectangleF rectF = new RectangleF(0, 0, 6, 6);
                        for (short i = 0; i < 4; i++)
                        {
                            rectF.Location = new PointF(points[i].X - 3, points[i].Y - 3);
                            if (rectF.Contains(e.Location))
                            {
                                selectedNode = i;
                                i            = 4; //terminate the loop
                            }
                        }
                        if (e.Clicks > 1)
                        {
                            for (int i = 1; i < 3; ++i)
                            {
                                float frac = (float)i / (float)(3);
                                Point mid  = new Point((int)(points[0].X + frac * (points[3].X - points[0].X)),
                                                       (int)(points[0].Y + frac * (points[3].Y - points[0].Y)));
                                points[i] = mid;
                            }
                            _Path = null;
                            blnRefreshInvalidate = true;
                            blnStraightened      = true;
                        }
                    }
                    eventData.NeedsPainted = true;
                }
                else
                {
                    if (isSelected)
                    {
                        isSelected             = false;
                        eventData.NeedsPainted = true;
                    }
                }
            }

            return(eventData);
        }
Esempio n. 18
0
 public void SetBounds(Rectangle bounds)
 {
     Bounds = bounds;
     ResizeHandles.SetLocation(bounds);
 }
Esempio n. 19
0
        public override bool MouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            doOperation      = false;
            eventData.WasHit = false;
            if (isSelected && !editingOn && !mouseIsPressed && !isInitializing)
            {
                //if the cursor is over a resize handle, we will set the
                //cursor to the appropriate image.
                ResizeHandles.HitTest(e.Location);
            }

            //if we are not moving the shape...
            if (!isInitializing && isSelected && bmpMove != null)
            {
                for (i = 0; i < points.Count; i++)
                {
                    rectNode.X = (int)points[i].X - 3;
                    rectNode.Y = (int)points[i].Y - 3;
                    if (rectNode.Contains(e.Location))
                    {
                        eventData.WasHit = true;
                        i = (short)points.Count; //terminate the loop
                    }
                }
            }
            //if we ARE moving the shape...
            if (mouseIsPressed && !isInitializing)
            {
                if (editingOn && selectedNodes.Count >= 1)
                {
                    RectangleF oldBounds = Path.GetBounds();

                    //Read NOTE1 at the top of the class for more
                    //info about this code
                    if ((selectedNodes[0] == 0 || selectedNodes[0] ==
                         points.Count - 1) &&
                        points[points.Count - 1].Equals(points[0]))
                    {
                        points[points.Count - 1] = e.Location;
                    }

                    if (selectedNodes.Count > 1 && isAnchor[selectedNodes[0]])
                    {
                        // if the node we're dragging is an anchor point for
                        //a beizer curve, we also want to drag the tension
                        //points with it. Note we are peforming index range validation
                        int intNum = 0;
                        if (selectedNodes[0] - 1 != -1)
                        {
                            intNum = selectedNodes[0] - 1;
                        }
                        else
                        {
                            if (types[types.Count - 1] == BEZIER_END)
                            {
                                intNum = types.Count - 2;
                            }
                        }


                        //store the delta amount that the point has moved
                        PointF delta = new PointF(e.X - points[selectedNodes[0]].X,
                                                  e.Y - points[selectedNodes[0]].Y);

                        if (!isAnchor[intNum])
                        {
                            points[intNum] = new PointF(points[intNum].X + delta.X,
                                                        points[intNum].Y + delta.Y);
                        }
                        int intNum2 = selectedNodes[0] + 1 < points.Count ? selectedNodes[0] + 1 : 0;
                        //make sure that we're not referencing the same point as intNum
                        if (intNum2 != intNum && (!isAnchor[intNum2]))
                        {
                            points[intNum2] = new PointF(points[intNum2].X + delta.X,
                                                         points[intNum2].Y + delta.Y);
                        }
                    }

                    points[selectedNodes[0]] = e.Location;
                    hasDragged = true;

                    _Path = null;
                    if (Path.GetBounds().Contains(oldBounds))
                    {
                        InvalidationArea = GetShapeBounds(true);
                    }
                    else
                    {
                        InvalidationArea = Rectangle.Round(oldBounds);
                    }
                    doOperation = true;
                }
                else if (!editingOn)
                {
                    if (isResizing)
                    {
                        Rectangle oldBounds = InvalidationArea;
                        Resize(e.Location);
                        InvalidationArea = Rectangle.Union(oldBounds,
                                                           GetShapeBounds(true));
                        doOperation = true;
                    }
                    else
                    {
                        if (bmpMove == null)
                        {
                            RectangleF rectBounds = Path.GetBounds();
                            PointF     tmp        = new PointF(0 - rectBounds.X,
                                                               0 - rectBounds.Y);
                            short intCount = (short)points.Count;
                            for (short i = 0; i < intCount; i++)
                            {
                                points[i] = new PointF((points[i].X + tmp.X),
                                                       (points[i].Y + tmp.Y));
                            }
                            _Path = null;


                            bmpMove = new Bitmap((int)Path.GetBounds().Width, (int)Path.GetBounds().Height);
                            Graphics g       = Graphics.FromImage(bmpMove);
                            bool     blnTemp = painter.PaintFill;
                            painter.PaintFill = false;
                            painter.Paint(g, Path);
                            painter.PaintFill = blnTemp;

                            g.Dispose(); g = null;

                            //return to the original coords
                            tmp = new PointF(rectBounds.X, rectBounds.Y);
                            for (short i = 0; i < intCount; i++)
                            {
                                points[i] = new PointF((points[i].X + tmp.X),
                                                       (points[i].Y + tmp.Y));
                            }
                            _Path = null;
                        }


                        Rectangle oldBounds = new Rectangle(pntBitmapPos, bmpMove.Size);

                        pntBitmapPos     = new Point((int)(e.X + mouseOffset.X), (int)(e.Y + mouseOffset.Y));
                        InvalidationArea = Rectangle.Union(oldBounds,
                                                           new Rectangle(pntBitmapPos, bmpMove.Size));
                        doOperation = true;
                    }
                }
            }
            return(doOperation);
        }
Esempio n. 20
0
        public override EventData MouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            //reset variables
            beizerCounter           = 0;
            eventData.NeedsPainted  = false;
            eventData.FinalizeShape = false;

            //if the shape is being created...
            if (this.isInitializing)
            {
                this.AddPoint(e.Location);
                eventData.NeedsPainted = true;
                eventData.WasHit       = true;
            }
            //if the shape has been double clicked..
            else if (editingOn && e.Clicks > 1 &&
                     Path.IsOutlineVisible(e.Location, hitTestPen))
            {
                this.AddPoint(e.Location);
                eventData.NeedsPainted = true;
                eventData.WasHit       = true;
            }
            else
            {
                if ((isSelected || editingOn) && InvalidationArea.Contains(e.Location))
                {
                    eventData.WasHit = true;
                }
                else //if (!isEditing)
                {
                    eventData.WasHit = Path.IsVisible(e.Location);
                }

                if (eventData.WasHit)
                {
                    mouseOffset     = new PointF(Path.GetBounds().X - e.X, Path.GetBounds().Y - e.Y);
                    pntMoveStartPos = Point.Round(Path.GetBounds().Location);
                    selectedNodes.Clear();
                    isSelected = true;
                    painter.State.IsSelected = true;
                    rectOldBounds            = GetShapeBounds(true);

                    #region Polygon Editing Code
                    //**********************************************
                    //******    POLYGON EDITING CODE     ***********
                    if (!editingOn)
                    {
                        isSelected = true;
                        isResizing = (ResizeHandles.HitTest(e.Location));
                        painter.State.IsSelected = true;
                        painter.State.IsResizing = isResizing;
                    }
                    else
                    {
                        RectangleF rectF    = new RectangleF(0, 0, 6, 6);
                        int        intNum   = -1;
                        short      intCount = (short)points.Count;
                        for (short i = 0; i < intCount; i++)
                        {
                            if (isBeizer(types[i]))
                            {
                                beizerCounter++;
                                if (beizerCounter == BEZIER)
                                {
                                    isLeftAnchor  = !isLeftAnchor;
                                    beizerCounter = 0;
                                }
                            }

                            rectF.Location = new PointF(points[i].X - 3, points[i].Y - 3);
                            if (rectF.Contains(e.Location))
                            {
                                /////OnCursorChange(eCursor.HandGrip);

                                intNum = i + 1 < points.Count ? (i + 1) : 0;
                                if (!nodeIsSelected(i))
                                {
                                    selectedNodes.Add(i);
                                    if (!isAnchor[i])
                                    {
                                        if (isAnchor[i - 1])
                                        {
                                            selectedNodes.Add((short)(i - 1));
                                            intNum = i + 2 < points.Count - 1 ? (i + 2) : 0;
                                            selectedNodes.Add((short)(intNum));
                                        }
                                        else
                                        {   //Read: Note1 at the top of the page for more info
                                            if (types[i + 1] == BEZIER_END)
                                            {
                                                selectedNodes.Add(0);
                                            }
                                            else
                                            {
                                                selectedNodes.Add((short)(i + 1));
                                            }
                                            selectedNodes.Add((short)(i - 2));
                                        }
                                    }
                                    else
                                    {
                                        intNum = i - 1;

                                        //Find the point behind selected node and see if
                                        //it is a bezier node.
                                        //If we have cycled behind zero...
                                        if (intNum == -1 && (types[types.Count - 1] == BEZIER_END))
                                        {
                                            selectedNodes.Add((short)(types.Count - 4));
                                            //selectedNodes.Add((short)(types.Count - 3));
                                            //selectedNodes.Add((short)(types.Count - 1));
                                        }
                                        else
                                        {
                                            intNum = i - 1 < 0 ? points.Count - 1  : (i - 1);
                                            if (intNum != i && isBeizer(types[intNum]) && !isAnchor[intNum])
                                            {
                                                selectedNodes.Add((short)(intNum - 2));
                                            }
                                        }

                                        //If anchor point in front is a beizer, turn it on
                                        intNum = i + 3;
                                        if (i != intNum && intNum < intCount)
                                        {
                                            if (isBeizer(types[intNum]))
                                            {
                                                if (types[intNum] == BEZIER_END)
                                                {
                                                    selectedNodes.Add(0);
                                                }
                                                else
                                                {
                                                    selectedNodes.Add((short)(intNum));
                                                }
                                            }
                                        }
                                    }
                                }
                                i = intCount;
                            }
                        }
                    }
                    //END Polygon Editing Code
                    #endregion
                    mouseIsPressed          = true;
                    painter.State.IsEditing = editingOn;
                }
                else if (isSelected)
                {
                    selectedNodes.Clear();
                    isSelected             = false;
                    EditingOn              = false;
                    eventData.NeedsPainted = true;
                }
            }
            if (eventData.WasHit)
            {
                eventData.NeedsPainted = true;
            }
            return(eventData);
        }
Esempio n. 21
0
 public void Locate(Point location)
 {
     SetBounds(new Rectangle(location, new Size()));
     ResizeHandles.SetInitialActiveHandle();
 }
Esempio n. 22
0
        private void Launcher_MouseMove(object sender, MouseEventArgs e)
        {
            Point pos    = Cursor.Position;
            Point posOff = Cursor.Position;

            posOff.X -= Left;
            posOff.Y -= Top;
            if (!MouseIsDown)
            {
                CurrentRH = ResizeHandles.None;
                if (posOff.Y <= HandleWidth)
                {
                    CurrentRH = CurrentRH | ResizeHandles.Top;
                }
                if (posOff.X > Width - HandleWidth)
                {
                    CurrentRH = CurrentRH | ResizeHandles.Right;
                }
                if (posOff.Y > Height - HandleWidth)
                {
                    CurrentRH = CurrentRH | ResizeHandles.Bottom;
                }
                if (posOff.X <= HandleWidth)
                {
                    CurrentRH = CurrentRH | ResizeHandles.Left;
                }
                if (CurrentRH == ResizeHandles.None)
                {
                    Cursor = Cursors.Arrow;
                }
                if (CurrentRH == ResizeHandles.Left || CurrentRH == ResizeHandles.Right)
                {
                    Cursor = Cursors.SizeWE;
                }
                if (CurrentRH == ResizeHandles.Top || CurrentRH == ResizeHandles.Bottom)
                {
                    Cursor = Cursors.SizeNS;
                }
                if (CurrentRH == ResizeHandles.TopLeft || CurrentRH == ResizeHandles.BottomRight)
                {
                    Cursor = Cursors.SizeNWSE;
                }
                if (CurrentRH == ResizeHandles.TopRight || CurrentRH == ResizeHandles.BottomLeft)
                {
                    Cursor = Cursors.SizeNESW;
                }
                return;
            }
            if ((CurrentRH & ResizeHandles.Top) == ResizeHandles.Top)
            {
                int newHeight = (Top + Height) - pos.Y;
                if (newHeight > MinimumSize.Height)
                {
                    Height = newHeight;
                    Top    = pos.Y;
                }
            }
            if ((CurrentRH & ResizeHandles.Right) == ResizeHandles.Right)
            {
                Width = pos.X - Left;
            }
            if ((CurrentRH & ResizeHandles.Bottom) == ResizeHandles.Bottom)
            {
                Height = pos.Y - Top;
            }
            if ((CurrentRH & ResizeHandles.Left) == ResizeHandles.Left)
            {
                int newWidth = (Left + Width) - pos.X;
                if (newWidth > MinimumSize.Width)
                {
                    Width = newWidth;
                    Left  = pos.X;
                }
            }
        }