Пример #1
0
        public override bool HitTest(MouseEventArgs e)
        {
            //we only need the Location of the mouse but by passing
            //the MouseEventArgs, no value copying has to occur.
            //Only the memory reference will be passed
            if (!isSelected && BufferSize.Width > 1)
            {
                return(new Rectangle(Location.X + intBmpOffsetX, Location.Y,
                                     (int)Buffer.Size.Width, (int)BufferSize.Height).Contains(e.Location));
            }
            ;

            return(InvalidationArea.Contains(e.Location));
        }
Пример #2
0
        public override bool HitTest(MouseEventArgs e)
        {
            //we only need the Location of the mouse but by passing
            //the MouseEventArgs, no value copying has to occur.
            //Only the memory reference will be passed

            if (isSelected && InvalidationArea.Contains(e.Location) || isInitializing)
            {
                return(true);
            }
            else if (Path.IsVisible(e.Location))
            {
                return(true);
            }
            else if (Path.IsOutlineVisible(e.Location, hitTestPen))
            {
                return(true);
            }

            return(false);
        }
Пример #3
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);
        }