static void Main(string[] args) { RegistryHelper.ProductName = "FieldWorks"; // needed to access proper registry values Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool fBadArg = false; bool fInstall = false; for (int i = 0; i < args.Length; ++i) { if (args[i] == "-i" || args[i] == "-install" || args[i] == "--install") fInstall = true; else fBadArg = true; } if (fInstall) { PUAMigrator migrator = new PUAMigrator(); migrator.Run(); } else if (fBadArg) { MessageBox.Show("Only one command line argument is recognized:" + Environment.NewLine + "\t-i means to install the custom character definitions (as a command line program).", "Unicode Character Editor"); } else { using (var window = new CharEditorWindow()) Application.Run(window); } }
static void Main(string[] args) { RegistryHelper.ProductName = "FieldWorks"; // needed to access proper registry values Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool fBadArg = false; bool fInstall = false; for (int i = 0; i < args.Length; ++i) { if (args[i] == "-i" || args[i] == "-install" || args[i] == "--install") { fInstall = true; } else { fBadArg = true; } } if (fInstall) { PUAMigrator migrator = new PUAMigrator(); migrator.Run(); } else if (fBadArg) { MessageBox.Show("Only one command line argument is recognized:" + Environment.NewLine + "\t-i means to install the custom character definitions (as a command line program).", "Unicode Character Editor"); } else { using (var window = new CharEditorWindow()) Application.Run(window); } }
static void Main(string[] args) { Form window = null; var needCleanup = true; try { // needed to access proper registry values FwRegistryHelper.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); switch (args.FirstOrDefault()) { case "-i": case "-install": case "--install": // If we have any custom character data, install it! FwUtils.InitializeIcu(); var customCharsFile = CharEditorWindow.CustomCharsFile; if (File.Exists(customCharsFile)) { new PUAInstaller().InstallPUACharacters(customCharsFile); } break; case "--cleanup": // If the second argument is a Process ID (int), wait up to five minutes for the proces to exit and then clean up; // otherwise, silently do nothing. needCleanup = false; int pid; if (int.TryParse(args.LastOrDefault(), out pid)) { var iterationCount = 0; while (Process.GetProcesses().Any(p => p.Id == pid) && iterationCount < 300) { // wait 1s then try again Thread.Sleep(1000); iterationCount++; } if (iterationCount < 300) { DeleteTemporaryFiles(); } } break; case null: // There were no arguments (the program was double-clicked or opened through the Start menu); run the graphical interface FwUtils.InitializeIcu(); window = new CharEditorWindow(); Application.Run(window); break; default: // An unrecognized argument was passed MessageBox.Show("Only one command line argument is recognized:" + Environment.NewLine + "\t-i means to install the custom character definitions (as a command line program).", "Unicode Character Editor"); break; } } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Unicode Character Properties Editor"); } catch (Exception ex) { // Be very, very careful about changing stuff here. Code here MUST not throw exceptions, // even when the application is in a crashed state. try { ErrorReporter.ReportException(ex, null, null, window, true); } catch { MessageBox.Show(ex.Message, "Unicode Character Properties Editor"); } } finally { window?.Dispose(); LogFile.Release(); if (needCleanup) { StartCleanup(); } } }
static void Main(string[] args) { RegistryHelper.ProductName = "FieldWorks"; // needed to access proper registry values Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool fBadArg = false; bool fInstall = false; for (int i = 0; i < args.Length; ++i) { if (args[i] == "-i" || args[i] == "-install" || args[i] == "--install") { fInstall = true; } else if (args[i] == "--cleanup") { if (i + 1 >= args.Length) { return; } var iterationCount = 0; var pid = int.Parse(args[i + 1]); while (Process.GetProcesses().Any(p => p.Id == pid) && iterationCount < 300) { // wait 1s then try again Thread.Sleep(1000); iterationCount++; } if (iterationCount < 300) { DeleteTemporaryFiles(); } return; } else { fBadArg = true; } } if (fInstall) { PUAMigrator migrator = new PUAMigrator(); migrator.Run(); } else if (fBadArg) { MessageBox.Show("Only one command line argument is recognized:" + Environment.NewLine + "\t-i means to install the custom character definitions (as a command line program).", "Unicode Character Editor"); } else { using (var window = new CharEditorWindow()) Application.Run(window); } LogFile.Release(); StartCleanup(); }