private void tabButtonSelectedHandler(object sender, TabButtonSelectedEventArgs args) { if ((content != null) && (content.ViewCount > args.Index)) { content.Select(args.Index); } }
protected internal void RemoveTabButton(TabButton tabButton) { if (tabButton == null) { throw new ArgumentNullException(nameof(tabButton), "tabButton should not be null."); } if (tabButtons.Contains(tabButton) == false) { throw new ArgumentException("tabButton does not exist in TabBar.", nameof(tabButton)); } int index = tabButtons.IndexOf(tabButton); TabButton selectedTabButton = tabButtons[SelectedIndex]; tabButtons.Remove(tabButton); Remove(tabButton); tabButtonGroup.Remove(tabButton); if ((index < SelectedIndex) || (tabButtons.Count == SelectedIndex)) { SelectedIndex -= 1; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } } if ((SelectedIndex != -1) && (selectedTabButton != tabButtons[SelectedIndex])) { tabButtons[SelectedIndex].IsSelected = true; } }
protected internal void AddTabButton(TabButton tabButton) { if (tabButton == null) { throw new ArgumentNullException(nameof(tabButton), "tabButton should not be null."); } tabButtons.Add(tabButton); Add(tabButton); tabButtonGroup.Add(tabButton); tabButton.Clicked += (object sender, ClickedEventArgs e) => { int index = tabButtons.IndexOf(tabButton); if (SelectedIndex == index) { return; } SelectedIndex = index; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } }; if (SelectedIndex == -1) { tabButton.IsSelected = true; tabButton.SetTabButtonState(ControlState.Pressed); SelectedIndex = 0; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } } //TODO: To support non-unified tab button size. CalculateUnifiedTabButtonSize(); }
protected internal void AddTabButton(TabButton tabButton) { if (tabButton == null) { throw new ArgumentNullException(nameof(tabButton), "tabButton should not be null."); } tabButtons.Add(tabButton); Add(tabButton); tabButtonGroup.Add(tabButton); tabButton.Clicked += (object sender, ClickedEventArgs e) => { int index = tabButtons.IndexOf(tabButton); if (SelectedIndex == index) { return; } SelectedIndex = index; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } }; if (SelectedIndex == -1) { tabButton.IsSelected = true; SelectedIndex = 0; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } } }
protected internal void RemoveTabButton(TabButton tabButton) { if (tabButton == null) { throw new ArgumentNullException(nameof(tabButton), "tabButton should not be null."); } if (tabButtons.Contains(tabButton) == false) { throw new ArgumentException("tabButton does not exist in TabBar.", nameof(tabButton)); } int index = tabButtons.IndexOf(tabButton); TabButton selectedTabButton = tabButtons[SelectedIndex]; tabButtons.Remove(tabButton); Remove(tabButton); tabButtonGroup.Remove(tabButton); if ((index < SelectedIndex) || (tabButtons.Count == SelectedIndex)) { SelectedIndex -= 1; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } } if ((SelectedIndex != -1) && (selectedTabButton != tabButtons[SelectedIndex])) { tabButtons[SelectedIndex].IsSelected = true; tabButtons[SelectedIndex].SetTabButtonState(ControlState.Pressed); } //TODO: To support non-unified tab button size. CalculateUnifiedTabButtonSize(); }