Exemplo n.º 1
0
        public ResizeHandle(Figure owner, VectorFigure handleShape, float offsetX, float offsetY, ResizeDirections direction)
        {
            HandleShape = handleShape;

            Width  = handleShape.Width;
            Height = handleShape.Height;

            _offsetX = offsetX;
            _offsetY = offsetY;
            handleShape.IsDragable      = false;
            handleShape.IsVisible       = false;
            handleShape.IsSelectable    = false;
            handleShape.CanBeSnapTarget = false;

            Direction = direction;

            IsDragable      = true;
            IsVisible       = true;
            IsSelectable    = true;
            CanBeSnapTarget = false;
            SetSnapTargets(SnapTargets.Center);

            Owner = owner;

            Update();
        }
 public FollowMasterResizePolicy(Figure master, float offsetX, float offsetY, ResizeDirections resizeDirection)
 {
     OffsetX         = offsetX;
     OffsetY         = offsetY;
     ResizeDirection = resizeDirection;
     _master         = master;
 }
Exemplo n.º 3
0
        public ResizeHelper(IComponent target, ResizeDirections directions = ResizeDirections.All)
        {
            Assert.IsNotNull(target, "target != null");

            Target     = target;
            Directions = directions;

            Handles = Enumerable.Empty <ResizeHandle>().ToList();
        }
Exemplo n.º 4
0
 private void Mouse_ButtonUp(object sender, MouseEventArgs e)
 {
     if ((e.Button == MouseButtons.Left) && this.IsResizing)
     {
         base.ResumeLayout(true);
         this.mLayoutSuspended = false;
         this.Refresh();
         this.mIsResizing = false;
         this.Cursor = Cursors.Default;
         this.mResizeDirection = ResizeDirections.None;
     }
 }
Exemplo n.º 5
0
 private void Mouse_ButtonDown(object sender, MouseEventArgs e)
 {
     if ((((e.Button == MouseButtons.Left) && !this.IsResizing) && (!base.IsDisposed && !base.Disposing)) && base.Bounds.Contains(e.Location))
     {
         Point point = base.PointToClient(e.Location);
         if ((point.X < this.ResizeThreshold) && (point.Y < this.ResizeThreshold))
         {
             this.Cursor = Cursors.SizeNWSE;
             this.mResizeDirection = ResizeDirections.TopLeft;
             this.mIsResizing = true;
         }
         else if ((point.X > (base.Width - this.ResizeThreshold)) && (point.Y < this.ResizeThreshold))
         {
             this.Cursor = Cursors.SizeNESW;
             this.mResizeDirection = ResizeDirections.TopRight;
             this.mIsResizing = true;
         }
         else if ((point.X > (base.Width - this.ResizeThreshold)) && (point.Y > (base.Height - this.ResizeThreshold)))
         {
             this.Cursor = Cursors.SizeNWSE;
             this.mResizeDirection = ResizeDirections.BottomRight;
             this.mIsResizing = true;
         }
         else if ((point.X < this.ResizeThreshold) && (point.Y > (base.Height - this.ResizeThreshold)))
         {
             this.Cursor = Cursors.SizeNESW;
             this.mResizeDirection = ResizeDirections.BottomLeft;
             this.mIsResizing = true;
         }
         else if (point.X < this.ResizeThreshold)
         {
             this.Cursor = Cursors.SizeWE;
             this.mResizeDirection = ResizeDirections.Left;
             this.mIsResizing = true;
         }
         else if (point.Y < this.ResizeThreshold)
         {
             this.Cursor = Cursors.SizeNS;
             this.mResizeDirection = ResizeDirections.Top;
             this.mIsResizing = true;
         }
         else if (point.X > (base.Width - this.ResizeThreshold))
         {
             this.Cursor = Cursors.SizeWE;
             this.mResizeDirection = ResizeDirections.Right;
             this.mIsResizing = true;
         }
         else if (point.Y > (base.Height - this.ResizeThreshold))
         {
             this.Cursor = Cursors.SizeNS;
             this.mResizeDirection = ResizeDirections.Bottom;
             this.mIsResizing = true;
         }
         else
         {
             this.Cursor = Cursors.Default;
             this.mResizeDirection = ResizeDirections.None;
             this.mIsResizing = false;
         }
         if (this.IsResizing)
         {
             this.LastDrag = Environment.TickCount;
             base.SuspendLayout();
             this.mLayoutSuspended = true;
             if (this.Dragging)
             {
                 this.EndDrag();
             }
             this.ResizeStartLoc = e.Location;
             this.ResizeStartSize = base.Size;
         }
     }
 }
Exemplo n.º 6
0
 public ResizeMasterPolicy(Figure slave, ResizeDirections resizeDirection) : base(slave)
 {
     ResizeDirection = resizeDirection;
 }
Exemplo n.º 7
0
        public bool ChangeSize(decimal change, ResizeTypes type, ResizeDirections dir, out decimal pctChange)
        {
            bool success = true;
            pctChange = 0;
            int newHeight = AlteredImg.Height;
            int newWidth = AlteredImg.Width;

            if (type == ResizeTypes.Percent)
            {
                decimal multiplier = 1.00m + (change / 100);
                if (dir == ResizeDirections.Vertical)
                {
                    decimal decNewHeight = (StartImg.Height * multiplier);
                    decimal decNewWidth = (StartImg.Width * multiplier);
                    newHeight = (int)decNewHeight;
                    newWidth = (int)decNewWidth;
                    pctChange = change;
                }
            }
            else if (type == ResizeTypes.Pixels)
            {
                if (dir == ResizeDirections.Vertical)
                {
                    newHeight = AlteredImg.Height + (int)change;
                    decimal newHeightPct = ((decimal)newHeight / (decimal)AlteredImg.Height);
                    newWidth = (int)Math.Round(AlteredImg.Width * newHeightPct);
                }
                else if (dir == ResizeDirections.Horizontal)
                {
                    newWidth = AlteredImg.Width + (int)change;
                    decimal newWidthPct = ((decimal)newWidth / (decimal)AlteredImg.Width);
                    newHeight = (int)Math.Round(AlteredImg.Height * newWidthPct);
                }
                pctChange = (((decimal)newHeight / (decimal)StartImg.Height) - 1) * 100.0m;
            }

            if (HasCrop)
            {
                if (change < 0) // Decreasing image size
                {
                    if (Crop.GetRectangle().Bottom >= this.GetRectangle().Bottom ||
                        Crop.GetRectangle().Right >= this.GetRectangle().Right)
                        success = false;
                }
            }

            if (success)
            {
                AlteredImg.Dispose();
                AlteredImg = new Bitmap(StartImg, new Size { Width = newWidth, Height = newHeight });
            }

            return success;
        }