Example #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;
                    }
                }
            }
        }
Example #2
0
        protected override void OnLostMouseCapture(MouseEventArgs e)
        {
            base.OnLostMouseCapture(e);
            PreviewMouseMove -= OnPreviewMouseMoveWhileCaptured;

            Suspended = false;

            ArtPanel panel = GetArtPanel(e.OriginalSource);

            if (panel != null)
            {
                if (panel.Parent == null)
                {
                    //The panel has been removed (probably due to image size changed), so find the new panel for that album art, and bring that into view instead
                    ContentPresenter contentPresenter = ItemContainerGenerator.ContainerFromItem(panel.AlbumArt) as ContentPresenter;
                    if (contentPresenter != null)
                    {
                        contentPresenter.BringIntoView();
                    }
                }
                else
                {
                    panel.BringIntoView();                     //Ensure the panel remains in view
                }
            }
        }