Example #1
0
        protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseMove(e);
            try
            {
                if (_isMouseDown)
                {
                    Point ptMouseMove = e.GetPosition(this);

                    if (Math.Abs(ptMouseMove.X - _mouseDownPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
                        Math.Abs(ptMouseMove.Y - _mouseDownPoint.Y) > SystemParameters.MinimumVerticalDragDistance)
                    {
                        UpdateDragDetails();
                        CaptureMouse();
                        _isMouseDown = false;
                    }
                }

                if (IsMouseCaptured)
                {
                    var mousePosInScreenCoord = this.PointToScreenDPI(e.GetPosition(this));
                    if (!_parentDocumentTabPanelScreenArea.Contains(mousePosInScreenCoord))
                    {
                        ReleaseMouseCapture();
                        //var manager = Model.Root.Manager;
                        //manager.StartDraggingFloatingWindowForContent(Model);
                    }
                    else
                    {
                        if (_otherTabsScreenArea == null || _otherTabsScreenArea.Count <= 0)
                        {
                            return;
                        }

                        int indexOfTabItemWithMouseOver = _otherTabsScreenArea.FindIndex(r => r.Contains(mousePosInScreenCoord));
                        if (indexOfTabItemWithMouseOver >= 0)
                        {
                            var targetModel   = _otherTabs[indexOfTabItemWithMouseOver].Content as LayoutContent;
                            var container     = Model.Parent as ILayoutContainer;
                            var containerPane = Model.Parent as ILayoutPane;
                            if (targetModel != null && container != null && containerPane != null &&
                                container.Children != null && _parentDocumentTabPanel != null)
                            {
                                var childrenList = container.Children.ToList();
                                containerPane.MoveChild(childrenList.IndexOf(Model), childrenList.IndexOf(targetModel));
                                Model.IsActive = true;
                                _parentDocumentTabPanel.UpdateLayout();
                                UpdateDragDetails();
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
        protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (_isMouseDown)
            {
                Point ptMouseMove = e.GetPosition(this);
                this.CaptureMouse();
                if (Math.Abs(ptMouseMove.X - _mouseDownPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(ptMouseMove.Y - _mouseDownPoint.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    this.UpdateDragDetails();

                    _isMouseDown = false;
                    _allowDrag   = true;
                }
            }

            if (this.IsMouseCaptured && _allowDrag)
            {
                var mousePosInScreenCoord = this.PointToScreenDPI(e.GetPosition(this));
                if (!_parentDocumentTabPanelScreenArea.Contains(mousePosInScreenCoord))
                {
                    this.StartDraggingFloatingWindowForContent();
                }
                else
                {
                    int indexOfTabItemWithMouseOver = _otherTabsScreenArea.FindIndex(r => r.Contains(mousePosInScreenCoord));
                    if (indexOfTabItemWithMouseOver >= 0)
                    {
                        var targetModel   = _otherTabs[indexOfTabItemWithMouseOver].Content as LayoutContent;
                        var container     = this.Model.Parent as ILayoutContainer;
                        var containerPane = this.Model.Parent as ILayoutPane;

                        if ((containerPane is LayoutDocumentPane) && !(( LayoutDocumentPane )containerPane).CanRepositionItems)
                        {
                            return;
                        }
                        if ((containerPane.Parent != null) && (containerPane.Parent is LayoutDocumentPaneGroup) && !(( LayoutDocumentPaneGroup )containerPane.Parent).CanRepositionItems)
                        {
                            return;
                        }

                        var childrenList = container.Children.ToList();
                        containerPane.MoveChild(childrenList.IndexOf(Model), childrenList.IndexOf(targetModel));
                        this.Model.IsActive = true;
                        _parentDocumentTabPanel.UpdateLayout();
                        this.UpdateDragDetails();
                    }
                }
            }
        }
        protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseMove(e);

            var ptMouseMove = e.GetPosition(this);

            if (_isMouseDown)
            {
                if (Math.Abs(ptMouseMove.X - _mouseDownPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(ptMouseMove.Y - _mouseDownPoint.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    this.UpdateDragDetails();
                    this.CaptureMouse();
                    _isMouseDown = false;
                }
            }

            if (this.IsMouseCaptured)
            {
                var mousePosInScreenCoord = this.PointToScreenDPI(ptMouseMove);

                if (!_parentDocumentTabPanelScreenArea.Contains(mousePosInScreenCoord))
                {
                    this.StartDraggingFloatingWindowForContent();
                }
                else
                {
                    int indexOfTabItemWithMouseOver = _otherTabsScreenArea.FindIndex(r => r.Contains(mousePosInScreenCoord));
                    if (indexOfTabItemWithMouseOver >= 0)
                    {
                        var targetModel          = _otherTabs[indexOfTabItemWithMouseOver].Content as LayoutContent;
                        var container            = this.Model.Parent as ILayoutContainer;
                        var containerPane        = this.Model.Parent as ILayoutPane;
                        var currentTabScreenArea = this.FindLogicalAncestor <TabItem>().GetScreenArea();

                        // Inside current TabItem, do not care about _mouseLastChangePosition for next change position.
                        if (targetModel == this.Model)
                        {
                            _mouseLastChangePositionX = currentTabScreenArea.Left + (currentTabScreenArea.Width / 2);
                        }

                        if ((containerPane is LayoutDocumentPane) && !((LayoutDocumentPane)containerPane).CanRepositionItems)
                        {
                            return;
                        }
                        if ((containerPane.Parent != null) && (containerPane.Parent is LayoutDocumentPaneGroup) && !((LayoutDocumentPaneGroup)containerPane.Parent).CanRepositionItems)
                        {
                            return;
                        }

                        var childrenList = container.Children.ToList();
                        var currentIndex = childrenList.IndexOf(this.Model);
                        var newIndex     = childrenList.IndexOf(targetModel);

                        if (currentIndex != newIndex)
                        {
                            // Moving left when cursor leave tabItem or moving left past last change position.
                            // Or, moving right cursor leave tabItem or moving right past last change position.
                            if (((mousePosInScreenCoord.X < currentTabScreenArea.Left) && (mousePosInScreenCoord.X < _mouseLastChangePositionX)) ||
                                ((mousePosInScreenCoord.X > (currentTabScreenArea.Left + currentTabScreenArea.Width)) && (mousePosInScreenCoord.X > _mouseLastChangePositionX)))
                            {
                                containerPane.MoveChild(currentIndex, newIndex);
                                _dragBuffer         = MaxDragBuffer;
                                this.Model.IsActive = true;
                                _parentDocumentTabPanel.UpdateLayout();
                                this.UpdateDragDetails();
                                _mouseLastChangePositionX = mousePosInScreenCoord.X;
                            }
                        }
                    }
                }
            }
        }