private PointF GetGripPosition(SizeGripPositions grip)
        {
            PointF pos = new PointF(0, 0);

            if (grip == SizeGripPositions.North)
            {
                pos.X = Rectangle.ActualWidth / 2;
                pos.Y = -4;
            }
            else if (grip == SizeGripPositions.East)
            {
                pos.X = Rectangle.ActualWidth + 4;
                pos.Y = Rectangle.ActualHeight / 2;
            }
            else if (grip == SizeGripPositions.South)
            {
                pos.X = Rectangle.ActualWidth / 2;
                pos.Y = Rectangle.ActualHeight + 4;
            }
            else if (grip == SizeGripPositions.West)
            {
                pos.X = -4;
                pos.Y = Rectangle.ActualHeight / 2;
            }

            pos.X += Rectangle.AbsoluteX;
            pos.Y += Rectangle.AbsoluteY;

            return(pos);
        }
Exemple #2
0
        private PointF GetGripPosition (SizeGripPositions grip)
        {
            PointF pos = new PointF(0, 0);
            if (grip == SizeGripPositions.North)
            {
                pos.X = Rectangle.ActualWidth / 2;
                pos.Y = -4;
            }
            else if (grip == SizeGripPositions.East)
            {
                pos.X = Rectangle.ActualWidth + 4;
                pos.Y = Rectangle.ActualHeight / 2;
            }
            else if (grip == SizeGripPositions.South)
            {
                pos.X = Rectangle.ActualWidth / 2;
                pos.Y = Rectangle.ActualHeight + 4;
            }
            else if (grip == SizeGripPositions.West)
            {
                pos.X = - 4;
                pos.Y = Rectangle.ActualHeight / 2;
            }
			
            pos.X += Rectangle.AbsoluteX;
            pos.Y += Rectangle.AbsoluteY;
			
            return pos;
        }
 public override void HandleMouseLeave()
 {
     if (grabbedGrip == SizeGripPositions.None)
     {
         SizeGripMouseLeave(this, new SizeGripEventArgs(highlightedGrip));
         highlightedGrip = SizeGripPositions.None;
         EmitRedraw();
     }
 }
        public override void HandleMouseDown(PointF pos)
        {
            grabbedGrip = InternalHitTest(pos);
            dragPos     = pos;
            dragOfst.X  = Rectangle.X - dragPos.X;
            dragOfst.Y  = Rectangle.Y - dragPos.Y;

            dragOrigWidth  = Rectangle.ActualWidth;
            dragOrigHeight = Rectangle.ActualHeight;
        }
Exemple #5
0
        private void DrawGripRect (Graphics graphics, SizeGripPositions grip)
        {
            Pen pen = Pens.Gray;
            if (grip == highlightedGrip)
                pen = Pens.Black;
			
            PointF pos = GetGripPosition (grip);
            graphics.FillRectangle(Brushes.White, pos.X - 3, pos.Y - 3, 6, 6);
            graphics.DrawRectangle(pen, pos.X - 3, pos.Y - 3, 6, 6);
        }
 private bool InternalHitTest(PointF pos, SizeGripPositions grip)
 {
     if ((gripPositions & grip) == grip)
     {
         if (IsInGrip(pos, GetGripPosition(grip)))
         {
             return(true);
         }
     }
     return(false);
 }
        private void DrawGripRect(Graphics graphics, SizeGripPositions grip)
        {
            Pen pen = Pens.Gray;

            if (grip == highlightedGrip)
            {
                pen = Pens.Black;
            }

            PointF pos = GetGripPosition(grip);

            graphics.FillRectangle(Brushes.White, pos.X - 3, pos.Y - 3, 6, 6);
            graphics.DrawRectangle(pen, pos.X - 3, pos.Y - 3, 6, 6);
        }
        public override void HandleMouseMove(PointF pos)
        {
            SizeGripPositions newGrip = InternalHitTest(pos);

            if (grabbedGrip == SizeGripPositions.None)
            {
                if (highlightedGrip != newGrip)
                {
                    SizeGripMouseLeave(this, new SizeGripEventArgs(highlightedGrip));
                    highlightedGrip = newGrip;
                    SizeGripMouseEnter(this, new SizeGripEventArgs(highlightedGrip));
                    EmitRedraw();
                }
            }

            if (grabbedGrip != SizeGripPositions.None)
            {
                if (grabbedGrip == SizeGripPositions.North)
                {
                    if (pos.Y >= 40)
                    {
                        Rectangle.Y      = dragOfst.Y + pos.Y;
                        Rectangle.Height = dragOrigHeight - pos.Y + dragPos.Y;
                    }
                }
                else if (grabbedGrip == SizeGripPositions.East)
                {
                    Rectangle.Width = dragOrigWidth + pos.X - dragPos.X;
                }
                else if (grabbedGrip == SizeGripPositions.South)
                {
                    Rectangle.Height = dragOrigHeight + pos.Y - dragPos.Y;
                }
                else if (grabbedGrip == SizeGripPositions.West)
                {
                    if (pos.X >= 40)
                    {
                        Rectangle.X     = dragOfst.X + pos.X;
                        Rectangle.Width = dragOrigWidth - pos.X + dragPos.X;
                    }
                }
            }
        }
 public SizeGripEventArgs(SizeGripPositions gripPosition)
 {
     this.gripPosition = gripPosition;
 }
 public override void HandleMouseUp(PointF pos)
 {
     grabbedGrip = SizeGripPositions.None;
 }
Exemple #11
0
 public SizeGripEventArgs (SizeGripPositions gripPosition)
 {
     this.gripPosition = gripPosition;
 }
Exemple #12
0
 public override void HandleMouseLeave()
 {
     if (grabbedGrip == SizeGripPositions.None)
     {
         SizeGripMouseLeave (this, new SizeGripEventArgs(highlightedGrip));
         highlightedGrip = SizeGripPositions.None;
         EmitRedraw();
     }
 }
Exemple #13
0
 public override void HandleMouseUp(PointF pos)
 {
     grabbedGrip = SizeGripPositions.None;
 }
Exemple #14
0
        public override void HandleMouseMove(PointF pos)
        {
            SizeGripPositions newGrip = InternalHitTest(pos);

            if (grabbedGrip == SizeGripPositions.None)
            {
                if (highlightedGrip != newGrip)
                {
                    SizeGripMouseLeave (this, new SizeGripEventArgs(highlightedGrip));
                    highlightedGrip = newGrip;
                    SizeGripMouseEnter (this, new SizeGripEventArgs(highlightedGrip));
                    EmitRedraw();
                }
            }

            if (grabbedGrip != SizeGripPositions.None)
            {
                if (grabbedGrip == SizeGripPositions.North)
                {
                    if (pos.Y >= 40)
                    {
                        Rectangle.Y = dragOfst.Y + pos.Y;
                        Rectangle.Height = dragOrigHeight - pos.Y + dragPos.Y;
                    }
                }
                else if (grabbedGrip == SizeGripPositions.East)
                {
                    Rectangle.Width = dragOrigWidth + pos.X - dragPos.X;
                }
                else if (grabbedGrip == SizeGripPositions.South)
                {
                    Rectangle.Height = dragOrigHeight + pos.Y - dragPos.Y;
                }
                else if (grabbedGrip == SizeGripPositions.West)
                {
                    if (pos.X >= 40)
                    {
                        Rectangle.X = dragOfst.X + pos.X;
                        Rectangle.Width = dragOrigWidth - pos.X + dragPos.X;
                    }
                }
            }
        }
Exemple #15
0
        public override void HandleMouseDown(PointF pos)
        {
            grabbedGrip = InternalHitTest(pos);
            dragPos = pos;
            dragOfst.X = Rectangle.X - dragPos.X;
            dragOfst.Y = Rectangle.Y - dragPos.Y;
			
            dragOrigWidth = Rectangle.ActualWidth;
            dragOrigHeight = Rectangle.ActualHeight;
        }
Exemple #16
0
 private bool InternalHitTest(PointF pos, SizeGripPositions grip)
 {
     if ((gripPositions & grip) == grip)
         if (IsInGrip (pos, GetGripPosition(grip)))
             return true;
     return false;
 }