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