Exemple #1
0
        internal void Over(ContentWindow window)
        {
            if (object.ReferenceEquals(window, currentWindow))
            {
                return;
            }

            if (mainTabberIsEmpty)
            {
                if (shadowItem != null)
                {
                    ZOrders.OrderFound();
                    int dropItemIndex = Items.IndexOf(shadowItem);
                    Items.Remove(shadowItem);
                    TabberItem replacedItem = window.ReplaceItem();
                    InsertTab(dropItemIndex, replacedItem);
                    currentWindow.Activate();
                }
            }
            else
            {
                if (shadowItem != null)
                {
                    ZOrders.OrderFound();
                    int dropItemIndex = Items.IndexOf(shadowItem);
                    Items.Remove(shadowItem);
                    TabberItem replacedItem = window.ReplaceItem();
                    InsertTab(dropItemIndex, replacedItem);
                    currentWindow.Activate();
                }
            }
        }
Exemple #2
0
 private void FocusOrderWindow(ContentWindow window)
 {
     ZOrders.OrderFound();
     if (!ZOrders.IsBackOfFront(window.GetTabberControl(), this))
     {
         ZOrders.ActiveReorder(window.GetTabberControl(), this);
         currentWindow.Topmost = true;
         currentWindow.Topmost = false;
         window.Topmost        = true;
         window.Topmost        = false;
     }
 }
Exemple #3
0
        internal void Move(ContentWindow window)
        {
            if (object.ReferenceEquals(window, currentWindow))
            {
                return;
            }

            if (mainTabberIsEmpty)
            {
                if (EmptyItemsPanelRect(window.GetDragItem())
                    .Contains(window.GetDragPosition()))
                {
                    FocusOrderWindow(window);
                    if (shadowItem == null)
                    {
                        shadowItem        = new ShadowTabberItem();
                        shadowItem.Header = new string(' ', 24);
                        Items.Add(shadowItem);
                        shadowItem.IsSelected = true;
                    }
                }
                else
                {
                    if (shadowItem != null)
                    {
                        Items.Remove(shadowItem);
                        shadowItem = null;
                    }
                }
            }
            else
            {
                if (ItemsPanelRect()
                    .Contains(window.GetDragPosition()))
                {
                    FocusOrderWindow(window);
                    FakeTab(window.GetDragPosition());
                }
                else
                {
                    if (shadowItem != null)
                    {
                        Items.Remove(shadowItem);
                        shadowItem = null;
                        lastSelectedItem.IsSelected = true;
                    }
                    oldReplaceItem = null;
                }
            }
        }
Exemple #4
0
        private void ContentWindow_Check(ContentWindow window)
        {
            if (window.Equals(this))
            {
                return;
            }

            bool isEmpty = tabberControl.Items.Count < 1;

            if (isEmpty)
            {
                Left   = Left + (Width / 2);
                Top    = Top + (Height / 2);
                Width  = 0;
                Height = 0;
                Hide();
                Close();
            }
        }
Exemple #5
0
        internal void Enter(ContentWindow window)
        {
            if (object.ReferenceEquals(window, currentWindow))
            {
                return;
            }

            mainTabberIsEmpty = (currentWindow as ContentWindow) == null && Items.Count < 1;
            if (!mainTabberIsEmpty)
            {
                foreach (TabItem item in Items)
                {
                    if (item.IsSelected)
                    {
                        lastSelectedItem = item;
                        break;
                    }
                }
            }
            shadowItem = null;
        }
Exemple #6
0
 private void DragEnd()
 {
     foreach (TabberControl tabberControl in TabberControl.ZOrders)
     {
         tabberControl.Over(this);
     }
     inDrag = false;
     if (firstDrag)
     {
         if (tabberControl.Items.Count == 1)
         {
             TabberItem    item      = (TabberItem)tabberControl.Items[0];
             ContentWindow newWindow = new ContentWindow(
                 item,
                 new Rect(Left, Top, ActualWidth, ActualHeight),
                 false);
             Hide();
             newWindow.Show();
             newWindow.Activate();
             Close();
         }
     }
     firstDrag = false;
 }
Exemple #7
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);
                }
            }
        }