예제 #1
0
        private void OnPreviewMouseMoveWhileCaptured(object sender, MouseEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                if (!((Mouse.Captured is ComboBox && ((ComboBox)Mouse.Captured).IsDropDownOpen)))                 //Combo boxes require non-pressed capture behaviour while popped up to work properly.
                {
                    if (Mouse.Captured != null)
                    {
                        Mouse.Captured.ReleaseMouseCapture();
                    }

                    OnLostMouseCapture(e);
                }
            }
            else
            {
                //Shift the mouse with the panel being moved, so that the resize remains relative to it.
                ArtPanel panel = GetArtPanel(e.OriginalSource);
                if (panel != null)
                {
                    panel.BringIntoView();                     //Ensure the panel remains in view
                    Point  newOffset   = panel.TranslatePoint(new Point(), this);
                    Vector offsetDelta = newOffset - mPanelResizeDragOffset;
                    if (offsetDelta.Length > 1)
                    {
                        MoveMousePosition(offsetDelta);
                        mPanelResizeDragOffset = newOffset;
                        e.Handled = true;
                    }
                }
            }
        }
예제 #2
0
        protected override void OnGotMouseCapture(MouseEventArgs e)
        {
            base.OnGotMouseCapture(e);

            Suspended = true;

            ArtPanel panel = GetArtPanel(e.OriginalSource);

            if (panel != null)
            {
                mPanelResizeDragOffset = panel.TranslatePoint(new Point(), this);
                PreviewMouseMove      += OnPreviewMouseMoveWhileCaptured;
            }
        }