Beispiel #1
0
        void OnListBoxItemLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ReleaseCapturedItem();

            var item = sender as ListBoxItem;

            if (item != null)
            {
                var creator = item.Content as AffinitizedViewCreator;

                if (creator != null)
                {
                    if (creator.Category != null && creator.Category.DocumentFactoryName != null)
                    {
                        // Make sure the selected document category matches the category of the clicked-on item.  Note
                        // that we do NOT do this for the "Any" category, since those views may be placed on any layout,
                        // not just the non-affinitized layouts.
                        this.SelectedDocumentCategory = creator.Category;
                    }

                    this.creatorBeingDragged = creator;
                }

                e.MouseDevice.Capture(item);
                this.capturedItem       = item;
                this.dragStart          = e.GetPosition(this);
                this.originalScreenPos  = this.capturedItem.PointToScreenIndependent(new Point(0, 0));
                this.dragGhostWindow    = null;
                item.Cursor             = Cursors.SizeAll;
                item.MouseMove         += OnListBoxItemMouseMove;
                item.MouseLeftButtonUp += OnListBoxItemLeftButtonUp;
                item.LostMouseCapture  += OnListBoxItemLostCapture;

                this.dragGhostWindow = new ViewDragGhostWindow
                {
                    ViewName = ((AffinitizedViewCreator)item.Content).Command.DisplayName,
                };

                this.dragGhostWindow.Show();
                UpdateHitState(this.originalScreenPos);
                e.Handled = true;
            }
        }
Beispiel #2
0
        void ReleaseCapturedItem()
        {
            if (this.capturedItem != null)
            {
                this.capturedItem.Cursor             = null;
                this.capturedItem.MouseMove         -= OnListBoxItemMouseMove;
                this.capturedItem.MouseLeftButtonUp -= OnListBoxItemLeftButtonUp;
                this.capturedItem.LostMouseCapture  -= OnListBoxItemLostCapture;
                this.capturedItem        = null;
                this.creatorBeingDragged = null;

                if (this.dragGhostWindow != null)
                {
                    this.dragGhostWindow.Close();
                    this.dragGhostWindow = null;
                }

                if (this.dockTargetWindow != null)
                {
                    this.dockTargetWindow.Close();
                    this.dockTargetWindow = null;
                }
            }
        }
        void ReleaseCapturedItem()
        {
            if (this.capturedItem != null)
            {
                this.capturedItem.Cursor = null;
                this.capturedItem.MouseMove -= OnListBoxItemMouseMove;
                this.capturedItem.MouseLeftButtonUp -= OnListBoxItemLeftButtonUp;
                this.capturedItem.LostMouseCapture -= OnListBoxItemLostCapture;
                this.capturedItem = null;
                this.creatorBeingDragged = null;

                if (this.dragGhostWindow != null)
                {
                    this.dragGhostWindow.Close();
                    this.dragGhostWindow = null;
                }

                if (this.dockTargetWindow != null)
                {
                    this.dockTargetWindow.Close();
                    this.dockTargetWindow = null;
                }
            }
        }
        void OnListBoxItemLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ReleaseCapturedItem();

            var item = sender as ListBoxItem;

            if (item != null)
            {
                var creator = item.Content as AffinitizedViewCreator;

                if (creator != null)
                {
                    if (creator.Category != null && creator.Category.DocumentFactoryName != null)
                    {
                        // Make sure the selected document category matches the category of the clicked-on item.  Note
                        // that we do NOT do this for the "Any" category, since those views may be placed on any layout,
                        // not just the non-affinitized layouts.
                        this.SelectedDocumentCategory = creator.Category;
                    }

                    this.creatorBeingDragged = creator;
                }

                e.MouseDevice.Capture(item);
                this.capturedItem = item;
                this.dragStart = e.GetPosition(this);
                this.originalScreenPos = this.capturedItem.PointToScreenIndependent(new Point(0, 0));
                this.dragGhostWindow = null;
                item.Cursor = Cursors.SizeAll;
                item.MouseMove += OnListBoxItemMouseMove;
                item.MouseLeftButtonUp += OnListBoxItemLeftButtonUp;
                item.LostMouseCapture += OnListBoxItemLostCapture;

                this.dragGhostWindow = new ViewDragGhostWindow
                {
                    ViewName = ((AffinitizedViewCreator)item.Content).Command.DisplayName,
                };

                this.dragGhostWindow.Show();
                UpdateHitState(this.originalScreenPos);
                e.Handled = true;
            }
        }