private static bool OnGUIInitInstance(object sender) { GUIProgram program = (GUIProgram)sender; eraserClient = new RemoteExecutorServer(); EraserSettings settings = EraserSettings.Get(); System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(settings.Language); Application.SafeTopLevelCaptionFormat = S._("Eraser"); SettingsCompatibility.Execute(); try { if (System.IO.File.Exists(TaskListPath)) { using (FileStream stream = new FileStream(TaskListPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { eraserClient.Tasks.LoadFromStream(stream); } } } catch (SerializationException e) { System.IO.File.Delete(TaskListPath); MessageBox.Show(S._("Could not load task list. All task entries have " + "been lost. The error returned was: {0}", e.Message), S._("Eraser"), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, S.IsRightToLeft(null) ? MessageBoxOptions.RtlReading : 0); } program.MainForm = new MainForm(); program.MainForm.CreateControl(); bool showMainForm = true; foreach (string param in program.CommandLine) { switch (param) { case "--atRestart": eraserClient.QueueRestartTasks(); goto case "--quiet"; case "--quiet": showMainForm = false; break; } } eraserClient.Run(); return showMainForm; }
private static void OnGUIInitInstance(object sender, InitInstanceEventArgs e) { GuiProgram program = (GuiProgram)sender; eraserClient = new RemoteExecutorServer(); EraserSettings settings = EraserSettings.Get(); Thread.CurrentThread.CurrentUICulture = new CultureInfo(settings.Language); Application.SafeTopLevelCaptionFormat = S._("Eraser"); SettingsCompatibility.Execute(); try { if (File.Exists(TaskListPath)) { using (FileStream stream = new FileStream(TaskListPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { eraserClient.Tasks.LoadFromStream(stream); } } } catch (SerializationException ex) { System.IO.File.Delete(TaskListPath); MessageBox.Show(S._("Could not load task list. All task entries have " + "been lost. The error returned was: {0}", ex.Message), S._("Eraser"), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, S.IsRightToLeft(null) ? MessageBoxOptions.RtlReading : 0); } program.MainForm = new MainForm(); GuiArguments arguments = new GuiArguments(); Args.Parse(program.CommandLine, CommandLinePrefixes, CommandLineSeparators, arguments); e.ShowMainForm = !arguments.AtRestart && !arguments.Quiet; if (arguments.AtRestart) eraserClient.QueueRestartTasks(); eraserClient.Run(); }