Example #1
0
        private void GripperMouseUp(object sender, MouseEventArgs e)
        {
            Gripper originatingGripper = (Gripper)sender;

            if (originatingGripper != _targetGripper)
            {
                _boundsBeforeResize = Rectangle.Empty;
                _boundsAfterResize  = RectangleF.Empty;
                isMadeUndoable      = false;
            }
            Status = EditStatus.IDLE;
            Invalidate();
        }
Example #2
0
        private void GripperMouseDown(object sender, MouseEventArgs e)
        {
            Gripper originatingGripper = (Gripper)sender;

            if (originatingGripper != _targetGripper)
            {
                Status = EditStatus.RESIZING;
                _boundsBeforeResize = new Rectangle(left, top, width, height);
                _boundsAfterResize  = new RectangleF(_boundsBeforeResize.Left, _boundsBeforeResize.Top, _boundsBeforeResize.Width, _boundsBeforeResize.Height);
            }
            else
            {
                Status = EditStatus.MOVING;
            }
            isMadeUndoable = false;
        }
Example #3
0
 /// <summary>
 /// Initialize a target gripper
 /// </summary>
 protected void InitTargetGripper(Color gripperColor, Point location)
 {
     _targetGripper = new Gripper {
         Cursor    = Cursors.SizeAll,
         BackColor = gripperColor,
         Visible   = false,
         Parent    = _parent,
         Location  = location
     };
     _targetGripper.MouseDown += GripperMouseDown;
     _targetGripper.MouseUp   += GripperMouseUp;
     _targetGripper.MouseMove += GripperMouseMove;
     if (_parent != null)
     {
         _parent.Controls.Add(_targetGripper);                 // otherwise we'll attach them in switchParent
     }
 }
Example #4
0
        private void GripperMouseMove(object sender, MouseEventArgs e)
        {
            Invalidate();
            Gripper originatingGripper = (Gripper)sender;
            int     absX = originatingGripper.Left + e.X;
            int     absY = originatingGripper.Top + e.Y;

            if (originatingGripper == _targetGripper && Status.Equals(EditStatus.MOVING))
            {
                TargetGripperMove(absX, absY);
            }
            else if (Status.Equals(EditStatus.RESIZING))
            {
                // check if we already made this undoable
                if (!isMadeUndoable)
                {
                    // don't allow another undo until we are finished with this move
                    isMadeUndoable = true;
                    // Make undo-able
                    MakeBoundsChangeUndoable(false);
                }

                SuspendLayout();

                // reset "workbench" rectangle to current bounds
                _boundsAfterResize.X      = _boundsBeforeResize.X;
                _boundsAfterResize.Y      = _boundsBeforeResize.Y;
                _boundsAfterResize.Width  = _boundsBeforeResize.Width;
                _boundsAfterResize.Height = _boundsBeforeResize.Height;

                // calculate scaled rectangle
                ScaleHelper.Scale(ref _boundsAfterResize, originatingGripper.Position, new PointF(absX, absY), ScaleHelper.GetScaleOptions());

                // apply scaled bounds to this DrawableContainer
                ApplyBounds(_boundsAfterResize);

                ResumeLayout();
            }
            Invalidate();
        }
Example #5
0
 protected void InitGrippers()
 {
     _grippers = new Gripper[8];
     for (int i = 0; i < _grippers.Length; i++)
     {
         _grippers[i]            = new Gripper();
         _grippers[i].Position   = i;
         _grippers[i].MouseDown += GripperMouseDown;
         _grippers[i].MouseUp   += GripperMouseUp;
         _grippers[i].MouseMove += GripperMouseMove;
         _grippers[i].Visible    = false;
         _grippers[i].Parent     = _parent;
     }
     _grippers[Gripper.POSITION_TOP_CENTER].Cursor    = Cursors.SizeNS;
     _grippers[Gripper.POSITION_MIDDLE_RIGHT].Cursor  = Cursors.SizeWE;
     _grippers[Gripper.POSITION_BOTTOM_CENTER].Cursor = Cursors.SizeNS;
     _grippers[Gripper.POSITION_MIDDLE_LEFT].Cursor   = Cursors.SizeWE;
     if (_parent != null)
     {
         _parent.Controls.AddRange(_grippers); // otherwise we'll attach them in switchParent
     }
 }
Example #6
0
 protected void InitGrippers()
 {
     grippers = new Gripper[8];
     for (int i = 0; i < grippers.Length; i++)
     {
         grippers[i]            = new Gripper();
         grippers[i].Position   = i;
         grippers[i].MouseDown += new MouseEventHandler(gripperMouseDown);
         grippers[i].MouseUp   += new MouseEventHandler(gripperMouseUp);
         grippers[i].MouseMove += new MouseEventHandler(gripperMouseMove);
         grippers[i].Visible    = false;
         grippers[i].Parent     = parent;
     }
     grippers[Gripper.POSITION_TOP_CENTER].Cursor    = Cursors.SizeNS;
     grippers[Gripper.POSITION_MIDDLE_RIGHT].Cursor  = Cursors.SizeWE;
     grippers[Gripper.POSITION_BOTTOM_CENTER].Cursor = Cursors.SizeNS;
     grippers[Gripper.POSITION_MIDDLE_LEFT].Cursor   = Cursors.SizeWE;
     if (parent != null)
     {
         parent.Controls.AddRange(grippers);                 // otherwise we'll attach them in switchParent
     }
 }
Example #7
0
		protected void InitGrippers() {
			
			_grippers = new Gripper[8];
			for(int i=0; i<_grippers.Length; i++) {
				_grippers[i] = new Gripper();
				_grippers[i].Position = i;
				_grippers[i].MouseDown += GripperMouseDown;
				_grippers[i].MouseUp += GripperMouseUp;
				_grippers[i].MouseMove += GripperMouseMove;
				_grippers[i].Visible = false;
				_grippers[i].Parent = _parent;
			}
			_grippers[Gripper.POSITION_TOP_CENTER].Cursor = Cursors.SizeNS;
			_grippers[Gripper.POSITION_MIDDLE_RIGHT].Cursor = Cursors.SizeWE;
			_grippers[Gripper.POSITION_BOTTOM_CENTER].Cursor = Cursors.SizeNS;
			_grippers[Gripper.POSITION_MIDDLE_LEFT].Cursor = Cursors.SizeWE;
			if (_parent != null) {
				_parent.Controls.AddRange(_grippers); // otherwise we'll attach them in switchParent
			}
		}
Example #8
0
		/// <summary>
		/// Initialize a target gripper
		/// </summary>
		protected void InitTargetGripper(Color gripperColor, Point location) {
			_targetGripper = new Gripper {
				Cursor = Cursors.SizeAll,
				BackColor = gripperColor,
				Visible = false,
				Parent = _parent,
				Location = location
			};
			_targetGripper.MouseDown += GripperMouseDown;
			_targetGripper.MouseUp += GripperMouseUp;
			_targetGripper.MouseMove += GripperMouseMove;
			if (_parent != null) {
				_parent.Controls.Add(_targetGripper); // otherwise we'll attach them in switchParent
			}
		}
 protected void InitGrippers()
 {
     grippers = new Gripper[8];
     for(int i=0; i<grippers.Length; i++) {
         grippers[i] = new Gripper();
         grippers[i].Position = i;
         grippers[i].MouseDown += new MouseEventHandler(gripperMouseDown);
         grippers[i].MouseUp += new MouseEventHandler(gripperMouseUp);
         grippers[i].MouseMove += new MouseEventHandler(gripperMouseMove);
         grippers[i].Visible = false;
         grippers[i].Parent = parent;
     }
     grippers[Gripper.POSITION_TOP_CENTER].Cursor = Cursors.SizeNS;
     grippers[Gripper.POSITION_MIDDLE_RIGHT].Cursor = Cursors.SizeWE;
     grippers[Gripper.POSITION_BOTTOM_CENTER].Cursor = Cursors.SizeNS;
     grippers[Gripper.POSITION_MIDDLE_LEFT].Cursor = Cursors.SizeWE;
     if (parent != null) {
         parent.Controls.AddRange(grippers); // otherwise we'll attach them in switchParent
     }
 }