/// <summary> /// The main entry point for the application. /// </summary> public static int Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); NetUtils.ApplyProxy(); if (WindowsUtils.IsWindows) { if (WindowsUtils.AttachConsole()) { return((int)RunCliWindows(args)); } else { return((int)RunGui(args)); } } else if (UnixUtils.HasGui) { return((int)RunGui(args)); } else { return((int)RunCli(args)); } }
[STAThread] // Required for WinForms private static int Main(string[] args) { ProgramUtils.Init(); WindowsUtils.SetCurrentProcessAppID(AppUserModelID); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); return(Run(args)); }
/// <summary> /// Runs the application in GUI mode. /// </summary> /// <param name="args">The command-line arguments passed to the application.</param> /// <returns>The exit status code to end the process with.</returns> public static ExitCode RunGui(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); using var handler = new GuiTaskHandler(); return(ProgramUtils.Run(args, handler, gui: true)); }
/// <summary> /// The main entry point for the application. /// </summary> // NOTE: No [STAThread] here, because it could block .NET remoting callbacks private static int Main(string[] args) { ProgramUtils.Init(); WindowsUtils.SetCurrentProcessAppID("ZeroInstall"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); using var handler = new GuiCommandHandler(); return((int)ProgramUtils.Run(ExeName, args, handler)); }
private static void Main(string[] args) { WindowsUtils.SetCurrentProcessAppID(Application.CompanyName + "." + GeneralSettings.AppNameShort); Application.EnableVisualStyles(); ErrorReportForm.SetupMonitoring(new Uri("http://omegaengine.de/error-report/?app=" + GeneralSettings.AppNameShort)); #if !DEBUG // Prevent multiple instances from running simultaneously if (AppMutex.Create(GeneralSettings.AppName)) { Msg.Inform(null, Resources.AlreadyRunning, MsgSeverity.Warn); return; } #endif Args = new Arguments(args); Settings.LoadCurrent(); UpdateLocale(); Settings.SaveCurrent(); // Show additional warning before actually starting the game if (Args.Contains("launchWarn") && !Args.Contains("benchmark")) { if (!Msg.OkCancel(null, Resources.ReadyToLaunch, MsgSeverity.Info, Resources.ReadyToLaunchContinue)) { return; } } // Handle benchmark mode if (Args.Contains("benchmark")) { if (!Msg.OkCancel(null, Resources.BenchmarkInfo, MsgSeverity.Info, Resources.BenchmarkInfoContinue)) { return; } ConfigureSettingsForBenchmark(); } if (!DetermineContentDirs()) { return; } if (!LoadArchives()) { return; } using (var game = new Game()) game.Run(); ContentManager.CloseArchives(); }
[STAThread] // Required for WinForms private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); NetUtils.ApplyProxy(); var openPgp = OpenPgpFactory.CreateDefault(); if (args == null || args.Length == 0) { Application.Run(new WelcomeForm(openPgp)); } else { try { var files = ArgumentUtils.GetFiles(args, "*.xml"); if (files.Count == 1) { string path = files.First().FullName; Application.Run(new MainForm(FeedEditing.Load(path), openPgp)); } else { MassSignForm.Show(files); } } #region Error handling catch (ArgumentException ex) { Msg.Inform(null, ex.Message, MsgSeverity.Warn); } catch (IOException ex) { Msg.Inform(null, ex.Message, MsgSeverity.Warn); } catch (UnauthorizedAccessException ex) { Msg.Inform(null, ex.Message, MsgSeverity.Warn); } catch (InvalidDataException ex) { Msg.Inform(null, ex.Message + (ex.InnerException == null ? "" : Environment.NewLine + ex.InnerException.Message), MsgSeverity.Warn); } #endregion } }
[STAThread] // Required for WinForms private static void Main(string[] args) { ProcessUtils.SanitizeEnvironmentVariables(); NetUtils.ApplyProxy(); WindowsUtils.SetCurrentProcessAppID("ZeroInstall.Publishing"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); var openPgp = OpenPgp.Signing(); if (args.Length == 0) { Application.Run(new WelcomeForm(openPgp)); } else { try { var files = Paths.ResolveFiles(args, "*.xml"); if (files.Count == 1) { string path = files.First().FullName; Application.Run(new MainForm(FeedEditing.Load(path), openPgp)); } else { MassSignForm.Show(files); } } #region Error handling catch (Exception ex) when(ex is ArgumentException or IOException or InvalidDataException) { Msg.Inform(null, ex.GetMessageWithInner(), MsgSeverity.Warn); } catch (Exception ex) when(ex is UnauthorizedAccessException) { Msg.Inform(null, ex.Message, MsgSeverity.Error); } #endregion } }
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { if (e.Error is IOException || e.Error is UnauthorizedAccessException || e.Error is InvalidOperationException) { // Expected error Msg.Inform(null, (e.Error.InnerException ?? e.Error).Message, MsgSeverity.Error); } else { // Unexpected error ErrorReportForm.Report(e.Error, new Uri("https://0install.de/error-report/")); } } if (_restartCentral && !_rerun) { _updateProcess.RestartCentral(); } Thread.Sleep(2000); Close(); }
[STAThread] // Required for WinForms private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/")); NetUtils.ApplyProxy(); if (args == null) { args = new string[0]; } if (args.Length < 3 || args.Length > 4) { Msg.Inform(null, string.Format(Resources.WrongNoArguments, "0update-win SOURCE-PATH NEW-VERSION TARGET-PATH [--rerun|--restart-central]"), MsgSeverity.Error); return; } bool rerun = args.Contains("--rerun"); bool restartCentral = args.Contains("--restart-central"); try { var updateProcess = new UpdateProcess(args[0], args[1], args[2]); Application.Run(new MainForm(updateProcess, rerun, restartCentral)); } #region Error handling catch (IOException ex) { Msg.Inform(null, ex.Message, MsgSeverity.Error); } catch (UnauthorizedAccessException ex) { Msg.Inform(null, ex.Message, MsgSeverity.Error); } catch (NotSupportedException ex) { Msg.Inform(null, ex.Message, MsgSeverity.Error); } #endregion }
private static void Main(string[] args) { WindowsUtils.SetCurrentProcessAppID(Application.CompanyName + "." + GeneralSettings.AppNameShort + ".AlphaEditor"); ModInfo.FileExt = "." + GeneralSettings.AppNameShort + "Mod"; Application.EnableVisualStyles(); ErrorReportForm.SetupMonitoring(new Uri("http://omegaengine.de/error-report/?app=" + GeneralSettings.AppNameShort)); // Allow setup to detect running instances AppMutex.Create(GeneralSettings.AppName + " Editor"); Args = new Arguments(args); Settings.LoadCurrent(); UpdateLocale(); Settings.SaveCurrent(); if (!DetermineContentDirs()) { return; } if (Settings.Current.Editor.ShowWelcomeMessage) { Restart = false; // Will be set to true again, if the user clicks "Continue" Application.Run(new WelcomeForm()); } // The user might want to come back here multiple times, in order to switch the mod while (Restart) { Restart = false; // Ask user to select mod, cancel if an exception occurred Application.Run(new ModSelectorForm(Settings.Current.Editor.EditBase, Settings.Current.Editor.RecentMods)); // Exit if the user didn't select anything if (ContentManager.ModDir == null && !ModInfo.MainGame) { break; } // Load the archives, run the main editor, cancel if an exception occurred, always unload the archives if (!LoadArchives()) { break; } try { Application.Run(new MainForm()); } finally { ContentManager.CloseArchives(); } // Prepare for next selection ModInfo.MainGame = false; ContentManager.ModDir = null; // After the MainForm has closed a lot of garbage will be left in Generation 2. // We should run Garbage Collection now, so we don't keep on wasting a large chunk of memory. GC.Collect(); } }