Ejemplo n.º 1
0
        private void AssociatedObject_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!IsResizable)
            {
                return;
            }

            if (_currentResizeGripDirection != ResizeGripDirection.None &&
                e.ChangedButton == MouseButton.Left)
            {
                _isResizing = true;
                var p = e.GetPosition(AssociatedObject);
                _initialDx = _initialDx = 0;
                switch (_currentResizeGripDirection)
                {
                case ResizeGripDirection.Right:
                    _initialDx = AssociatedObject.ActualWidth - p.X;
                    break;

                case ResizeGripDirection.Left:
                    _initialDx = -p.X;
                    break;

                case ResizeGripDirection.Top:
                    _initialDy = -p.Y;
                    break;

                case ResizeGripDirection.Bottom:
                    _initialDy = AssociatedObject.ActualHeight - p.Y;
                    break;

                case ResizeGripDirection.TopRight:
                    _initialDx = AssociatedObject.ActualWidth - p.X;
                    _initialDy = -p.Y;
                    break;

                case ResizeGripDirection.BottomRight:
                    _initialDx = AssociatedObject.ActualWidth - p.X;
                    _initialDy = AssociatedObject.ActualHeight - p.Y;
                    break;

                case ResizeGripDirection.BottomLeft:
                    _initialDy = AssociatedObject.ActualHeight - p.Y;
                    _initialDx = -p.X;
                    break;

                case ResizeGripDirection.TopLeft:
                    _initialDy = -p.Y;
                    _initialDx = -p.X;
                    break;
                }
                DockablePanelWindowBehavior.DisableDockBehavior(AssociatedObject);
                Mouse.Capture(AssociatedObject);
#if alldbg || dbg
                DesktopPanelTool.Lib.Debug.WriteLine($"is resizing dx={InitialDx},dy={InitialDy} x={p.X},y={p.Y} (rgd={CurrentResizeGripDirection})");
#endif
            }
        }
Ejemplo n.º 2
0
        private void AssociatedObject_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                _currentResizeGripDirection = ResizeGripDirection.None;
                if (_isResizing)
                {
                    _isResizing       = false;
                    _lastDragMoveTime = DateTime.Now;
                    Mouse.Capture(null);
                    AssociatedObject.Cursor = CursorDefault;
                    DockablePanelWindowBehavior.EnableDockBehavior(AssociatedObject);
#if alldbg || dbg
                    DesktopPanelTool.Lib.Debug.WriteLine($"not resizing");
#endif
                }
            }
        }