static void Main(string[] args) { // Parse arguments. PCCSettingsArgs pccArgs = new PCCSettingsArgs(); Parser.ParseArguments(args, pccArgs); // Set bitness in PCC environment. switch (pccArgs.bitness) { case Bitness.x86: { PCCEnvironment.Is64Bit = false; break; } case Bitness.x64: { PCCEnvironment.Is64Bit = true; break; } case Bitness.Default: { PCCEnvironment.Is64Bit = PCCEnvironment.Is64BitOS; break; } default: { Debug.Fail(String.Format("Unknown Bitness value: {0}", pccArgs.bitness)); PCCEnvironment.Is64Bit = PCCEnvironment.Is64BitOS; break; } } // Setup visual styles. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Check if we need to simply check for updates. bool created; if (pccArgs.updatecheck) { // Make sure we only do this once. using (new Mutex(true, UPDATE_CHECK_MUTEX_NAME, out created)) { if (!created) { return; } using (UserSettings settings = new UserSettings()) { try { SoftwareUpdater updater = new SoftwareUpdater(settings); updater.CheckForUpdate(null); } catch (SoftwareUpdateException) { // Silence this. Can't check for updates, too bad. } return; } } } // Block multiple instances. using (new Mutex(true, MUTEX_NAME, out created)) { if (!created) { return; } // Unless we're launched by the PCC extension, perform revise. if (!pccArgs.frompcc) { new PCCExecutor().ApplyUserRevisions(); } // Make sure editing is allowed. using (UserSettings settings = new UserSettings()) { if (settings.EditingDisabled) { MessageBox.Show(Resources.EDITING_DISABLED_MESSAGE, Resources.EDITING_DISABLED_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } // If we reached this point, run the application. Application.Run(new MainForm()); } }
static void Main(string[] args) { // Parse arguments. PCCSettingsArgs pccArgs = new PCCSettingsArgs(); Parser.ParseArguments(args, pccArgs); // Set bitness in PCC environment. switch (pccArgs.bitness) { case Bitness.x86: { PCCEnvironment.Is64Bit = false; break; } case Bitness.x64: { PCCEnvironment.Is64Bit = true; break; } case Bitness.Default: { PCCEnvironment.Is64Bit = PCCEnvironment.Is64BitOS; break; } default: { Debug.Fail($"Unknown Bitness value: {pccArgs.bitness}"); PCCEnvironment.Is64Bit = PCCEnvironment.Is64BitOS; break; } } // Setup visual styles. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Set culture info to switch language if needed. using (UserSettings settings = new UserSettings()) { string language = settings.Language; if (!string.IsNullOrWhiteSpace(language)) { CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language); Thread.CurrentThread.CurrentUICulture = cultureInfo; Thread.CurrentThread.CurrentCulture = cultureInfo; } } // Check if we need to simply check for updates. if (pccArgs.updatecheck) { // Make sure we only do this once. using (new Mutex(true, UpdateCheckMutexName, out bool created)) { if (!created) { return; } using (UserSettings settings = new UserSettings()) { try { SoftwareUpdater updater = new SoftwareUpdater(settings); updater.CheckForUpdate(null); } catch (SoftwareUpdateException) { // Silence this. Can't check for updates, too bad. } return; } } } // Block multiple instances. using (new Mutex(true, MutexName, out bool created)) { if (!created) { return; } // Unless we're launched by the PCC extension, perform revise. if (!pccArgs.frompcc) { new PCCExecutor().ApplyUserRevisions(); } // Make sure editing is allowed. using (UserSettings settings = new UserSettings()) { if (settings.EditingDisabled) { MessageBox.Show(Resources.EDITING_DISABLED_MESSAGE, Resources.EDITING_DISABLED_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } // If we reached this point, run the application. using (MainForm mainForm = new MainForm()) { Application.Run(mainForm); } } }