/// <summary> /// Initializes a new instance of the <see cref="OptionsWindow"/> class. /// </summary> /// <param name="optionPageIndex">The index of the page to display.</param> /// <param name="theme">The theme to use.</param> /// <param name="saveBeforeCompiling">True if documents must be saved before compiling.</param> /// <param name="optionPages">The list of controls for each option category.</param> public OptionsWindow(int optionPageIndex, ThemeOption theme, bool saveBeforeCompiling, ICollection <TabItem> optionPages) { OptionPageIndex = optionPageIndex; Theme = theme; SaveBeforeCompiling = saveBeforeCompiling; InitializeComponent(); DataContext = this; Loaded += OnLoaded; Closing += OnClosing; List <TabItem> TemplateList = new List <TabItem>(); BackupTable = new Dictionary <IOptionPageDataContext, IOptionPageDataContext>(); TemplateList.Add((TabItem)FindResource("PageTheme")); TemplateList.Add((TabItem)FindResource("PageCompiler")); if (optionPages != null) { foreach (TabItem Page in optionPages) { if (Page.DataContext is IOptionPageDataContext AsOptionPageDataContext) { BackupTable.Add(AsOptionPageDataContext, AsOptionPageDataContext.Backup()); } TemplateList.Add(Page); } } Pages = TemplateList; }
public OptionsWindow(int optionPageIndex, ThemeOption theme, bool saveBeforeCompiling, ICollection <TabItem> optionPages) { this.OptionPageIndex = optionPageIndex; this.Theme = theme; this.SaveBeforeCompiling = saveBeforeCompiling; this.UnusedCtrl = null; InitializeComponent(); DataContext = this; Loaded += OnLoaded; List <TabItem> TemplateList = new List <TabItem>(); BackupTable = new Dictionary <IOptionPageDataContext, IOptionPageDataContext>(); TemplateList.Add(FindResource("PageTheme") as TabItem); TemplateList.Add(FindResource("PageCompiler") as TabItem); if (optionPages != null) { foreach (TabItem Page in optionPages) { IOptionPageDataContext AsOptionPageDataContext; if ((AsOptionPageDataContext = Page.DataContext as IOptionPageDataContext) != null) { BackupTable.Add(AsOptionPageDataContext, AsOptionPageDataContext.Backup()); } TemplateList.Add(Page); } } Pages = TemplateList; }