protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            _isMouseDown  = true;
            _draggingItem = this;
        }
        protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (e.LeftButton != MouseButtonState.Pressed)
            {
                _isMouseDown  = false;
                _draggingItem = null;
            }
        }
        protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (_isMouseDown && e.LeftButton == MouseButtonState.Pressed)
            {
                _draggingItem = this;
            }

            _isMouseDown = false;
        }
        protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed &&
                LayoutAnchorableTabItem.IsDraggingItem())
            {
                var contentModel = LayoutAnchorableTabItem.GetDraggingItem().Model as LayoutAnchorable;
                var manager      = contentModel.Root.Manager;
                LayoutAnchorableTabItem.ResetDraggingItem();

                manager.StartDraggingFloatingWindowForContent(contentModel);
            }

            base.OnMouseLeave(e);
        }
        protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (_isMouseDown && e.LeftButton == MouseButtonState.Pressed)
            {
                // drag the item if the mouse leave is not canceled.
                // Mouse leave should be canceled when selecting a new tab to prevent automatic undock when Panel size is Auto.
                _draggingItem = !_cancelMouseLeave ? this : null;
            }

            _isMouseDown      = false;
            _cancelMouseLeave = false;
        }
示例#6
0
        /// <inheritdoc cref="IOverlayWindow"/>
        IEnumerable <IDropTarget> IOverlayWindow.GetTargets()
        {
            foreach (var visibleArea in _visibleAreas)
            {
                switch (visibleArea.Type)
                {
                case DropAreaType.DockingManager:
                {
                    // Dragging over DockingManager -> Add DropTarget Area
                    var dropAreaDockingManager = visibleArea as DropArea <DockingManager>;
                    yield return(new DockingManagerDropTarget(dropAreaDockingManager.AreaElement, _dockingManagerDropTargetLeft.GetScreenArea(), DropTargetType.DockingManagerDockLeft));

                    yield return(new DockingManagerDropTarget(dropAreaDockingManager.AreaElement, _dockingManagerDropTargetTop.GetScreenArea(), DropTargetType.DockingManagerDockTop));

                    yield return(new DockingManagerDropTarget(dropAreaDockingManager.AreaElement, _dockingManagerDropTargetBottom.GetScreenArea(), DropTargetType.DockingManagerDockBottom));

                    yield return(new DockingManagerDropTarget(dropAreaDockingManager.AreaElement, _dockingManagerDropTargetRight.GetScreenArea(), DropTargetType.DockingManagerDockRight));
                }
                break;

                case DropAreaType.AnchorablePane:
                {
                    // Dragging over AnchorablePane -> Add DropTarget Area
                    var dropAreaAnchorablePane = visibleArea as DropArea <LayoutAnchorablePaneControl>;
                    yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetLeft.GetScreenArea(), DropTargetType.AnchorablePaneDockLeft));

                    yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetTop.GetScreenArea(), DropTargetType.AnchorablePaneDockTop));

                    yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetRight.GetScreenArea(), DropTargetType.AnchorablePaneDockRight));

                    yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetBottom.GetScreenArea(), DropTargetType.AnchorablePaneDockBottom));

                    if (_anchorablePaneDropTargetInto.IsVisible)
                    {
                        yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetInto.GetScreenArea(), DropTargetType.AnchorablePaneDockInside));
                    }

                    var parentPaneModel = dropAreaAnchorablePane.AreaElement.Model as LayoutAnchorablePane;
                    LayoutAnchorableTabItem lastAreaTabItem = null;
                    foreach (var dropAreaTabItem in dropAreaAnchorablePane.AreaElement.FindVisualChildren <LayoutAnchorableTabItem>())
                    {
                        var tabItemModel = dropAreaTabItem.Model as LayoutAnchorable;
                        lastAreaTabItem = lastAreaTabItem == null || lastAreaTabItem.GetScreenArea().Right < dropAreaTabItem.GetScreenArea().Right ?
                                          dropAreaTabItem : lastAreaTabItem;
                        int tabIndex = parentPaneModel.Children.IndexOf(tabItemModel);
                        yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, dropAreaTabItem.GetScreenArea(), DropTargetType.AnchorablePaneDockInside, tabIndex));
                    }

                    if (lastAreaTabItem != null)
                    {
                        var lastAreaTabItemScreenArea = lastAreaTabItem.GetScreenArea();
                        var newAreaTabItemScreenArea  = new Rect(lastAreaTabItemScreenArea.TopRight, new Point(lastAreaTabItemScreenArea.Right + lastAreaTabItemScreenArea.Width, lastAreaTabItemScreenArea.Bottom));
                        if (newAreaTabItemScreenArea.Right < dropAreaAnchorablePane.AreaElement.GetScreenArea().Right)
                        {
                            yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, newAreaTabItemScreenArea, DropTargetType.AnchorablePaneDockInside, parentPaneModel.Children.Count));
                        }
                    }

                    var dropAreaTitle = dropAreaAnchorablePane.AreaElement.FindVisualChildren <AnchorablePaneTitle>().FirstOrDefault();
                    if (dropAreaTitle != null)
                    {
                        yield return(new AnchorablePaneDropTarget(dropAreaAnchorablePane.AreaElement, dropAreaTitle.GetScreenArea(), DropTargetType.AnchorablePaneDockInside));
                    }
                }
                break;

                case DropAreaType.DocumentPane:
                {
                    // Dragging over DocumentPane -> Add DropTarget Area
                    bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow;
                    if (isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null)
                    {
                        // Item dragged is a layout anchorable over the DockingManager's DocumentPane
                        // -> Yield a drop target structure with 9 buttons
                        var dropAreaDocumentPane = visibleArea as DropArea <LayoutDocumentPaneControl>;
                        if (_documentPaneFullDropTargetLeft.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetLeft.GetScreenArea(), DropTargetType.DocumentPaneDockLeft));
                        }
                        if (_documentPaneFullDropTargetTop.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetTop.GetScreenArea(), DropTargetType.DocumentPaneDockTop));
                        }
                        if (_documentPaneFullDropTargetRight.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetRight.GetScreenArea(), DropTargetType.DocumentPaneDockRight));
                        }
                        if (_documentPaneFullDropTargetBottom.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetBottom.GetScreenArea(), DropTargetType.DocumentPaneDockBottom));
                        }
                        if (_documentPaneFullDropTargetInto.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetInto.GetScreenArea(), DropTargetType.DocumentPaneDockInside));
                        }

                        var parentPaneModel = dropAreaDocumentPane.AreaElement.Model as LayoutDocumentPane;
                        LayoutDocumentTabItem lastAreaTabItem = null;
                        foreach (var dropAreaTabItem in dropAreaDocumentPane.AreaElement.FindVisualChildren <LayoutDocumentTabItem>())
                        {
                            var tabItemModel = dropAreaTabItem.Model;
                            lastAreaTabItem = lastAreaTabItem == null || lastAreaTabItem.GetScreenArea().Right < dropAreaTabItem.GetScreenArea().Right ?
                                              dropAreaTabItem : lastAreaTabItem;
                            int tabIndex = parentPaneModel.Children.IndexOf(tabItemModel);
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, dropAreaTabItem.GetScreenArea(), DropTargetType.DocumentPaneDockInside, tabIndex));
                        }

                        if (lastAreaTabItem != null)
                        {
                            var lastAreaTabItemScreenArea = lastAreaTabItem.GetScreenArea();
                            var newAreaTabItemScreenArea  = new Rect(lastAreaTabItemScreenArea.TopRight, new Point(lastAreaTabItemScreenArea.Right + lastAreaTabItemScreenArea.Width, lastAreaTabItemScreenArea.Bottom));
                            if (newAreaTabItemScreenArea.Right < dropAreaDocumentPane.AreaElement.GetScreenArea().Right)
                            {
                                yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, newAreaTabItemScreenArea, DropTargetType.DocumentPaneDockInside, parentPaneModel.Children.Count));
                            }
                        }

                        if (_documentPaneDropTargetLeftAsAnchorablePane.IsVisible)
                        {
                            yield return(new DocumentPaneDropAsAnchorableTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetLeftAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableLeft));
                        }
                        if (_documentPaneDropTargetTopAsAnchorablePane.IsVisible)
                        {
                            yield return(new DocumentPaneDropAsAnchorableTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetTopAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableTop));
                        }
                        if (_documentPaneDropTargetRightAsAnchorablePane.IsVisible)
                        {
                            yield return(new DocumentPaneDropAsAnchorableTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetRightAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableRight));
                        }
                        if (_documentPaneDropTargetBottomAsAnchorablePane.IsVisible)
                        {
                            yield return(new DocumentPaneDropAsAnchorableTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetBottomAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableBottom));
                        }
                    }
                    else
                    {
                        // Item being dragged is a document over the DockingManager's DocumentPane
                        // -> Yield a drop target structure with 5 center buttons over the document
                        var dropAreaDocumentPane = visibleArea as DropArea <LayoutDocumentPaneControl>;
                        if (_documentPaneDropTargetLeft.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetLeft.GetScreenArea(), DropTargetType.DocumentPaneDockLeft));
                        }
                        if (_documentPaneDropTargetTop.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetTop.GetScreenArea(), DropTargetType.DocumentPaneDockTop));
                        }
                        if (_documentPaneDropTargetRight.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetRight.GetScreenArea(), DropTargetType.DocumentPaneDockRight));
                        }
                        if (_documentPaneDropTargetBottom.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetBottom.GetScreenArea(), DropTargetType.DocumentPaneDockBottom));
                        }
                        if (_documentPaneDropTargetInto.IsVisible)
                        {
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetInto.GetScreenArea(), DropTargetType.DocumentPaneDockInside));
                        }

                        var parentPaneModel = dropAreaDocumentPane.AreaElement.Model as LayoutDocumentPane;
                        LayoutDocumentTabItem lastAreaTabItem = null;
                        foreach (var dropAreaTabItem in dropAreaDocumentPane.AreaElement.FindVisualChildren <LayoutDocumentTabItem>())
                        {
                            var tabItemModel = dropAreaTabItem.Model;
                            lastAreaTabItem = lastAreaTabItem == null || lastAreaTabItem.GetScreenArea().Right < dropAreaTabItem.GetScreenArea().Right ?
                                              dropAreaTabItem : lastAreaTabItem;
                            int tabIndex = parentPaneModel.Children.IndexOf(tabItemModel);
                            yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, dropAreaTabItem.GetScreenArea(), DropTargetType.DocumentPaneDockInside, tabIndex));
                        }

                        if (lastAreaTabItem != null)
                        {
                            var lastAreaTabItemScreenArea = lastAreaTabItem.GetScreenArea();
                            var newAreaTabItemScreenArea  = new Rect(lastAreaTabItemScreenArea.TopRight, new Point(lastAreaTabItemScreenArea.Right + lastAreaTabItemScreenArea.Width, lastAreaTabItemScreenArea.Bottom));
                            if (newAreaTabItemScreenArea.Right < dropAreaDocumentPane.AreaElement.GetScreenArea().Right)
                            {
                                yield return(new DocumentPaneDropTarget(dropAreaDocumentPane.AreaElement, newAreaTabItemScreenArea, DropTargetType.DocumentPaneDockInside, parentPaneModel.Children.Count));
                            }
                        }
                    }
                }
                break;

                case DropAreaType.DocumentPaneGroup:
                {
                    // Dragging over DocumentPaneGroup -> Add DropTarget Area
                    var dropAreaDocumentPane = visibleArea as DropArea <LayoutDocumentPaneGroupControl>;
                    if (_documentPaneDropTargetInto.IsVisible)
                    {
                        yield return(new DocumentPaneGroupDropTarget(dropAreaDocumentPane.AreaElement, _documentPaneDropTargetInto.GetScreenArea(), DropTargetType.DocumentPaneGroupDockInside));
                    }
                }
                break;
                }
            }
            yield break;
        }
        protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (e.LeftButton != MouseButtonState.Pressed)
            {
                _isMouseDown = false;
                _draggingItem = null;
            }
        }
        protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            _isMouseDown = true;
            _draggingItem = this;
        }
        protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (_isMouseDown && e.LeftButton == MouseButtonState.Pressed)
            {
                _draggingItem = this;
            }

            _isMouseDown = false;
        }
 internal static void ResetDraggingItem()
 {
     _draggingItem = null;
 }
 internal static void ResetDraggingItem()
 {
     _draggingItem = null;
 }