private static void Main(string[] args) { Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartTimer = Stopwatch.StartNew(); // For be able to show startup time CLI = new CLIManager(args); CLI.ParseCommands(); if (CheckAdminTasks()) { return; // If ShareX opened just for be able to execute task as Admin } IsMultiInstance = CLI.IsCommandExist("multi", "m"); if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback, args)) { using (Mutex mutex = new Mutex(false, "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC")) // Required for installer { Run(); } if (restarting) { Process.Start(Application.ExecutablePath); } } }
private static void Main(string[] args) { Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartTimer = Stopwatch.StartNew(); // For be able to show startup time CLI = new CLIManager(args); CLI.ParseCommands(); IsMultiInstance = CLI.IsCommandExist("multi", "m"); if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback, args)) { using (Mutex mutex = new Mutex(false, "09949CF0-52B9-11E5-B970-0800200C9A66")) // Required for installer { Run(); } if (restarting) { Process.Start(Application.ExecutablePath); } } }
private static void Main(string[] args) { StartTimer = Stopwatch.StartNew(); IsMultiInstance = CLIHelper.CheckArgs(args, "m", "multi"); if (!IsMultiInstance && !ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback)) { return; } IsSilentRun = CLIHelper.CheckArgs(args, "s", "silent"); if (CLIHelper.CheckArgs(args, "p", "portable") && !Directory.Exists(PortablePersonalPath)) { Directory.CreateDirectory(PortablePersonalPath); } IsPortable = Directory.Exists(PortablePersonalPath); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MyLogger = new Logger(); DebugHelper.MyLogger = MyLogger; MyLogger.WriteLine("{0} {1} r{2} started", Application.ProductName, Application.ProductVersion, AppRevision); MyLogger.WriteLine("Operating system: " + Environment.OSVersion.VersionString); MyLogger.WriteLine("CommandLine: " + Environment.CommandLine); MyLogger.WriteLine("IsMultiInstance: " + IsMultiInstance); MyLogger.WriteLine("IsSilentRun: " + IsSilentRun); MyLogger.WriteLine("IsPortable: " + IsPortable); SettingsResetEvent = new ManualResetEvent(false); UploaderSettingsResetEvent = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(state => LoadSettings()); MyLogger.WriteLine("new MainForm() started"); mainForm = new MainForm(); MyLogger.WriteLine("new MainForm() finished"); if (Settings == null) { SettingsResetEvent.WaitOne(); } Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.Run(mainForm); Settings.Save(); MyLogger.WriteLine("ZUploader closing"); MyLogger.SaveLog(LogFilePath); }
private static void Main(string[] args) { Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartTimer = Stopwatch.StartNew(); IsMultiInstance = CLIHelper.CheckArgs(args, "multi", "m"); if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback)) { Run(args); } }
private static void Main(string[] args) { // Check for multi instance if (args != null && args.Length > 0) { CommandLineArg = args[0]; if (CommandLineArg.Contains("-m")) { Engine.IsMultiInstance = true; } else if (args.Length > 1 && args[0] == "/doc") { string fp = args[1]; if (File.Exists(fp)) { Process.Start(fp); } return; } } if (!Engine.IsMultiInstance) { if (!ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback)) { return; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(CurrentDomain_AssemblyLoad); if (Engine.TurnOn(new Engine.EngineOptions { KeyboardHook = true, ShowConfigWizard = true })) { Application.Run(MainForm = new ZScreen()); // Application.Run(CoreUI = new ZScreenSnap()); } }
private static void Main(string[] args) { Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartTimer = Stopwatch.StartNew(); // For be able to show startup time Arguments = args; if (CheckAdminTasks()) { return; // If ShareX opened just for be able to execute task as Admin } IsMultiInstance = CLIHelper.CheckArgs(Arguments, "multi", "m"); if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback, Arguments)) { using (Mutex mutex = new Mutex(false, "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC")) // Required for installer { Run(); } } }
/// <summary> /// On app start /// </summary> /// <param name="e">Startup EventArgs</param> protected override void OnStartup(StartupEventArgs e) { Settings.BESettings.LoadSettings(); Process process = Process.GetCurrentProcess(); process.PriorityClass = ProcessPriorityClass.Normal; // Set the current thread to run at 'Highest' Priority Thread thread = Thread.CurrentThread; thread.Priority = ThreadPriority.Highest; Boolean dmi = true; System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Current.DispatcherUnhandledException += this.Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += this.CurrentDomain_UnhandledException; System.Windows.Forms.Application.ThreadException += this.Application_ThreadException; if (!File.Exists(Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer\Settings.sqlite"))) { var beAppDataPath = Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer"); if (!Directory.Exists(beAppDataPath)) { Directory.CreateDirectory(beAppDataPath); } File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.sqlite"), Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer\Settings.sqlite")); } //// loads current Ribbon color theme try { switch (Settings.BESettings.CurrentTheme) { case "Dark": ThemeManager.ChangeAppTheme(this, "BaseDark"); break; default: ThemeManager.ChangeAppTheme(this, "BaseLight"); break; } } catch (Exception ex) { // MessageBox.Show(String.Format("An error occurred while trying to load the theme data from the Registry. \n\r \n\r{0}\n\r \n\rPlease let us know of this issue at http://bugtracker.better-explorer.com/", ex.Message), "RibbonTheme Error - " + ex.ToString()); MessageBox.Show( $"An error occurred while trying to load the theme data from the Registry. \n\r \n\rRibbonTheme Error - {ex}\n\r \n\rPlease let us know of this issue at http://bugtracker.better-explorer.com/", ex.Message); } if (e.Args.Any()) { dmi = e.Args.Length >= 1; IsStartWithStartupTab = e.Args.Contains("/norestore"); if (e.Args[0] != "-minimized") { this.Properties["cmd"] = e.Args[0]; } else { IsStartMinimized = true; } } if (!ApplicationInstanceManager.CreateSingleInstance(Assembly.GetExecutingAssembly().GetName().Name, this.SingleInstanceCallback) && dmi) { return; // exit, if same app. is running } base.OnStartup(e); try { this.SelectCulture(Settings.BESettings.Locale); } catch { // MessageBox.Show(String.Format("A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {0}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/.", Locale)); MessageBox.Show($"A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {Settings.BESettings.Locale}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/."); this.Shutdown(); } }
static void Main(string[] Args) { // Connect the application to console to have proper output there if requested. bool consoleRedirectionWorked = Win32Api.RedirectConsole(); // Start with command line parsing. string userDir = System.IO.Path.Combine(System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MySQL"), "Workbench"); Logger.InitLogger(userDir); if (!consoleRedirectionWorked) { Logger.LogError("Workbench", "Console redirection failed.\n"); } System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly(); string baseDir = System.IO.Path.GetDirectoryName(asm.Location); WbOptions wbOptions = new WbOptions(baseDir, userDir, true); if (!wbOptions.parse_args(Args, asm.Location)) { Logger.LogInfo("Workbench", "Command line params told us to shut down.\n"); return; } wbOptions.analyzeCommandLineArguments(); PrintInitialLogInfo(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Hook into the exception handling to establish our own handling. AppDomain currentDomain = AppDomain.CurrentDomain; // CLR currentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException); Application.ThreadException += // Windows Forms new System.Threading.ThreadExceptionEventHandler(OnGuiUnhandledException); // Read some early values which cannot be stored in the preferences (since they are loaded // later) from registry. bool singleInstance = true; string lastVersion = ""; string currentVersion = GetApplicationMetaInfo(ApplicationMetaInfo.Version); Logger.LogInfo("Workbench", "Current version given by meta info is: " + currentVersion + '\n'); RegistryKey wbKey = Registry.CurrentUser; try { wbKey = wbKey.OpenSubKey(@"Software\Oracle\MySQL Workbench", false); if (wbKey != null) { if (wbKey.GetValue("DisableSingleInstance", 0).ToString() == "1") { singleInstance = false; } lastVersion = wbKey.GetValue("LastStartedAs", "").ToString(); } else { Registry.CurrentUser.CreateSubKey(@"Software\Oracle\MySQL Workbench"); } } catch (Exception e) { Logger.LogError("Workbench", "Error while checking single instance reg key: " + e.Message + '\n'); } finally { if (wbKey != null) { wbKey.Close(); } } // First check if this is the first instance of Workbench (if enabled). // The setting for single-instance is stored in the registry as it is Windows-only // and loading of the application settings happens later. if (singleInstance) { if (!ApplicationInstanceManager.CreateSingleInstance( Assembly.GetExecutingAssembly().GetName().Name, Args, SingleInstanceCallback)) { Logger.LogInfo("Workbench", "Exiting as another instance of WB is already running.\n"); return; } } // Give the main thread a proper name, so we can later check for it when needed. Thread.CurrentThread.Name = "mainthread"; // Change the working dir to to application path. // This is necessary because all our internal data files etc. are located under the app dir // and WB could have been called from a different dir. string workdir = System.IO.Directory.GetCurrentDirectory(); System.IO.Directory.SetCurrentDirectory(baseDir); // Next check if this is the first start of a new version of WB. In this case remove all // compiled python files. They will be automatically recreated and can produce problems // under certain circumstances. if (currentVersion != lastVersion) { Logger.LogInfo("Workbench", "This is the first start of a new version. Doing some clean up.\n"); List <string> failed = new List <string>(); RemoveCompiledPythonFiles(baseDir, failed); // TODO: decide if we wanna ask the user to remove those files manually or just ignore them. } // Some people don't have c:\windows\system32 in PATH, so we need to set it here // for WBA to find the needed commands String systemFolder = Environment.GetFolderPath(Environment.SpecialFolder.System); String cleanedPath = Environment.GetEnvironmentVariable("PATH"); String [] paths = cleanedPath.Split(new char[] { ';' }); cleanedPath = ""; // Strip all python related dirs from PATH to avoid conflicts with other Python installations. foreach (String path in paths) { if (!path.ToLower().Contains("python")) { cleanedPath = cleanedPath + ";" + path; } } Environment.SetEnvironmentVariable("PATH", systemFolder + cleanedPath); Logger.LogInfo("Workbench", "Setting PATH to: " + systemFolder + cleanedPath + '\n'); // Clear PYTHONPATH environment variable, as we do not need it but our python impl // seriously gets confused with it. Environment.SetEnvironmentVariable("PYTHONPATH", workdir + "\\python\\Lib;" + workdir + "\\python\\DLLs;" + workdir + "\\python"); Environment.SetEnvironmentVariable("PYTHONHOME", workdir + "\\python"); // Initialize forms stuff. MySQL.Forms.Manager formsManager = MySQL.Forms.Manager.get_instance(); // Creates the singleton. // init extra mforms things that are delegated to the frontend, indirectly through RecordsetWrapper in wbpublic MySQL.Grt.Db.RecordsetWrapper.init_mforms(MySQL.Grt.Db.RecordsetView.create); #region Runtime path check // Currently WB has trouble running from a path containing non-ASCII characters. // Actually, our third party libraries have (namely lua, python, ctemplate), // as they don't consider Unicode file names (encoded as UTF-8) which leads to file-not-found // errors. Refuse to work in such a path for now. foreach (Char c in baseDir) { if (c > 0x7f) { MessageBox.Show("MySQL Workbench cannot be executed from a path that contains non-ASCII characters.\n" + "This problem is imposed by used third-party libraries.\n" + "Please run this application from the default installation path or at least a path which is all ASCII characters.", "MySQL Workbench Execution Problem", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } #endregion #region Release check (outdated beta or rc version) // check the date of the executable and suggest to install a new version if this is a beta or rc if (GetApplicationMetaInfo(ApplicationMetaInfo.Configuration).ToUpper().IndexOf("BETA") >= 0 || GetApplicationMetaInfo(ApplicationMetaInfo.Configuration).ToUpper().IndexOf("RC") >= 0) { DateTime fileDate = System.IO.File.GetCreationTime(Application.ExecutablePath); if (DateTime.Now.Subtract(fileDate).TotalDays > 45) { Logger.LogInfo("Workbench", "Found an old WB pre release. Showing warning.\n"); if (MessageBox.Show("This version of MySQL Workbench is older than 45 days and most probably outdated. " + Environment.NewLine + "It is recommended to upgrade to a newer version if available. " + Environment.NewLine + "Press [OK] to check for a new version and exit the application. " + "Press [Cancel] to continue using this version.", "MySQL Workbench Version Outdated", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.OK) { CheckForNewVersion(); return; } } } #endregion #region Variables and Splashscreen #endregion #region Initialize GRT // Try to instantiate the Workbench context and the GRT Manager and catch exceptions try { // Create Workbench Context wbContext = new WbContext(wbOptions.Verbose); if (wbContext != null) { // Create the GRT Manager instance grtManager = wbContext.get_grt_manager(); } } catch (Exception ex) { HandleException(ex); } #endregion // If the Workbench Context and GRT Manager were successfully created, // initialize the application if (wbContext != null && grtManager != null) { #region Initialize Callbacks and Mainform mainForm = new MainForm(wbContext); // Initialize the Workbench context ManagedApplication formsApplication = new ManagedApplication( new AppCommandDelegate(mainForm.ApplicationCommand), mainForm.dockDelegate); callbacks = new WbFrontendCallbacks( new WbFrontendCallbacks.StrStrStrStrDelegate(mainForm.ShowFileDialog), new WbFrontendCallbacks.VoidStrDelegate(mainForm.ShowStatusText), new WbFrontendCallbacks.BoolStrStrFloatDelegate(mainForm.ShowProgress), new WbFrontendCallbacks.CanvasViewStringStringDelegate(mainForm.CreateNewDiagram), new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.DestroyView), new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.SwitchedView), new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.ToolChanged), new WbFrontendCallbacks.IntPtrGRTManagerModuleStrStrGrtListFlagsDelegate(mainForm.OpenPlugin), new WbFrontendCallbacks.VoidIntPtrDelegate(mainForm.ShowPlugin), new WbFrontendCallbacks.VoidIntPtrDelegate(mainForm.HidePlugin), new WbFrontendCallbacks.VoidRefreshTypeStringIntPtrDelegate(mainForm.RefreshGUI), new WbFrontendCallbacks.VoidBoolDelegate(mainForm.LockGUI), new WbFrontendCallbacks.VoidStrDelegate(mainForm.PerformCommand), new WbFrontendCallbacks.BoolDelegate(mainForm.QuitApplication)); // TODO: check return value and show error message. // Currently the return value is always true. In case of an error an exception is raised. // That should change. wbContext.init(callbacks, wbOptions, new WbContext.VoidStrUIFormDelegate(mainForm.CreateMainFormView) ); // command registration must be done after WBContext init mainForm.PostInit(); // Set the Application.Idle event handler Application.Idle += new EventHandler(OnApplicationIdle); // Don't call the idle handler too often. timer = new System.Windows.Forms.Timer(); timer.Interval = 100; timer.Tick += new EventHandler(timer_Tick); timer.Start(); // Trigger GRT idle tasks grtManager.perform_idle_tasks(); // Setup Menus wbContext.validate_edit_menu(); mainForm.Show(); Logger.LogInfo("Workbench", "UI is up\n"); // Tell the backend our main UI is ready. This will also load a model if it was given via command line // and opens the overview form for it. wbContext.finished_loading(wbOptions); // Right before we go to work and everything was loaded write the current version to registry // to allow us later to find out if we ran a new version the first time. try { wbKey = Registry.CurrentUser.OpenSubKey(@"Software\Oracle\MySQL Workbench", true); if (wbKey != null) { wbKey.SetValue("LastStartedAs", currentVersion); } } catch (Exception e) { Logger.LogError("Workbench", "Couldn't write regkey LastStartedAs: " + e.Message + '\n'); } finally { if (wbKey != null) { wbKey.Close(); } } // Start the Application if we are not already shutting down. if (!wbContext.is_quitting()) { try { Logger.LogInfo("Workbench", "Running the application\n"); Application.Run(new ApplicationContext(mainForm)); } catch (Exception e) { HandleException(e); } } #endregion Logger.LogInfo("Workbench", "Shutting down Workbench\n"); timer.Stop(); timer.Dispose(); // shutdown wb context if (wbContext != null) { while (wbContext.is_busy()) { wbContext.flush_idle_tasks(); } wbContext.finalize(); wbContext.Dispose(); } formsApplication.Dispose(); formsManager.Dispose(); GC.Collect(); } Win32Api.ReleaseConsole(); Logger.LogInfo("Workbench", "Done\n"); }
protected override void OnStartup(StartupEventArgs e) { Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; try { bool dmi = true; if (e.Args != null && e.Args.Count() > 0) { if (e.Args[0] == "/nw") { dmi = false; } else if (e.Args[0] == "/norestore") { isStartWithStartupTab = true; } else { if (e.Args[0] != "-minimized") { //if (e.Args != null && e.Args.Count() > 0) //{ this.Properties["cmd"] = e.Args[0]; if (e.Args.Count() > 1) { if (e.Args[1] == "/nw") { dmi = false; if (e.Args.Count() > 2) { if (e.Args[2] == "/norestore") { isStartWithStartupTab = true; } } } else if (e.Args[1] == "/norestore") { isStartWithStartupTab = true; if (e.Args.Count() > 2) { if (e.Args[2] == "/nw") { dmi = false; } } } } //} } else { isStartMinimized = true; } if (dmi == true) { isStartNewWindows = false; if (!ApplicationInstanceManager.CreateSingleInstance( Assembly.GetExecutingAssembly().GetName().Name, SingleInstanceCallback)) { return; // exit, if same app. is running } } else { isStartNewWindows = true; } } } else { if (!ApplicationInstanceManager.CreateSingleInstance( Assembly.GetExecutingAssembly().GetName().Name, SingleInstanceCallback)) { return; // exit, if same app. is running } } } catch { //MessageBox.Show("There was an error in the startup procedure related to consolidating multiple instances. Please let us know of this issue at http://bugtracker.better-explorer.com/", "Startup Error", MessageBoxButton.OK, MessageBoxImage.Error); } string Locale = ""; try { base.OnStartup(e); RegistryKey rk = Registry.CurrentUser; try { RegistryKey rks = rk.OpenSubKey(@"Software\BExplorer", true); if (rks == null) { rks = rk.CreateSubKey(@"Software\BExplorer"); } var regLocale = rks.GetValue(@"Locale", "").ToString(); if (String.IsNullOrEmpty(regLocale)) { Locale = CultureInfo.CurrentUICulture.EnglishName; } else { Locale = regLocale; } SelectCulture(Locale); rks.Close(); } catch { } rk.Close(); } catch { MessageBox.Show(String.Format("A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {0}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/.", Locale)); Shutdown(); } }
protected override void OnStartup(StartupEventArgs e) { System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess(); process.PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal; // Set the current thread to run at 'Highest' Priority Thread thread = System.Threading.Thread.CurrentThread; thread.Priority = ThreadPriority.Highest; string locale = ""; bool dmi = true; Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //System.AppDomain.CurrentDomain.BaseDirectory if (!File.Exists(Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer\Settings.sqlite"))) { File.Copy(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Settings.sqlite"), Path.Combine(KnownFolders.RoamingAppData.ParsingName, @"BExplorer\Settings.sqlite")); } RegistryKey rk = Registry.CurrentUser, rks = rk.OpenSubKey(@"Software\BExplorer", true); if (rks == null) { rk.CreateSubKey(@"Software\BExplorer"); rks = rk.OpenSubKey(@"Software\BExplorer", true); } //// loads current Ribbon color theme try { var Color = Convert.ToString(rks.GetValue("CurrentTheme", "Blue")); var owner = Application.Current.MainWindow; if (owner != null) { owner.Resources.BeginInit(); if (owner.Resources.MergedDictionaries.Count > 0) { owner.Resources.MergedDictionaries.RemoveAt(0); } if (string.IsNullOrEmpty(Color) == false) { owner.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(Color) }); } owner.Resources.EndInit(); } Application.Current.Resources.BeginInit(); Application.Current.Resources.MergedDictionaries.RemoveAt(1); switch (Color) { case "Blue": case "Silver": case "Black": case "Green": Application.Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri($"pack://application:,,,/Fluent;component/Themes/Office2010/{Color}.xaml") }); break; case "Metro": Application.Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2013/Generic.xaml") }); break; default: Application.Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri($"pack://application:,,,/Fluent;component/Themes/Office2010/{Color}.xaml") }); break; } Application.Current.Resources.EndInit(); if (owner is RibbonWindow) { owner.Style = null; owner.Style = owner.FindResource("RibbonWindowStyle") as Style; owner.Style = null; // Resize Window to work around alignment issues caused by theme change ++owner.Width; --owner.Width; } } catch (Exception ex) { //MessageBox.Show(String.Format("An error occurred while trying to load the theme data from the Registry. \n\r \n\r{0}\n\r \n\rPlease let us know of this issue at http://bugtracker.better-explorer.com/", ex.Message), "RibbonTheme Error - " + ex.ToString()); MessageBox.Show($"An error occurred while trying to load the theme data from the Registry. \n\r \n\rRibbonTheme Error - {ex.ToString()}\n\r \n\rPlease let us know of this issue at http://bugtracker.better-explorer.com/", ex.Message); } rks.Close(); rk.Close(); if (e.Args.Any()) { dmi = e.Args.Length >= 1; IsStartWithStartupTab = e.Args.Contains("/norestore"); if (e.Args[0] != "-minimized") { this.Properties["cmd"] = e.Args[0]; } else { IsStartMinimized = true; } } if (dmi && !ApplicationInstanceManager.CreateSingleInstance(Assembly.GetExecutingAssembly().GetName().Name, SingleInstanceCallback)) { return; // exit, if same app. is running } base.OnStartup(e); try { var regLocale = Utilities.GetRegistryValue("Locale", "").ToString(); locale = String.IsNullOrEmpty(regLocale) ? CultureInfo.CurrentUICulture.Name : regLocale; SelectCulture(locale); } catch { //MessageBox.Show(String.Format("A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {0}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/.", Locale)); MessageBox.Show($"A problem occurred while loading the locale from the Registry. This was the value in the Registry: \r\n \r\n {locale}\r\n \r\nPlease report this issue at http://bugtracker.better-explorer.com/."); Shutdown(); } }