/// <summary> /// Initializes a new instance of the <see cref="UndockedHierarchicalViewWindow"/> class. /// </summary> /// <param name="viewResult">The view result.</param> /// <param name="hierarchicalViewHostTabItem">The hierarchical view host tab item.</param> public UndockedHierarchicalViewWindow(ViewResult viewResult, HierarchicalViewHostTabItem hierarchicalViewHostTabItem) { Closing += (s, e) => { DockContent(); }; DataContext = viewResult; _hierarchicalViewHostTabItem = hierarchicalViewHostTabItem; if (hierarchicalViewHostTabItem.UndockWindowStyle != null) { Style = hierarchicalViewHostTabItem.UndockWindowStyle; } if (viewResult != null) { Title = viewResult.ViewTitle; if (viewResult.View != null) { var viewColor = SimpleView.GetViewThemeColor(viewResult.View); if (viewColor != Colors.Transparent) { Background = new SolidColorBrush(viewColor); } } } }
/// <summary> /// Called when the button is clicked /// </summary> protected override void OnClick() { if (TabControl == null) { return; } var menu = new ContextMenu(); var counter = -1; foreach (var view in Shell.Current.NormalViews) { counter++; var menuItem = new SelectViewMenuItem(TabControl, counter); menuItem.Header = SimpleView.GetTitle(view.View); var viewColor = SimpleView.GetViewThemeColor(view.View); if (viewColor.A == 0) { var viewColorResource = FindResource("CODE.Framework-Application-ThemeColor1"); if (viewColorResource != null) { viewColor = (Color)viewColorResource; } } if (viewColor.A != 0) { menuItem.Background = new SolidColorBrush(viewColor); } menu.Items.Add(menuItem); } menu.Placement = PlacementMode.Bottom; menu.HorizontalOffset = ActualWidth; menu.PlacementTarget = this; menu.IsOpen = true; }
/// <summary> /// Creates a new tab, or returns the existing tab for the group /// </summary> /// <param name="group">The group.</param> /// <param name="groupName">Name of the group.</param> /// <returns>TabItem.</returns> private TabItem GetNewOrExistingGroupTab(IList <ViewResult> group, string groupName) { var tab = Items.OfType <TabItem>().FirstOrDefault(t => GetAssociatedGroupName(t) == groupName); if (tab != null) { SelectedItem = tab; return(tab); } var newTab = new TabItem(); SetAssociatedGroupName(newTab, groupName); var backgroundColor = SimpleView.GetViewThemeColor(group[0].View); if (backgroundColor != Colors.Transparent) { newTab.Background = new SolidColorBrush(backgroundColor); } var foregroundBrush = SimpleView.GetTitleColor(group[0].View); if (foregroundBrush != null) { newTab.Foreground = foregroundBrush; } newTab.DataContext = group; // We assign the whole collection here so we can reference to it later var subTabs = new TabControl(); if (SubTabControlStyle != null) { subTabs.Style = SubTabControlStyle; } newTab.Content = subTabs; Items.Add(newTab); SelectedItem = newTab; return(newTab); }