Example #1
0
        internal ContentWindow(TabberItem item, Rect rect, bool firstDrag = false)
        {
            inDrag         = false;
            iniRect        = rect;
            this.firstDrag = firstDrag;
            (item.Parent as TabberControl).Items.Remove(item);
            tabberControl = new TabberControl();
            tabberControl.Items.Add(item);
            Content = tabberControl;
            if (firstDrag)
            {
                WindowStyle        = WindowStyle.None;
                AllowsTransparency = true;
                background         = Background;
                Background         = Brushes.Transparent;
                Top = rect.Y;
            }
            else
            {
                Top = rect.Y - SystemParameters.WindowCaptionHeight;
                Top = Top < 0 ? 0 : Top;
            }
            Left   = rect.X;
            Width  = rect.Width;
            Height = rect.Height;

            Check           += ContentWindow_Check;
            Closed          += ContentWindow_Closed;
            LocationChanged += ContentWindow_LocationChanged;
        }
Example #2
0
 public void Close()
 {
     if (CanClosing())
     {
         TabberControl tabberControl = (Parent as TabberControl);
         tabberControl.Items.Remove(this);
         if (tabberControl.Items.Count < 1)
         {
             Window.GetWindow(this).Close();
         }
     }
 }
Example #3
0
        private void TabberItem_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed && dragTabAndWindow)
            {
                Window        currentWindow = Window.GetWindow(this);
                TabberControl tabberControl = (TabberControl)Parent;
                if (!((currentWindow as ContentWindow) == null &&
                      tabberControl.Items.Count < 2 &&
                      tabberControl.Pinned))
                {
                    Point innerMousePosition = Mouse.GetPosition(this);

                    if (moveEnter)
                    {
                        if (tabberControl.TabStripPlacement == Dock.Top || tabberControl.TabStripPlacement == Dock.Bottom)
                        {
                            #region Drag Section
                            if (((innerMousePosition.Y <= 0 || innerMousePosition.Y >= ActualHeight) &&
                                 (innerMousePosition.X > 0 && innerMousePosition.X < ActualWidth)) ||
                                (tabberControl.Items[0].Equals(this) && innerMousePosition.X <= 0) ||
                                (tabberControl.Items[tabberControl.Items.Count - 1].Equals(this) && innerMousePosition.X >= ActualWidth))
                            {
                                if (IsMouseCaptured)
                                {
                                    Mouse.Capture(null);
                                }

                                DragPressed?.Invoke(this, new EventArgs());
                                Point dragPosition = this.PointToScreen(innerMousePosition);
                                Pin    = false;
                                window = new ContentWindow(
                                    this,
                                    new Rect(
                                        dragPosition.X + (-ActualWidth / 2),
                                        dragPosition.Y + (-ActualHeight / 2),
                                        currentWindow.ActualWidth,
                                        currentWindow.ActualHeight),
                                    true);
                                dragTabAndWindow = false;
                                inDragMove       = true;
                                window.DragMove();
                                DragReleased?.Invoke(this, new EventArgs());
                            }
                            #endregion
                            #region Swap Section
                            else if (!tabberControl.Items[0].Equals(this) && innerMousePosition.X <= 0)
                            {
                                int        index    = tabberControl.Items.IndexOf(this);
                                TabberItem swapItem = (TabberItem)tabberControl.Items[index - 1];
                                if (swapItem.Pin == Pin)
                                {
                                    tabberControl.Items.Remove(swapItem);
                                    tabberControl.Items.Insert(index, swapItem);
                                }
                            }
                            else if (!tabberControl.Items[tabberControl.Items.Count - 1].Equals(this) && innerMousePosition.X >= ActualWidth)
                            {
                                int        index    = tabberControl.Items.IndexOf(this);
                                TabberItem swapItem = (TabberItem)tabberControl.Items[index + 1];
                                if (swapItem.Pin == Pin)
                                {
                                    tabberControl.Items.Remove(swapItem);
                                    tabberControl.Items.Insert(index, swapItem);
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            #region Drag Section
                            if (((innerMousePosition.X <= 0 || innerMousePosition.X >= ActualWidth) &&
                                 (innerMousePosition.Y > 0 && innerMousePosition.Y < ActualHeight)) ||
                                (tabberControl.Items[0].Equals(this) && innerMousePosition.Y <= 0) ||
                                (tabberControl.Items[tabberControl.Items.Count - 1].Equals(this) && innerMousePosition.Y >= ActualHeight))
                            {
                                if (IsMouseCaptured)
                                {
                                    Mouse.Capture(null);
                                }

                                DragPressed?.Invoke(this, new EventArgs());
                                Point dragPosition = this.PointToScreen(innerMousePosition);
                                Pin    = false;
                                window = new ContentWindow(
                                    this,
                                    new Rect(
                                        dragPosition.X + (-ActualWidth / 2),
                                        dragPosition.Y + (-ActualHeight / 2),
                                        currentWindow.ActualWidth,
                                        currentWindow.ActualHeight),
                                    true);
                                dragTabAndWindow = false;
                                inDragMove       = true;
                                window.DragMove();
                                DragReleased?.Invoke(this, new EventArgs());
                            }
                            #endregion
                            #region Swap Section
                            else if (!tabberControl.Items[0].Equals(this) && innerMousePosition.Y <= 0)
                            {
                                int        index    = tabberControl.Items.IndexOf(this);
                                TabberItem swapItem = (TabberItem)tabberControl.Items[index - 1];
                                if (swapItem.Pin == Pin)
                                {
                                    tabberControl.Items.Remove(swapItem);
                                    tabberControl.Items.Insert(index, swapItem);
                                }
                            }
                            else if (!tabberControl.Items[tabberControl.Items.Count - 1].Equals(this) && innerMousePosition.Y >= ActualHeight)
                            {
                                int        index    = tabberControl.Items.IndexOf(this);
                                TabberItem swapItem = (TabberItem)tabberControl.Items[index + 1];
                                if (swapItem.Pin == Pin)
                                {
                                    tabberControl.Items.Remove(swapItem);
                                    tabberControl.Items.Insert(index, swapItem);
                                }
                            }
                            #endregion
                        }
                    }
                    moveEnter = TabItemLocalRect().Contains(Mouse.GetPosition(this));
                }
            }
            else if (e.LeftButton == MouseButtonState.Released)
            {
                if (IsMouseCaptured && !inDragMove)
                {
                    Mouse.Capture(null);
                }
            }
        }