public void Select(string tabName) { foreach (var item in Items) { ListTabItem mlti = item as ListTabItem; if (mlti == null) { continue; } if (!mlti.Selectable) { continue; } if (!mlti.IsEnabled) { continue; } if (mlti.Name != tabName) { continue; } tabHeaders.SelectedItem = mlti.ListBoxItem; mlti.IsSelected = true; currentSelectedItem = mlti; break; } }
private void InstallItem(object item, int index) { ListTabItem tab = item as ListTabItem; //if (tab == null && ItemTemplate != null) // tab = ItemTemplate.LoadContent() as MetroListTabItem; if (tab == null) { return; } if (listTabs.Contains(tab)) { return; } tab.UnSelectedState = UnSelectedState; tab.AnimationEnabled = AnimationEnabled; tab.AnimationSlide = AnimationSlide; tab.AnimationSlideLength = AnimationSlideLength; listTabs.Insert(index, tab); listHeader.Insert(index, tab.ListBoxItem); tab.Hide(); if (tabHeaders != null && tabHeaders.SelectedIndex < 0) { tabHeaders.SelectedIndex = 0; } }
private void TryActivate(ListTabItem currentSelectedItem) { var l = currentSelectedItem.Content as ITabLifetime; l?.Activated(); var f = currentSelectedItem.Content as FrameworkElement; if (f != null && f != f.DataContext) { l = f.DataContext as ITabLifetime; l?.Activated(); } }
private bool HasShown(ListTabItem item) { if (item == null) { return(false); } bool shown = false; if (dicShown.ContainsKey(item)) { shown = dicShown[item]; } return(shown); }
private void UninstallItem(object item) { ListTabItem tab = item as ListTabItem; if (tab == null) { return; } dicShown.Remove(tab); listTabs.Remove(tab); listHeader.Remove(tab.ListBoxItem); if (tabHeaders == null) { return; } }
private void TryShown(ListTabItem currentSelectedItem) { var l = currentSelectedItem.Content as ITabLifetime; l?.Shown(); var f = currentSelectedItem.Content as FrameworkElement; if (f != null && f != f.DataContext) { l = f.DataContext as ITabLifetime; l?.Shown(); } TabShown?.Invoke(this, new MsgEventArgs <ListTabItem>() { Parameter = currentSelectedItem }); }
private void SetSelectedItem(ListTabItem value) { if (value == null) { return; } if (!value.Selectable) { return; } if (!value.IsEnabled) { return; } if (!isTemplateApplied) { isTemplateApplied = this.ApplyTemplate(); } tabHeaders.SelectedItem = value.ListBoxItem; currentSelectedItem = value; }
private PropertyGridCatalogMetadata GetPropertyContainer(PropertyDescriptorAttribute attr) { if (!tabs.ContainsKey(attr.Gallery)) { var content = new PropertyGridTabItemContent() { PropertyGrid = pg }; var item = new ListTabItem() { Name = attr.Gallery.Replace(' ', '_'), Header = new TextBox() { Text = attr.Gallery, ToolTip = attr.Gallery, }, Content = content, }; tabs[attr.Gallery] = content; pg.tabControl.Items.Add(item); } var tab = tabs[attr.Gallery]; if (!tab.Catalogs.Any(c => c.Name == attr.Catalog)) { tab.Catalogs.Add(new PropertyGridCatalogMetadata() { Name = attr.Catalog, Image = attr.CatalogImage16.IsNullOrBlank() ? null : BitmapFrame.Create(new Uri(attr.CatalogImage16)), PropertyGrid = pg, }); } return(tab.Catalogs.FirstOrDefault(c => c.Name == attr.Catalog)); }
private void tabs_SelectionChanged(object sender, SelectionChangedEventArgs e) { bool hasSelectable = listTabs.Any(c => c.Selectable); var id = listTabs.IndexOf(currentSelectedItem); int index = tabHeaders.SelectedIndex; if (index < 0 && hasSelectable) { tabHeaders.SelectedIndex = id; return; } else if (index < 0 && !hasSelectable) { SelectedIndex = -1; if (currentSelectedItem != null) { currentSelectedItem.IsSelected = false; currentSelectedItem = null; } RaiseSelectedIndexChangedEvent(); return; } ListTabItem mlti = null; foreach (ListTabItem item in Items) { if (item.ListBoxItem == tabHeaders.SelectedItem) { mlti = item; break; } } if (mlti != null && mlti.Selectable) { if (!handleSelectable) { return; } if (currentSelectedItem != null) { currentSelectedItem.IsSelected = false; } mlti.Before = !AnimationEnabledWhenShown && !HasShown(mlti) ? (null as bool?) : (SelectedIndex <= index); SelectedIndex = index; currentSelectedItem = mlti; mlti.IsSelected = true; RaiseSelectedIndexChangedEvent(); return; } handleSelectable = false; tabHeaders.SelectedIndex = SelectedIndex; handleSelectable = true; RaiseItemClickEvent(mlti == null ? null : mlti.Header); }