Ejemplo n.º 1
0
        private void FakeTab(Point drahPosition)
        {
            TabItem replaceItem = null;

            foreach (TabItem tab in Items)
            {
                Rect tabRect = TabItemRect(tab);
                if (tabRect.Contains(drahPosition))
                {
                    replaceItem = tab;
                    break;
                }
            }
            if (replaceItem != null)
            {
                TabberItem tabberItem = replaceItem as TabberItem;
                if (tabberItem != null && !tabberItem.Pin && (oldReplaceItem == null || !oldReplaceItem.Equals(replaceItem)))
                {
                    oldReplaceItem = replaceItem;
                    int shadowIndex = shadowItem != null?Items.IndexOf(shadowItem) : -1;

                    if (shadowItem == null)
                    {
                        shadowItem        = new ShadowTabberItem();
                        shadowItem.Header = new string(' ', 24);
                    }
                    int replaceItemIndex = Items.IndexOf(replaceItem);

                    if (shadowIndex > -1 && shadowIndex < replaceItemIndex)
                    {
                        Items.Remove(replaceItem);
                        Items.Insert(shadowIndex, replaceItem);
                    }
                    else
                    {
                        Items.Remove(shadowItem);
                        Items.Insert(replaceItemIndex, shadowItem);
                    }
                    shadowItem.IsSelected = true;
                }
            }
            else if ((Items[Items.Count - 1] as ShadowTabberItem) == null)
            {
                if (shadowItem == null)
                {
                    shadowItem        = new ShadowTabberItem();
                    shadowItem.Header = new string(' ', 24);
                    Items.Add(shadowItem);
                }
                else
                {
                    Items.Remove(shadowItem);
                    Items.Add(shadowItem);
                }
                oldReplaceItem        = null;
                shadowItem.IsSelected = true;
            }
        }
Ejemplo n.º 2
0
        public TabberControl()
            : base()
        {
            firstSort         = true;
            mainTabberIsEmpty = false;
            lastSelectedItem  = null;
            shadowItem        = null;

            Loaded   += TabberControl_Loaded;
            Unloaded += TabberControl_Unloaded;
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 4
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;
        }