public static void RunWpf(Model.Startup startup, bool showSettingsWindow) { var app = new Application(); app.DispatcherUnhandledException += (s, e) => { MessageBox.Show(e.Exception.Message, VBASyncResources.MWTitle, MessageBoxButton.OK, MessageBoxImage.Error); e.Handled = true; }; var mw = new MainWindow(startup); mw.Show(); if (showSettingsWindow) { mw.SettingsMenu_Click(null, null); } app.Run(); }
internal MainViewModel(Model.Startup startup, Action onLoadIni) { Session = new SessionViewModel { Action = startup.Action, AutoRun = startup.AutoRun, FilePath = startup.FilePath, FolderPath = startup.FolderPath }; Settings = new SettingsViewModel { AddNewDocumentsToFile = startup.AddNewDocumentsToFile, AfterExtractHookContent = startup.AfterExtractHook?.Content, BeforePublishHookContent = startup.BeforePublishHook?.Content, DiffTool = startup.DiffTool, DiffToolParameters = startup.DiffToolParameters, IgnoreEmpty = startup.IgnoreEmpty, Language = startup.Language, Portable = startup.Portable, SearchRepositorySubdirectories = startup.SearchRepositorySubdirectories }; RecentFiles = new BindingList <string>(); foreach (var recentFile in startup.RecentFiles) { RecentFiles.Add(recentFile); } _onLoadIni = onLoadIni; _lastSessionPath = startup.LastSessionPath; BrowseForSessionCommand = new WpfCommand(v => BrowseForSession()); LoadLastSessionCommand = new WpfCommand(v => LoadLastSession(), v => LastSessionExists()); OpenRecentCommand = new WpfCommand(v => LoadRecent((string)v)); SaveSessionCommand = new WpfCommand(v => SaveSession()); // promote ListChanged events to PropertyChanged, so the // recent files list in the main menu stays up to date RecentFiles.ListChanged += (s, e) => OnPropertyChanged(nameof(RecentFiles)); }