/// <summary> Deselects a <see cref="WebTab"/> whose position in the list is still occupied. </summary> protected void DeselectTab(WebTab tab, int index) { ArgumentUtility.CheckNotNull("tab", tab); if (_tabStrip != null && tab.IsSelected) { bool isLastTab = index + 1 == InnerList.Count; if (isLastTab) { if (InnerList.Count > 1) { WebTab penultimateTab = (WebTab)InnerList[index - 1]; _tabStrip.SetSelectedTabInternal(penultimateTab); } else { _tabStrip.SetSelectedTabInternal(null); } } else { WebTab nextTab = (WebTab)InnerList[index + 1]; _tabStrip.SetSelectedTabInternal(nextTab); } } }
/// <summary> Loads the selected tabs from the window state or the query string. </summary> private void LoadSelection() { string[] selectedTabIDs = GetSelectionFromWindowState(); if (selectedTabIDs.Length == 0) { selectedTabIDs = GetSelectionFromQueryString(); } if (selectedTabIDs.Length > 0) { string selectedMainMenuItemID = selectedTabIDs[0]; WebTab selectedMainMenuItem = _mainMenuTabStrip.Tabs.Find(selectedMainMenuItemID); if (selectedMainMenuItem.IsVisible) { selectedMainMenuItem.IsSelected = true; } } RefreshSubMenuTabStrip(); if (selectedTabIDs.Length > 1) { string selectedSubMenuItemID = selectedTabIDs[1]; WebTab selectedSubMenuItem = _subMenuTabStrip.Tabs.Find(selectedSubMenuItemID); if (selectedSubMenuItem.IsVisible) { selectedSubMenuItem.IsSelected = true; } } }
protected virtual object SaveControlState() { ArrayList tabsState = new ArrayList(); for (int i = 0; i < InnerList.Count; i++) { WebTab tab = (WebTab)InnerList[i]; object tabStateValue = ((IControlStateManager)tab).SaveControlState(); if (tabStateValue != null) { Pair pair = new Pair(); pair.First = tab.ItemID; pair.Second = tabStateValue; tabsState.Add(pair); } } if (tabsState.Count == 0) { return(null); } else { return(tabsState.ToArray(typeof(Pair))); } }
protected override void OnRemoveComplete(int index, object value) { WebTab tab = ArgumentUtility.CheckNotNullAndType <WebTab> ("value", value); base.OnRemoveComplete(index, value); tab.SetTabStrip(null); if (_tabStrip != null && tab.IsSelected) { bool wasLastTab = index == InnerList.Count; if (wasLastTab) { if (InnerList.Count > 1) { WebTab lastTab = (WebTab)InnerList[index - 1]; _tabStrip.SetSelectedTabInternal(lastTab); } else { _tabStrip.SetSelectedTabInternal(null); } } else { WebTab nextTab = (WebTab)InnerList[index]; _tabStrip.SetSelectedTabInternal(nextTab); } } }
protected override void OnInsertComplete(int index, object value) { WebTab tab = ArgumentUtility.CheckNotNullAndType <WebTab> ("value", value); base.OnInsertComplete(index, value); tab.SetTabStrip(_tabStrip); InitalizeSelectedTab(); }
public void SetActiveView(TabView view) { ArgumentUtility.CheckNotNull("view", view); MultiViewInternal.SetActiveView(view); TabView activeView = GetActiveView(); WebTab nextActiveTab = _tabStrip.Tabs.Find(activeView.ID + c_itemIDSuffix); nextActiveTab.IsSelected = true; }
private void HandleClickEvent(string eventArgument) { ArgumentUtility.CheckNotNullOrEmpty("eventArgument", eventArgument); WebTab tab = Tabs.Find(eventArgument); if (tab != null) { OnClick(tab); } }
internal void DeselectTabInternal(WebTab tab) { ArgumentUtility.CheckNotNull("tab", tab); if (tab.TabStrip != null && tab.TabStrip != _tabStrip) { throw new ArgumentException("The tab is not part of this collection's Tabstrip", "tab"); } DeselectTab(tab, IndexOf(tab)); }
protected override void ValidateNewValue(object value) { WebTab tab = ArgumentUtility.CheckNotNullAndType <WebTab> ("value", value); EnsureDesignModeTabInitialized(tab); if (string.IsNullOrEmpty(tab.ItemID)) { throw new ArgumentException("The tab does not have an 'ItemID'. It can therfor not be inserted into the collection.", "value"); } base.ValidateNewValue(value); }
private void SetSelectedTab(string itemID) { ArgumentUtility.CheckNotNullOrEmpty("itemID", itemID); if (_selectedTab == null || _selectedTab.ItemID != itemID) { WebTab tab = Tabs.Find(itemID); if (tab != _selectedTab) { SetSelectedTabInternal(tab); } } }
protected virtual void OnClick(WebTab tab) { ArgumentUtility.CheckNotNull("tab", tab); tab.OnClick(); WebTabClickEventHandler handler = (WebTabClickEventHandler)Events[s_clickEvent]; if (handler != null) { WebTabClickEventArgs e = new WebTabClickEventArgs(tab); handler(this, e); } }
protected override void OnSetComplete(int index, object oldValue, object newValue) { WebTab oldTab = ArgumentUtility.CheckNotNullAndType <WebTab> ("oldValue", oldValue); WebTab newTab = ArgumentUtility.CheckNotNullAndType <WebTab> ("newValue", newValue); base.OnSetComplete(index, oldValue, newValue); newTab.SetTabStrip(_tabStrip); oldTab.SetTabStrip(null); DeselectTab(oldTab, index); }
protected override void OnClear() { base.OnClear(); for (int i = 0; i < InnerList.Count; i++) { WebTab tab = (WebTab)InnerList[i]; tab.SetTabStrip(null); } if (_tabStrip != null) { _tabStrip.SetSelectedTabInternal(null); } }
private void InitalizeSelectedTab() { if (_tabStrip != null && (_tabStrip.Page == null || !_tabStrip.Page.IsPostBack) && _tabStrip.SelectedTab == null) { for (int i = 0; i < InnerList.Count; i++) { WebTab tab = (WebTab)InnerList[i]; if (tab.IsVisible && !tab.IsDisabled) { _tabStrip.SetSelectedTabInternal(tab); break; } } } }
protected virtual void LoadControlState(object state) { if (state == null) { return; } Pair[] tabsState = (Pair[])state; for (int i = 0; i < tabsState.Length; i++) { Pair pair = tabsState[i]; string itemID = (string)pair.First; WebTab tab = Find(itemID); if (tab != null) { ((IControlStateManager)tab).LoadControlState(pair.Second); } } }
/// <summary> Sets the selected tab. </summary> internal void SetSelectedTabInternal(WebTab tab) { if (!_isRestoringTabs) { EnsureTabsRestored(); } if (tab != null && tab.TabStrip != this) { throw new InvalidOperationException("Only tabs that are part of this tab strip can be selected."); } if (_selectedTab != tab) { if ((_selectedTab != null) && _selectedTab.IsSelected) { _selectedTab.SetSelected(false); } _selectedTab = tab; if ((_selectedTab != null) && !_selectedTab.IsSelected) { _selectedTab.SetSelected(true); } if (_selectedTab == null) { _selectedItemID = null; } else { _selectedItemID = _selectedTab.ItemID; } if (_selectedTab != null) { _selectedTab.OnSelectionChangedInternal(); } } }
private void EnsureDesignModeTabInitialized(WebTab tab) { ArgumentUtility.CheckNotNull("tab", tab); if (!tab.HasItemID() && (_tabStrip != null && ControlHelper.IsDesignMode(_tabStrip) || OwnerControl != null && ControlHelper.IsDesignMode(OwnerControl))) { int index = InnerList.Count; do { index++; string itemID = "Tab" + index; if (Find(itemID) == null) { tab.ItemID = itemID; if (string.IsNullOrEmpty(tab.Text)) { tab.Text = "Tab " + index; } break; } } while (true); } }
private void OnTabViewRemoved(TabView view) { EnsureChildControls(); WebTab tab = _tabStrip.Tabs.Find(view.ID + c_itemIDSuffix); if (tab == null) { return; } int tabIndex = _tabStrip.Tabs.IndexOf(tab); _tabStrip.Tabs.RemoveAt(tabIndex); if (_newActiveTabAfterRemove != null) { if (_newActiveTabAfterRemove == _placeHolderTabView) { Views.Add(_placeHolderTabView); } SetActiveView(_newActiveTabAfterRemove); } }
/// <summary> Initializes an instance. </summary> public WebTabClickEventArgs(WebTab tab) { ArgumentUtility.CheckNotNull("tab", tab); _tab = tab; }