private async void btnImport_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Filter = "ShareX backup (*.sxb)|*.sxb|All files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { btnExport.Enabled = false; btnImport.Enabled = false; pbExportImport.Location = btnImport.Location; pbExportImport.Visible = true; string importPath = ofd.FileName; DebugHelper.WriteLine($"Import started: {importPath}"); await Task.Run(() => { SettingManager.Import(importPath); SettingManager.LoadAllSettings(); }); if (!IsDisposed) { UpdateControls(); pbExportImport.Visible = false; btnExport.Enabled = true; btnImport.Enabled = true; } LanguageHelper.ChangeLanguage(Program.Settings.Language); Program.MainForm.UpdateControls(); DebugHelper.WriteLine($"Import completed: {importPath}"); } } }
private static void Run() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IsSilentRun = CLI.IsCommandExist("silent", "s"); IsSandbox = CLI.IsCommandExist("sandbox"); if (!IsSandbox) { IsPortable = CLI.IsCommandExist("portable", "p"); if (IsPortable) { CustomPersonalPath = PortablePersonalPath; } else { CheckPersonalPathConfig(); } if (!Directory.Exists(PersonalPath)) { try { Directory.CreateDirectory(PersonalPath); } catch (Exception e) { MessageBox.Show(Resources.Program_Run_Unable_to_create_folder_ + string.Format(" \"{0}\"\r\n\r\n{1}", PersonalPath, e), "ShareX - " + Resources.Program_Run_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); CustomPersonalPath = ""; } } } #if STEAM IsFirstTimeConfig = CLI.IsCommandExist("SteamConfig"); #endif NoHotkeys = CLI.IsCommandExist("NoHotkeys"); DebugHelper.WriteLine($"{Title} {Build} build"); DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString); DebugHelper.WriteLine("Command line: " + Environment.CommandLine); DebugHelper.WriteLine("Personal path: " + PersonalPath); LoadProgramSettings(); UploaderSettingsResetEvent = new ManualResetEvent(false); HotkeySettingsResetEvent = new ManualResetEvent(false); TaskEx.Run(LoadSettings); LanguageHelper.ChangeLanguage(Settings.Language); DebugHelper.WriteLine("MainForm init started"); MainForm = new MainForm(); DebugHelper.WriteLine("MainForm init finished"); Application.Run(MainForm); if (WatchFolderManager != null) { WatchFolderManager.Dispose(); } SaveSettings(); BackupSettings(); DebugHelper.Logger.Async = false; DebugHelper.WriteLine("ShareX closing"); }
private static void Run() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s"); IsSandbox = CLIHelper.CheckArgs(Arguments, "sandbox"); if (!IsSandbox) { IsPortable = CLIHelper.CheckArgs(Arguments, "portable", "p"); if (IsPortable) { CustomPersonalPath = PortablePersonalPath; } else { CheckPersonalPathConfig(); } if (!Directory.Exists(PersonalPath)) { try { Directory.CreateDirectory(PersonalPath); } catch (Exception e) { MessageBox.Show("Unable to create folder: \"" + PersonalPath + "\"\r\n\r\n" + e.ToString(), "ShareX - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); CustomPersonalPath = ""; } } } DebugHelper.WriteLine("{0} started", Title); DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString); DebugHelper.WriteLine("Command line: " + Environment.CommandLine); DebugHelper.WriteLine("Personal path: " + PersonalPath); string gitHash = GetGitHash(); if (!string.IsNullOrEmpty(gitHash)) { DebugHelper.WriteLine("Git: https://github.com/ShareX/ShareX/tree/" + gitHash); } LoadProgramSettings(); UploaderSettingsResetEvent = new ManualResetEvent(false); HotkeySettingsResetEvent = new ManualResetEvent(false); TaskEx.Run(() => LoadSettings()); LanguageHelper.ChangeLanguage(Settings.Language); DebugHelper.WriteLine("MainForm init started"); MainForm = new MainForm(); DebugHelper.WriteLine("MainForm init finished"); Application.Run(MainForm); if (WatchFolderManager != null) { WatchFolderManager.Dispose(); } SaveSettings(); BackupSettings(); DebugHelper.WriteLine("ShareX closing"); DebugHelper.Logger.SaveLog(LogsFilePath); }