Exemple #1
0
        void DragWindow_Evt_MoveWindow(object obj, object header, Point startPoint)
        {
            _curMoveWindow = new DockingWindowElement(header, obj, parentWin, startPoint);

            //修改弹出框名称
            _curMoveWindow.CreateDragWindow("测试", false, parentWin);
            _curMoveWindow.DragWindow.MouseLeave     += DragWindow_MouseLeave;
            _curMoveWindow.DragWindow.Evt_MoveWindow += DragWindow_Evt_MoveWindow;
            _tbPanel.CaptureMouse();
            moveNewWindow = true;
        }
Exemple #2
0
        void DockingTabControl_MouseMove(object sender, MouseEventArgs e)
        {
            var a = e.Source as TabItem;
            var b = e.GetPosition(a);
            var c = e.GetPosition(this);
            var d = PointToScreen(c);

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (moveNewWindow)
                {
                    //更新窗口位置
                    _curMoveWindow.UpdateWindowLocation(d);

                    //判断是否拖入TabPanel
                    if ((c.X >= _tabPanelEmt.TabPanelStartPoint.X && c.X <= _tabPanelEmt.TabPanelStartPoint.X + _tabPanelEmt.TabPanelSize.Width) &&
                        (c.Y >= _tabPanelEmt.TabPanelStartPoint.Y && c.Y <= _tabPanelEmt.TabPanelStartPoint.Y + _tabPanelEmt.TabPanelSize.Height))
                    {
                        if (!this.Items.Contains(_curMoveWindow.DragTargetHeader))
                        {
                            //拖进来
                            this.Items.Add(_curMoveWindow.DragTargetHeader);
                        }
                    }
                    else
                    {
                        //拖出去
                        if (this.Items.Contains(_curMoveWindow.DragTargetHeader))
                        {
                            this.Items.Remove(_curMoveWindow.DragTargetHeader);
                        }
                    }
                }
                else
                {
                    if (_isBtnDown && a != null)
                    {
                        if (_curMoveWindow != null)
                        {
                            //更新窗口位置
                            _curMoveWindow.UpdateWindowLocation(d);
                        }
                        if ((b.X < 0 || b.Y < 0 || b.X > a.ActualWidth || b.Y > a.ActualHeight) && _curMoveWindow == null)
                        {
                            _curMoveWindow = new DockingWindowElement(a, a.Content, parentWin, d);
                            _curMoveWindow.CreateDragWindow(a.Header.ToString(), true, parentWin);
                            _curMoveWindow.DragWindow.Evt_MoveWindow += DragWindow_Evt_MoveWindow;
                            _curMoveWindow.DragWindow.MouseLeave     += DragWindow_MouseLeave;
                            a.Opacity = 0.4;
                        }
                    }
                }
            }
        }