/// <summary> /// Функция реализующая логику выбора вкладок. /// </summary> ///<remarks> /// A function that implements the selecting tabs logic. ///</remarks> internal void Select(UITabPanelItem item, bool value) { if (item != null) { SelectedItems.Clear(); UnselectedItems.Clear(); foreach (UITabPanelItem node in Items) { if (Equals(node, item)) { if (!item.IsSelected && value) { node.IsSelected = true; SelectedItems.Add(item); } else if (item.IsSelected && !value) { node.IsSelected = false; UnselectedItems.Add(node); } } else { node.IsSelected = false; UnselectedItems.Add(node); } if (TabsStyle == UITabPanelStyleEnum.CompactTabs) { BringItemToUp(node); } } state = ControlState.IgnoreChanges; if (SelectedItems.Count != 0) { SelectedItem = SelectedItems[SelectedItems.Count - 1]; SelectedIndex = Items.IndexOf(SelectedItem); if (IsExpandable) { IsExpanded = true; } } else { SelectedItem = null; SelectedIndex = -1; if (IsExpandable) { IsExpanded = false; } } state = ControlState.Ready; RaiseEvent(new SelectionChangedEventArgs(SelectionChangedEvent, UnselectedItems, SelectedItems)); } }
/// <summary> /// Вспомогательная функция, устанавливает ZIndex таким образом, чтобы казалось будто вкладки расположены друг под другом, /// при этом первая вкладка всегда самая верхняя, а последняя самая нижняя. Если вкладка выделена, то ZIndex устанавливается таким, чтобы визуально быть наверху всех вкладок. /// </summary> ///<remarks> /// A helper function that sets the ZIndex so that it appears as if the tabs are located one above the other, with the first tab always the top one and the last one the bottom one. /// If a tab is selected, then the ZIndex is set to visually be at the top of all tabs. ///</remarks> private void BringItemToUp(UITabPanelItem item) { if (item.IsSelected) { Panel.SetZIndex(item, 100); } else { var itemIndex = Items.IndexOf(item); Panel.SetZIndex(item, Items.Count - itemIndex + 1); } }
/// <summary> /// Функция устанавливает внешний вид заданному UITabPanelItem. /// </summary> ///<remarks> /// The function sets the appearance of the given UITabPanelItem. ///</remarks> private void SetItemAppearance(UITabPanelItem item) { item.TabStyle = TabsStyle; if (TabsStyle == UITabPanelStyleEnum.CompactTabs) { BringItemToUp(item); } if (Orientation == UITabPanelItemOrientation.Left) { item.HorizontalAlignment = HorizontalAlignment.Right; item.VerticalAlignment = VerticalAlignment.Top; if (TabsStyle == UITabPanelStyleEnum.CompactTabs) { item.Margin = new Thickness(0, -22, 0, 0); } else { item.Margin = new Thickness(0); } } else if (Orientation == UITabPanelItemOrientation.Right) { item.HorizontalAlignment = HorizontalAlignment.Left; item.VerticalAlignment = VerticalAlignment.Top; if (TabsStyle == UITabPanelStyleEnum.CompactTabs) { item.Margin = new Thickness(0, -22, 0, 0); } else { item.Margin = new Thickness(0); } } else if (Orientation == UITabPanelItemOrientation.Top) { item.HorizontalAlignment = HorizontalAlignment.Left; item.VerticalAlignment = VerticalAlignment.Bottom; if (TabsStyle == UITabPanelStyleEnum.CompactTabs) { item.Margin = new Thickness(-22, 0, 0, 0); } else { item.Margin = new Thickness(0); } } else if (Orientation == UITabPanelItemOrientation.Bottom) { item.HorizontalAlignment = HorizontalAlignment.Left; item.VerticalAlignment = VerticalAlignment.Top; if (TabsStyle == UITabPanelStyleEnum.CompactTabs) { item.Margin = new Thickness(-22, 0, 0, 0); } else { item.Margin = new Thickness(0); } } }