private void OnStartup(Object sender, StartupEventArgs e) { if ((Native.GetKeyState(System.Windows.Forms.Keys.ShiftKey) & KeyStates.Down) == KeyStates.Down) { // Reset User Settings when Shift is held down during start up. GlobalSettings.Default.Reset(); GlobalSettings.Default.PromptUser = true; // Clear app bin cache. var binCache = ToolboxUpdater.GetBinCachePath(); if (Directory.Exists(binCache)) { try { Directory.Delete(binCache, true); } catch { // File is locked and cannot be deleted at this time. } } } LocalizeDictionary.Instance.SetCurrentThreadCulture = false; LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode); Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture; Splasher.Splash = new WindowSplashScreen(); Splasher.ShowSplash(); log4net.Config.XmlConfigurator.Configure(); var update = CodeplexReleases.CheckForUpdates(); if (update != null) { var dialogResult = MessageBox.Show(string.Format(Res.DialogNewVersionMessage, update.Version), Res.DialogNewVersionTitle, MessageBoxButton.YesNo, MessageBoxImage.Information); if (dialogResult == MessageBoxResult.Yes) { Process.Start(update.Link); GlobalSettings.Default.Save(); Application.Current.Shutdown(); return; } if (dialogResult == MessageBoxResult.No) { GlobalSettings.Default.IgnoreUpdateVersion = update.Version.ToString(); } } // Configure service locator. ServiceLocator.RegisterSingleton <IDialogService, DialogService>(); ServiceLocator.Register <IOpenFileDialog, OpenFileDialogViewModel>(); ServiceLocator.Register <ISaveFileDialog, SaveFileDialogViewModel>(); ServiceLocator.Register <IColorDialog, ColorDialogViewModel>(); ServiceLocator.Register <IFolderBrowserDialog, FolderBrowserDialogViewModel>(); _toolboxApplication = new CoreToolbox(); if (_toolboxApplication.Init(e.Args)) { _toolboxApplication.Load(e.Args); } else { Application.Current.Shutdown(); } }
private void OnStartup(Object sender, StartupEventArgs e) { if ((NativeMethods.GetKeyState(System.Windows.Forms.Keys.ShiftKey) & KeyStates.Down) == KeyStates.Down) { // Reset User Settings when Shift is held down during start up. GlobalSettings.Default.Reset(); GlobalSettings.Default.PromptUser = true; // Clear app bin cache. var binCache = ToolboxUpdater.GetBinCachePath(); if (Directory.Exists(binCache)) { try { Directory.Delete(binCache, true); } catch { // File is locked and cannot be deleted at this time. } } } LocalizeDictionary.Instance.SetCurrentThreadCulture = false; LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode); Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture; Splasher.Splash = new WindowSplashScreen(); Splasher.ShowSplash(); log4net.Config.XmlConfigurator.Configure(); var update = CodeRepositoryReleases.CheckForUpdates(CodeRepositoryType.GitHub, SEToolbox.Properties.Resources.GlobalUpdatesUrl); if (update != null) { var dialogResult = MessageBox.Show(string.Format(Res.DialogNewVersionMessage, update.Version), Res.DialogNewVersionTitle, MessageBoxButton.YesNo, MessageBoxImage.Information); if (dialogResult == MessageBoxResult.Yes) { Process.Start(update.Link); GlobalSettings.Default.Save(); Application.Current.Shutdown(); return; } if (dialogResult == MessageBoxResult.No) { GlobalSettings.Default.IgnoreUpdateVersion = update.Version.ToString(); } } // Configure service locator. ServiceLocator.RegisterSingleton<IDialogService, DialogService>(); ServiceLocator.Register<IOpenFileDialog, OpenFileDialogViewModel>(); ServiceLocator.Register<ISaveFileDialog, SaveFileDialogViewModel>(); ServiceLocator.Register<IColorDialog, ColorDialogViewModel>(); ServiceLocator.Register<IFolderBrowserDialog, FolderBrowserDialogViewModel>(); System.Windows.FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false; _toolboxApplication = new CoreToolbox(); if (_toolboxApplication.Init(e.Args)) _toolboxApplication.Load(e.Args); else Application.Current.Shutdown(); }