/// <inheritdoc /> protected override void OnActivate(CancelEventArgs e) { var themeManager = new ThemeManager(); var windowLayoutManager = new WindowLayoutManager(); IEnumerable <Theme> themes = themeManager.GetInstalledThemes(); IEnumerable <WindowLayout> windowLayouts = windowLayoutManager.GetWindowLayouts(); string currentTheme1 = this.Theme1Id; string currentTheme2 = this.Theme2Id; string currentLayout1 = this.WindowLayout1Key; string currentLayout2 = this.WindowLayout2Key; windowLayouts = windowLayouts.Union(new[] { new WindowLayout(string.Empty, -1, "Do not change window layout") }); this.UpdateCollectionView(this.AvailableThemes1, themes); this.UpdateCollectionView(this.AvailableThemes2, themes); this.UpdateCollectionView(this.AvailableWindowLayouts, windowLayouts); this.Theme1Id = currentTheme1; this.Theme2Id = currentTheme2; this.WindowLayout1Key = currentLayout1; this.WindowLayout2Key = currentLayout2; base.OnActivate(e); }
/// <summary>Initializes a new instance of the <see cref="ThemeSwitcherOptionsDialogPage" /> class.</summary> public ThemeSwitcherOptionsDialogPage() { ThreadHelper.ThrowIfNotOnUIThread(); var themeManager = new ThemeManager(); var windowLayoutManager = new WindowLayoutManager(); var themes1 = new ObservableCollection <Theme>(themeManager.GetInstalledThemes()); var themes2 = new ObservableCollection <Theme>(themeManager.GetInstalledThemes()); var windowLayouts = new ObservableCollection <WindowLayout>(windowLayoutManager.GetWindowLayouts()); windowLayouts.Add(new WindowLayout(string.Empty, -1, "Do not change window layout")); this.AvailableThemes1 = CollectionViewSource.GetDefaultView(themes1); this.AvailableThemes1.SortDescriptions.Add(new SortDescription(nameof(Theme.DisplayName), ListSortDirection.Ascending)); this.AvailableThemes1.Filter = theme => !((Theme)theme).Id.Equals(this.Theme2Id); this.AvailableThemes2 = CollectionViewSource.GetDefaultView(themes2); this.AvailableThemes2.SortDescriptions.Add(new SortDescription(nameof(Theme.DisplayName), ListSortDirection.Ascending)); this.AvailableThemes2.Filter = theme => !((Theme)theme).Id.Equals(this.Theme1Id); this.AvailableWindowLayouts = CollectionViewSource.GetDefaultView(windowLayouts); this.AvailableWindowLayouts.SortDescriptions.Add(new SortDescription(nameof(WindowLayout.Index), ListSortDirection.Ascending)); }