public App(string configFile) { MessageHandlers.RegisterMessageHandlers(this); #if PORTABLE ViewerConfigPath = !string.IsNullOrWhiteSpace(configFile) ? configFile : DefaultViewerConfigFileName; #else ViewerConfigPath = !string.IsNullOrWhiteSpace(configFile) ? configFile : GetAppDataViewerConfigPath(); #endif AppViewModelParameters parameters = new AppViewModelParameters() { ProgramTitle = Assembly.GetEntryAssembly().GetName().Name, FullVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(), ViewerConfig = LoadConfig(), DoOnUIThread = (action) => { Dispatcher.Invoke(action); }, TextToClipboard = TextToClipboard, InternalGameEngineConfig = InternalGameEngineConfig, // Should be the unmodified defaults }; if (parameters.ViewerConfig.EngineType == EngineType.CommandLine) { parameters.EngineWrapper = new CLIEngineWrapper(parameters.ViewerConfig.EngineCommandLine); } AppViewModel.Init(parameters); Exit += App_Exit; }
public App(string configFile) { MessageHandlers.RegisterMessageHandlers(this); AppViewModel.Init(LoadConfig(configFile), (action) => { Dispatcher.Invoke(action); }); Exit += App_Exit; }
private void App_Exit(object sender, ExitEventArgs e) { try { SaveConfig(); AppVM.EngineWrapper.StopEngine(); } catch (Exception ex) { ExceptionUtils.HandleException(ex); } finally { MessageHandlers.UnregisterMessageHandlers(this); } }