Esempio n. 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (!LayoutSetting.IsEditMode)
            {
                return;
            }

            _startLoc = e.Location;
            if (MoveRec.Contains(e.X, e.Y))
            {
                MoveResizeAction = MoveResizeAction.Move;
            }
            else if (ResizeRec.Contains(e.X, e.Y))
            {
                var rec   = ResizeRec;
                int diffX = (rec.X + rec.Width) - _startLoc.X;
                int diffY = (rec.Y + rec.Height) - _startLoc.Y;
                _resizeDiffLoc   = new Point(diffX, diffY);
                MoveResizeAction = MoveResizeAction.ResizeBottomRight;
            }
            else
            {
                MoveResizeAction = MoveResizeAction.None;
            }
            OnMouseDownEventForEdit?.Invoke(this, e);
        }
Esempio n. 2
0
        public static Rectangle CalcBounds(MoveResizeAction type, Control control, Point startLoc, Point currentLoc)
        {
            var bounds = new Rectangle(control.Location.X, control.Location.Y, control.Width, control.Height);

            switch (type)
            {
            case MoveResizeAction.Move:
                bounds.X += currentLoc.X - startLoc.X;
                bounds.Y += currentLoc.Y - startLoc.Y;
                break;

            case MoveResizeAction.ResizeLeft:
                bounds.Width -= currentLoc.X - startLoc.X;
                bounds.X     += currentLoc.X - startLoc.X;
                break;

            case MoveResizeAction.ResizeTop:
                bounds.Height -= currentLoc.Y - startLoc.Y;
                bounds.Y      += currentLoc.Y - startLoc.Y;
                break;

            case MoveResizeAction.ResizeRight:
                bounds.Width = currentLoc.X;
                break;

            case MoveResizeAction.ResizeBottom:
                bounds.Height = currentLoc.Y;
                break;

            case MoveResizeAction.ResizeTopLeft:
                bounds.Height -= currentLoc.Y - startLoc.Y;
                bounds.Y      += currentLoc.Y - startLoc.Y;
                bounds.Width  -= currentLoc.X - startLoc.X;
                bounds.X      += currentLoc.X - startLoc.X;
                break;

            case MoveResizeAction.ResizeTopRight:
                bounds.Height -= currentLoc.Y - startLoc.Y;
                bounds.Y      += currentLoc.Y - startLoc.Y;
                bounds.Width   = currentLoc.X;
                break;

            case MoveResizeAction.ResizeBottomRight:
                bounds.Height = currentLoc.Y;
                bounds.Width  = currentLoc.X;
                break;

            case MoveResizeAction.ResizeBottomLeft:
                bounds.Height = currentLoc.Y;
                bounds.Width -= currentLoc.X - startLoc.X;
                bounds.X     += currentLoc.X - startLoc.X;
                break;
            }
            return(bounds);
        }
Esempio n. 3
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (!LayoutSetting.IsEditMode)
            {
                return;
            }

            MoveResizeAction = MoveResizeAction.None;
        }
Esempio n. 4
0
        public virtual MoveResizeAction Compose(Display <TData> display, MoveResizeAction action, bool isSelection)
        {
            action.HitSize       = display.HitSize;
            action.CameraHandler = this.Camera;
            action.CursorGetter  = this.DeviceCursor;

            if (isSelection)
            {
                action.SelectionRenderer = display.SelectionRenderer;
            }
            else
            {
                action.SelectionRenderer = display.MoveResizeRenderer;
            }

            action.SelectionRenderer.Enabled = action.Enabled;

            return(action);
        }