Exemplo n.º 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));
        }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
        void MoveAllToOtherTabGroup(TabGroup dst, TabGroup src)
        {
            var activeTab = src.ActiveTabItemImpl;

            Merge(dst, src, 0);
            dst.SetSelectedTab(activeTab);
            SetActive(dst);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 5
0
        public bool MoveToAndSelect(TabGroup dstTabGroup, TabItemImpl srcTabItem, int insertIndex)
        {
            bool res = MoveTo(dstTabGroup, srcTabItem, insertIndex);

            if (res)
            {
                dstTabGroup.SetSelectedTab(srcTabItem);
            }
            return(res);
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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);
        }
Exemplo n.º 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++);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
 }
Exemplo n.º 16
0
 public GuidObjectsCreator(TabGroup tabGroup)
 {
     this.tabGroup = tabGroup;
 }
Exemplo n.º 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));
 }
Exemplo n.º 18
0
 public GuidObjectsProvider(TabGroup tabGroup)
 {
     this.tabGroup = tabGroup;
 }
Exemplo n.º 19
0
 void MoveAllToOtherTabGroup(TabGroup dst, TabGroup src)
 {
     var activeTab = src.ActiveTabItemImpl;
     Merge(dst, src, 0);
     dst.SetSelectedTab(activeTab);
     SetActive(dst);
 }
Exemplo n.º 20
0
			public GuidObjectsProvider(TabGroup tabGroup) {
				this.tabGroup = tabGroup;
			}
Exemplo n.º 21
0
 public GuidObjectsCreator(TabGroup tabGroup)
 {
     this.tabGroup = tabGroup;
 }
Exemplo n.º 22
0
 public bool MoveToAndSelect(TabGroup dstTabGroup, TabItemImpl srcTabItem, int insertIndex)
 {
     bool res = MoveTo(dstTabGroup, srcTabItem, insertIndex);
     if (res)
         dstTabGroup.SetSelectedTab(srcTabItem);
     return res;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
        }
Exemplo n.º 27
0
 public bool MoveToAndSelect(TabGroup dstTabGroup, TabItemImpl srcTabItem, TabItemImpl insertBeforeThis)
 {
     bool res = MoveTo(dstTabGroup, srcTabItem, insertBeforeThis);
     if (res)
         dstTabGroup.SetSelectedTab(srcTabItem);
     return res;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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++);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }