private void Application_Startup(object sender, StartupEventArgs e) { try { LogDir = Path.Combine(Utils.GetDataFolderPath(), "logs"); GlobalDiagnosticsContext.Set("logDir", LogDir); Assembly thisAssembly = Assembly.GetAssembly(typeof(App)); var path = Path.GetDirectoryName(thisAssembly.Location); if (Environment.Is64BitProcess) { SevenZip.SevenZipBase.SetLibraryPath(Path.Combine(path, @"7z64.dll")); } else { SevenZip.SevenZipBase.SetLibraryPath(Path.Combine(path, @"7z.dll")); } ResourceManagerEx.Initialize(); TranslationSource.Instance.SetCulture(GrepSettings.Instance.Get <string>(GrepSettings.Key.CurrentCulture)); AppTheme.Instance.Initialize(); AppArgs = new CommandLineArgs(Environment.CommandLine); if (AppArgs.WarmUp) { MainWindow = new MainForm(false); MainWindow.Loaded += MainWindow_Loaded; } else if (AppArgs.ShowHelp) { MainWindow = new HelpWindow(AppArgs.GetHelpString(), AppArgs.InvalidArgument); } else { AppArgs.ApplyArgs(); } if (MainWindow == null) { MainWindow = new MainForm(); Utils.DeleteTempFolder(); } MainWindow.Show(); if (AppArgs.ExecuteSearch && MainWindow.DataContext != null) { ((MainViewModel)MainWindow.DataContext).SearchCommand.Execute(null); } } catch (Exception ex) { logger.Error(ex, "Failure in application startup"); MessageBox.Show(Localization.Properties.Resources.MessageBox_SomethingBrokeDownInDnGrep + LogDir, Localization.Properties.Resources.MessageBox_DnGrep, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, TranslationSource.Instance.FlowDirection); } }
private void Application_Startup(object sender, StartupEventArgs e) { try { LogDir = Path.Combine(Utils.GetDataFolderPath(), "logs"); GlobalDiagnosticsContext.Set("logDir", LogDir); Assembly thisAssembly = Assembly.GetAssembly(typeof(App)); var path = Path.GetDirectoryName(thisAssembly.Location); if (Environment.Is64BitProcess) { SevenZip.SevenZipBase.SetLibraryPath(Path.Combine(path, @"7z64.dll")); } else { SevenZip.SevenZipBase.SetLibraryPath(Path.Combine(path, @"7z.dll")); } AppTheme.Instance.Initialize(); AppArgs = new CommandLineArgs(Environment.CommandLine); if (AppArgs.WarmUp) { MainWindow = new MainForm(false); MainWindow.Loaded += MainWindow_Loaded; } else if (AppArgs.ShowHelp) { MainWindow = new HelpWindow(AppArgs.GetHelpString(), AppArgs.InvalidArgument); } else { AppArgs.ApplyArgs(); } if (MainWindow == null) { MainWindow = new MainForm(); Utils.DeleteTempFolder(); } MainWindow.Show(); if (AppArgs.ExecuteSearch && MainWindow.DataContext != null) { ((MainViewModel)MainWindow.DataContext).SearchCommand.Execute(null); } } catch (Exception ex) { logger.Error(ex, "Failure in application startup"); MessageBox.Show("Something broke down in dnGrep. See the error log for details: " + LogDir, "dnGrep", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Application_Startup(object sender, StartupEventArgs e) { try { AppTheme.Instance.Initialize(); CommandLineArgs args = new CommandLineArgs(Environment.CommandLine); if (args.WarmUp) { MainWindow = new MainForm(false); MainWindow.Loaded += MainWindow_Loaded; } else if (args.ShowHelp) { MainWindow = new HelpWindow(args.GetHelpString(), args.InvalidArgument); } else { args.ApplyArgs(); } if (MainWindow == null) { MainWindow = new MainForm(); Utils.DeleteTempFolder(); } MainWindow.Show(); if (args.ExecuteSearch && MainWindow.DataContext != null) { ((MainViewModel)MainWindow.DataContext).SearchCommand.Execute(null); } } catch (Exception ex) { logger.Log <Exception>(LogLevel.Error, ex.Message, ex); MessageBox.Show("Something broke down in the program. See event log for details.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }