Example #1
0
        internal void Remove(TabGroup tabGroup)
        {
            int index = stackedContent.IndexOf(tabGroup);

            if (index < 0)
            {
                return;
            }
            if (stackedContent.Count == 1)
            {
                ActiveIndex = -1;
                stackedContent.Remove(tabGroup);
            }
            else
            {
                if (ActiveIndex == index)
                {
                    int newIndex = index == 0 ? index + 1 : index - 1;
                    SetActive(stackedContent[newIndex]);
                    ActiveIndex = newIndex;
                }
                var current = stackedContent[ActiveIndex];
                stackedContent.Remove(tabGroup);
                ActiveIndex = stackedContent.IndexOf(current);
                Debug.Assert(ActiveIndex >= 0);
            }
            tabGroupCollectionChanged.Raise(this, new TabGroupCollectionChangedEventArgs(false, tabGroup));
        }
Example #2
0
 public SetFocusWhenVisible(TabGroup tabGroup, ITabContent content, UIElement uiElem, Action action)
 {
     this.tabGroup            = tabGroup;
     this.content             = content;
     this.uiElem              = uiElem;
     this.action              = action;
     uiElem.IsVisibleChanged += uiElem_IsVisibleChanged;
 }
Example #3
0
        void MoveAllToOtherTabGroup(TabGroup dst, TabGroup src)
        {
            var activeTab = src.ActiveTabItemImpl;

            Merge(dst, src, 0);
            dst.SetSelectedTab(activeTab);
            SetActive(dst);
        }
Example #4
0
 void Move(TabGroup dstTabGroup, TabGroup srcTabGroup, TabItemImpl srcTabItemImpl, int insertIndex = 0)
 {
     Debug.Assert(stackedContent.Contains(dstTabGroup));
     Debug.Assert(stackedContent.Contains(srcTabGroup));
     Debug.Assert(srcTabGroup.Contains(srcTabItemImpl));
     if (srcTabGroup.MoveToAndSelect(dstTabGroup, srcTabItemImpl, insertIndex))
     {
         SetActive(dstTabGroup);
     }
 }
Example #5
0
        public bool MoveToAndSelect(TabGroup dstTabGroup, TabItemImpl srcTabItem, int insertIndex)
        {
            bool res = MoveTo(dstTabGroup, srcTabItem, insertIndex);

            if (res)
            {
                dstTabGroup.SetSelectedTab(srcTabItem);
            }
            return(res);
        }
Example #6
0
 public bool MoveTo(TabGroup dstTabGroup, TabItemImpl srcTabItem, TabItemImpl insertBeforeThis)
 {
     if (insertBeforeThis != null)
     {
         Debug.Assert(dstTabGroup.tabControl.Items.Contains(insertBeforeThis));
         return(MoveTo(dstTabGroup, srcTabItem, dstTabGroup.tabControl.Items.IndexOf(insertBeforeThis)));
     }
     else
     {
         return(MoveTo(dstTabGroup, srcTabItem, -1));
     }
 }
Example #7
0
        TabGroup Create(int index, Action <ITabGroup> onCreated)
        {
            var tg = new TabGroup(this, menuService, wpfFocusService, options);

            stackedContent.AddChild(tg, null, index);
            if (ActiveIndex < 0)
            {
                ActiveIndex = index;
            }
            onCreated?.Invoke(tg);
            tabGroupCollectionChanged.Raise(this, new TabGroupCollectionChangedEventArgs(true, tg));
            return(tg);
        }
Example #8
0
 public TabItemImpl(TabGroup tabGroup, ITabContent tabContent, object objStyle)
 {
     this.tabGroup    = tabGroup;
     this.tabContent  = tabContent;
     this.Content     = tabContent.UIObject;
     this.theHeader   = new TheHeader(this);
     this.DataContext = theHeader;
     this.Header      = theHeader;
     this.AllowDrop   = true;
     this.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(GotKeyboardFocus2), true);
     this.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(LostKeyboardFocus2), true);
     this.SetStyle(objStyle ?? "FileTabGroupTabItemStyle");
     AddEvents();
 }
Example #9
0
 public TabItemImpl(TabGroup tabGroup, ITabContent tabContent, object objStyle)
 {
     this.tabGroup = tabGroup;
     this.tabContent = tabContent;
     this.Content = tabContent.UIObject;
     this.theHeader = new TheHeader(this);
     this.DataContext = theHeader;
     this.Header = theHeader;
     this.AllowDrop = true;
     this.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(GotKeyboardFocus2), true);
     this.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(LostKeyboardFocus2), true);
     this.SetStyle(objStyle ?? "FileTabGroupTabItemStyle");
     AddEvents();
 }
Example #10
0
        bool GetInfo(object sender, DragEventArgs e,
                     out TabItemImpl tabItemSource, out TabItemImpl tabItemTarget,
                     out TabGroup tabGroupSource, out TabGroup tabGroupTarget,
                     bool canBeSame)
        {
            tabItemSource  = tabItemTarget = null;
            tabGroupSource = tabGroupTarget = null;

            if (!e.Data.GetDataPresent(typeof(TabItemImpl)))
            {
                return(false);
            }

            tabItemTarget = sender as TabItemImpl;
            tabItemSource = (TabItemImpl)e.Data.GetData(typeof(TabItemImpl));
            if (tabItemTarget == null || tabItemSource == null || (!canBeSame && tabItemTarget == tabItemSource))
            {
                return(false);
            }
            var tabControlTarget = tabItemTarget.Parent as TabControl;

            if (tabControlTarget == null)
            {
                return(false);
            }
            var tabControlSource = tabItemSource.Parent as TabControl;

            if (tabControlSource == null)
            {
                return(false);
            }

            tabGroupTarget = tabControlTarget.DataContext as TabGroup;
            tabGroupSource = tabControlSource.DataContext as TabGroup;
            if (tabGroupTarget == null || tabGroupSource == null)
            {
                return(false);
            }
            if (tabGroupTarget.tabGroupService.TabService != tabGroupSource.tabGroupService.TabService)
            {
                return(false);
            }
            if (tabGroupTarget.tabGroupService != this.tabGroupService)
            {
                return(false);
            }

            return(true);
        }
Example #11
0
 void Merge(TabGroup dstTabGroup, TabGroup srcTabGroup, int insertIndex)
 {
     if (dstTabGroup == srcTabGroup)
     {
         return;
     }
     if (insertIndex < 0 || insertIndex > dstTabGroup.Count)
     {
         insertIndex = dstTabGroup.Count;
     }
     foreach (var srcTabItemImpl in srcTabGroup.AllTabItemImpls.ToArray())
     {
         srcTabGroup.MoveTo(dstTabGroup, srcTabItemImpl, insertIndex++);
     }
 }
Example #12
0
        TabGroup Create(int index, Action <ITabGroup> onCreated)
        {
            var tg = new TabGroup(this, menuManager, wpfFocusManager, options);

            stackedContent.AddChild(tg, null, index);
            if (ActiveIndex < 0)
            {
                ActiveIndex = index;
            }
            if (onCreated != null)
            {
                onCreated(tg);
            }
            tabGroupCollectionChanged.Raise(this, new TabGroupCollectionChangedEventArgs(true, tg));
            return(tg);
        }
Example #13
0
        internal void SetActive(TabGroup tabGroup)
        {
            tabManager.SetActive(this);

            if (tabGroup == ActiveTabGroup)
            {
                return;
            }
            int newIndex = stackedContent.IndexOf(tabGroup);

            if (newIndex < 0)
            {
                throw new InvalidOperationException();
            }
            var oldTabGroup = ActiveTabGroup;

            ActiveIndex = newIndex;
            tabGroupSelectionChanged.Raise(this, new TabGroupSelectedEventArgs(ActiveTabGroup, oldTabGroup));
        }
Example #14
0
        public bool MoveTo(TabGroup dstTabGroup, TabItemImpl srcTabItem, int insertIndex)
        {
            Debug.Assert(Contains(srcTabItem));
            if (srcTabItem == null)
            {
                return(false);
            }

            DetachTabItem(srcTabItem);
            dstTabGroup.AttachTabItem(srcTabItem, insertIndex);

            if (srcTabItem.IsKeyboardFocusWithin)
            {
                tabGroupService.SetActiveTab(srcTabItem);
                this.IsActive        = false;
                dstTabGroup.IsActive = true;
            }

            return(true);
        }
Example #15
0
 internal void Remove(TabGroup tabGroup)
 {
     int index = stackedContent.IndexOf(tabGroup);
     if (index < 0)
         return;
     if (stackedContent.Count == 1) {
         ActiveIndex = -1;
         stackedContent.Remove(tabGroup);
     }
     else {
         if (ActiveIndex == index) {
             int newIndex = index == 0 ? index + 1 : index - 1;
             SetActive(stackedContent[newIndex]);
             ActiveIndex = newIndex;
         }
         var current = stackedContent[ActiveIndex];
         stackedContent.Remove(tabGroup);
         ActiveIndex = stackedContent.IndexOf(current);
         Debug.Assert(ActiveIndex >= 0);
     }
     tabGroupCollectionChanged.Raise(this, new TabGroupCollectionChangedEventArgs(false, tabGroup));
 }
Example #16
0
 public GuidObjectsCreator(TabGroup tabGroup)
 {
     this.tabGroup = tabGroup;
 }
Example #17
0
 internal void OnSelectionChanged(TabGroup tabGroup, TabItemImpl selected, TabItemImpl unselected)
 {
     tabSelectionChanged.Raise(this, new TabSelectedEventArgs(tabGroup, selected == null ? null : selected.TabContent, unselected == null ? null : unselected.TabContent));
 }
Example #18
0
 public GuidObjectsProvider(TabGroup tabGroup)
 {
     this.tabGroup = tabGroup;
 }
Example #19
0
 void MoveAllToOtherTabGroup(TabGroup dst, TabGroup src)
 {
     var activeTab = src.ActiveTabItemImpl;
     Merge(dst, src, 0);
     dst.SetSelectedTab(activeTab);
     SetActive(dst);
 }
Example #20
0
			public GuidObjectsProvider(TabGroup tabGroup) {
				this.tabGroup = tabGroup;
			}
Example #21
0
 public GuidObjectsCreator(TabGroup tabGroup)
 {
     this.tabGroup = tabGroup;
 }
Example #22
0
 public bool MoveToAndSelect(TabGroup dstTabGroup, TabItemImpl srcTabItem, int insertIndex)
 {
     bool res = MoveTo(dstTabGroup, srcTabItem, insertIndex);
     if (res)
         dstTabGroup.SetSelectedTab(srcTabItem);
     return res;
 }
Example #23
0
        public bool MoveTo(TabGroup dstTabGroup, TabItemImpl srcTabItem, int insertIndex)
        {
            Debug.Assert(Contains(srcTabItem));
            if (srcTabItem == null)
                return false;

            DetachTabItem(srcTabItem);
            dstTabGroup.AttachTabItem(srcTabItem, insertIndex);

            if (srcTabItem.IsKeyboardFocusWithin) {
                tabGroupManager.SetActiveTab(srcTabItem);
                this.IsActive = false;
                dstTabGroup.IsActive = true;
            }

            return true;
        }
Example #24
0
 internal void OnSelectionChanged(TabGroup tabGroup, TabItemImpl selected, TabItemImpl unselected)
 {
     tabSelectionChanged.Raise(this, new TabSelectedEventArgs(tabGroup, selected == null ? null : selected.TabContent, unselected == null ? null : unselected.TabContent));
 }
Example #25
0
 public bool MoveTo(TabGroup dstTabGroup, TabItemImpl srcTabItem, TabItemImpl insertBeforeThis)
 {
     if (insertBeforeThis != null) {
         Debug.Assert(dstTabGroup.tabControl.Items.Contains(insertBeforeThis));
         return MoveTo(dstTabGroup, srcTabItem, dstTabGroup.tabControl.Items.IndexOf(insertBeforeThis));
     }
     else
         return MoveTo(dstTabGroup, srcTabItem, -1);
 }
Example #26
0
        internal void SetActive(TabGroup tabGroup)
        {
            tabManager.SetActive(this);

            if (tabGroup == ActiveTabGroup)
                return;
            int newIndex = stackedContent.IndexOf(tabGroup);
            if (newIndex < 0)
                throw new InvalidOperationException();
            var oldTabGroup = ActiveTabGroup;
            ActiveIndex = newIndex;
            tabGroupSelectionChanged.Raise(this, new TabGroupSelectedEventArgs(ActiveTabGroup, oldTabGroup));
        }
Example #27
0
 public bool MoveToAndSelect(TabGroup dstTabGroup, TabItemImpl srcTabItem, TabItemImpl insertBeforeThis)
 {
     bool res = MoveTo(dstTabGroup, srcTabItem, insertBeforeThis);
     if (res)
         dstTabGroup.SetSelectedTab(srcTabItem);
     return res;
 }
Example #28
0
 TabGroup Create(int index, Action<ITabGroup> onCreated)
 {
     var tg = new TabGroup(this, menuManager, wpfFocusManager, options);
     stackedContent.AddChild(tg, null, index);
     if (ActiveIndex < 0)
         ActiveIndex = index;
     if (onCreated != null)
         onCreated(tg);
     tabGroupCollectionChanged.Raise(this, new TabGroupCollectionChangedEventArgs(true, tg));
     return tg;
 }
Example #29
0
        bool GetInfo(object sender, DragEventArgs e,
					out TabItemImpl tabItemSource, out TabItemImpl tabItemTarget,
					out TabGroup tabGroupSource, out TabGroup tabGroupTarget,
					bool canBeSame)
        {
            tabItemSource = tabItemTarget = null;
            tabGroupSource = tabGroupTarget = null;

            if (!e.Data.GetDataPresent(typeof(TabItemImpl)))
                return false;

            tabItemTarget = sender as TabItemImpl;
            tabItemSource = (TabItemImpl)e.Data.GetData(typeof(TabItemImpl));
            if (tabItemTarget == null || tabItemSource == null || (!canBeSame && tabItemTarget == tabItemSource))
                return false;
            var tabControlTarget = tabItemTarget.Parent as TabControl;
            if (tabControlTarget == null)
                return false;
            var tabControlSource = tabItemSource.Parent as TabControl;
            if (tabControlSource == null)
                return false;

            tabGroupTarget = tabControlTarget.DataContext as TabGroup;
            tabGroupSource = tabControlSource.DataContext as TabGroup;
            if (tabGroupTarget == null || tabGroupSource == null)
                return false;
            if (tabGroupTarget.tabGroupManager.TabManager != tabGroupSource.tabGroupManager.TabManager)
                return false;
            if (tabGroupTarget.tabGroupManager != this.tabGroupManager)
                return false;

            return true;
        }
Example #30
0
 void Merge(TabGroup dstTabGroup, TabGroup srcTabGroup, int insertIndex)
 {
     if (dstTabGroup == srcTabGroup)
         return;
     if (insertIndex < 0 || insertIndex > dstTabGroup.Count)
         insertIndex = dstTabGroup.Count;
     foreach (var srcTabItemImpl in srcTabGroup.AllTabItemImpls.ToArray())
         srcTabGroup.MoveTo(dstTabGroup, srcTabItemImpl, insertIndex++);
 }
Example #31
0
 public SetFocusWhenVisible(TabGroup tabGroup, ITabContent content, UIElement uiElem, Action action)
 {
     this.tabGroup = tabGroup;
     this.content = content;
     this.uiElem = uiElem;
     this.action = action;
     uiElem.IsVisibleChanged += uiElem_IsVisibleChanged;
 }
Example #32
0
 void Move(TabGroup dstTabGroup, TabGroup srcTabGroup, TabItemImpl srcTabItemImpl, int insertIndex = 0)
 {
     Debug.Assert(stackedContent.Contains(dstTabGroup));
     Debug.Assert(stackedContent.Contains(srcTabGroup));
     Debug.Assert(srcTabGroup.Contains(srcTabItemImpl));
     if (srcTabGroup.MoveToAndSelect(dstTabGroup, srcTabItemImpl, insertIndex))
         SetActive(dstTabGroup);
 }