コード例 #1
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();
        }
コード例 #2
0
        /// <summary>
        ///     Handle the mouse move
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
        {
            if (EditStatus != EditStatus.RESIZING)
            {
                return;
            }
            Owner.Invalidate();
            Owner.MakeBoundsChangeUndoable(false);

            // reset "workbench" rectangle to current bounds
            _boundsAfterResize = _boundsBeforeResize;

            // calculate scaled rectangle
            ScaleHelper.Scale(ref _boundsAfterResize, Position, new NativePointFloat(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());

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

            Owner.Invalidate();
        }