protected override void OnStartup(StartupEventArgs e) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\SaveData"); //create if not exist SaveData.LoadConfig(); #region language //CultureInfo.CurrentCulture = new CultureInfo("ru-RU", false); //not working? System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(SaveData.config.Language); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); //zh-CN #endregion language if (!SaveData.config.SafeShutdown) { //clearing previous wp persisting image if any. SetupDesktop.RefreshDesktop(); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\"); string fileName = DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".txt"; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\" + fileName)) { fileName = Path.GetRandomFileName() + ".txt"; } try { File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\logfile.txt", AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\" + fileName); } catch (IOException e1) { System.Diagnostics.Debug.WriteLine(e1.ToString()); } var result = MessageBox.Show(Props.Resources.msgSafeModeWarning + AppDomain.CurrentDomain.BaseDirectory + "ErrorLogs\\" + fileName , Props.Resources.txtLivelyErrorMsgTitle, MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { SetupDesktop.wallpapers.Clear(); SaveData.SaveWallpaperLayout(); //deleting saved wallpaper arrangements. } } SaveData.config.SafeShutdown = false; SaveData.SaveConfig(); base.OnStartup(e); SetupExceptionHandling(); w = new MainWindow(); if (SaveData.config.IsFirstRun) { //SaveData.config.isFirstRun = false; //only after minimizing to tray isFirstRun is set to false. SaveData.SaveConfig(); //creating disk file temp, not needed! w.Show(); w.UpdateWallpaperLibrary(); HelpWindow hw = new HelpWindow { Owner = w, WindowStartupLocation = WindowStartupLocation.CenterOwner }; hw.ShowDialog(); } if (SaveData.config.IsRestart) { SaveData.config.IsRestart = false; SaveData.SaveConfig(); //w.WindowStartupLocation = WindowStartupLocation.Manual; w.Show(); w.UpdateWallpaperLibrary(); w.tabControl1.SelectedIndex = 2; //settings tab } }
protected override void OnStartup(StartupEventArgs e) { //delete residue tempfiles FileOperations.EmptyDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\tmpdata"); //create directories if not exist Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\SaveData"); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\wallpapers"); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\SaveData\\wptmp"); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\tmpdata"); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\tmpdata\\wpdata"); SaveData.LoadConfig(); #region language //CultureInfo.CurrentCulture = new CultureInfo("ru-RU", false); //not working? System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(SaveData.config.Language); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); //zh-CN #endregion language if (!SaveData.config.SafeShutdown) { //clearing previous wp persisting image if any. SetupDesktop.RefreshDesktop(); Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\"); string fileName = DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".txt"; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\" + fileName)) { fileName = Path.GetRandomFileName() + ".txt"; } try { File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\logfile.txt", AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLogs\\" + fileName); } catch (IOException e1) { System.Diagnostics.Debug.WriteLine(e1.ToString()); } var result = MessageBox.Show(Props.Resources.msgSafeModeWarning + AppDomain.CurrentDomain.BaseDirectory + "ErrorLogs\\" + fileName , Props.Resources.txtLivelyErrorMsgTitle, MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { SetupDesktop.wallpapers.Clear(); SaveData.SaveWallpaperLayout(); //deleting saved wallpaper arrangements. } } SaveData.config.SafeShutdown = false; SaveData.SaveConfig(); #region theme // add custom accent and theme resource dictionaries to the ThemeManager // you should replace MahAppsMetroThemesSample with your application name // and correct place where your custom accent lives //ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/CustomAccent1.xaml")); // get the current app style (theme and accent) from the application // you can then use the current theme and custom accent instead set a new theme Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); // setting accent & theme ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(SaveData.livelyThemes[SaveData.config.Theme].Accent), ThemeManager.GetAppTheme(SaveData.livelyThemes[SaveData.config.Theme].Base)); // or appStyle.Item1 // now change app style to the custom accent and current theme //ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("CustomAccent1"), ThemeManager.GetAppTheme(SaveData.livelyThemes[SaveData.config.Theme].Base)); #endregion theme base.OnStartup(e); SetupExceptionHandling(); w = new MainWindow(); if (SaveData.config.IsFirstRun) { //SaveData.config.isFirstRun = false; //only after minimizing to tray isFirstRun is set to false. SaveData.SaveConfig(); //creating disk file temp, not needed! w.Show(); w.UpdateWallpaperLibrary(); HelpWindow hw = new HelpWindow { Owner = w, WindowStartupLocation = WindowStartupLocation.CenterOwner }; hw.ShowDialog(); } if (SaveData.config.IsRestart) { SaveData.config.IsRestart = false; SaveData.SaveConfig(); w.Show(); w.UpdateWallpaperLibrary(); //w.ShowMainWindow(); w.tabControl1.SelectedIndex = 2; //settings tab //SetupDesktop.SetFocus(); //w.Activate(); } }