static void Main() { LaunchPath = string.Empty; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { LoggedApplication.Start(ProTONEConstants.LibraryName); string[] cmdLineArgs = Environment.GetCommandLineArgs(); if (cmdLineArgs.Length > 2) { switch (cmdLineArgs.Length) { case 3: switch (cmdLineArgs[1].ToLowerInvariant()) { case "launch": LaunchPath = cmdLineArgs[2]; break; } break; } } Translator.RegisterTranslationAssembly(typeof(MediaPlayer).Assembly); Translator.RegisterTranslationAssembly(typeof(MediaLibraryForm).Assembly); string cmdLine = Environment.CommandLine.ToLowerInvariant(); if (cmdLineArgs != null && cmdLineArgs.Length > 2 && cmdLine.Contains("configaddons")) { Translator.SetInterfaceLanguage(cmdLineArgs[2]); AddonsConfig.IsInitialConfig = true; AppConfig.SkinType = string.Empty; try { AddonAppSettingsForm.Show("TXT_S_ADDONSETTINGS"); } finally { } } else { Translator.SetInterfaceLanguage(AppConfig.LanguageID); Application.Run(new MediaLibraryForm()); } } catch (Exception ex) { ErrorDispatcher.DispatchFatalError(ex); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { if (!ProcessCommandLine(true)) { try { RemoteControllableApplication.Start(ProTONEConstants.PlayerName); ProcessCommandLine(false); Translator.SetInterfaceLanguage(AppConfig.LanguageID); Translator.RegisterTranslationAssembly(typeof(MediaPlayer).Assembly); Translator.RegisterTranslationAssembly(typeof(MainForm).Assembly); ShortcutMapper.IsPlayer = true; mainFrm = new MainForm(); foreach (BasicCommand cmd in _commandQueue) { mainFrm.EnqueueCommand(cmd); } Application.Run(mainFrm); mainFrm.Dispose(); ShortcutMapper.Save(); } catch (MultipleInstancesException ex) { Logger.LogWarning(ex.Message); // Send an activate command to the main instance RemoteControlHelper.SendPlayerCommand(CommandType.Activate, null); } catch (Exception ex) { ErrorDispatcher.DispatchFatalError(ex); } finally { RemoteControllableApplication.Stop(); } } } catch (Exception ex) { ErrorDispatcher.DispatchFatalError(ex); } }
public static void UnregisterServer(string s) { try { Logger.LogInfo("Attempt to unregister OPMedia.ShellSupport ..."); SuiteRegistrationSupport.Init(MediaRenderer.GetSupportedFileProvider()); SuiteRegistrationSupport.UnregisterKnownFileTypes(); SuiteRegistrationSupport.UnregisterContextMenuHandler(); SuiteRegistrationSupport.ReloadFileAssociations(); Logger.LogInfo("OPMedia.ShellSupport was succesfully unregistered !"); } catch (Exception exception) { ErrorDispatcher.DispatchFatalError("Fatal unregistration error: " + exception.Message); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Translator.SetInterfaceLanguage(AppConfig.LanguageID); Translator.RegisterTranslationAssembly(typeof(MainForm).Assembly); Translator.RegisterTranslationAssembly(typeof(SerialDeviceCfgDlg).Assembly); Translator.RegisterTranslationAssembly(typeof(MediaPlayer).Assembly); LoggedApplication.Start(ProTONEConstants.RCCManagerName); if (!AppConfig.CurrentUserIsAdministrator) { MessageDisplay.Show(Translator.Translate("TXT_ADMIN_RIGHTS_REQUIRED"), Translator.Translate("TXT_CAUTION"), MessageBoxIcon.Exclamation); Logger.LogInfo("RCC Manager started with non-admin rights. Exiting."); return; } ServiceControl.StopService(); mainFrm = new MainForm(); Application.Run(mainFrm); mainFrm.Dispose(); } catch (Exception ex) { ErrorDispatcher.DispatchFatalError(ex); } finally { LoggedApplication.Stop(); ServiceControl.StartService(); } }
protected override void RegisterAppMutex(string appName) { bool isPrimaryInstance = false; try { using (Mutex m = Mutex.OpenExisting("Global\\" + _appMutexName, MutexRights.ReadPermissions)) { } // SECONDARY INSTANCE Logger.LogTrace("Succesfully opened the mutex with name: {0}", _appMutexName); Logger.LogTrace("=> Apparently it's a secondary app instance."); } catch (WaitHandleCannotBeOpenedException) { // PRIMARY INSTANCE Logger.LogTrace("Could not open the mutex with name: {0}", _appMutexName); Logger.LogTrace("=> Apparently it's the primary app instance"); isPrimaryInstance = true; } catch (Exception ex) { ErrorDispatcher.DispatchFatalError(ex); } if (isPrimaryInstance) { _appMutex = new Mutex(true, "Global\\" + _appMutexName); } else { // Raise exception to notify the secondary instance that it must terminate. ReleaseAppMutex(); throw new MultipleInstancesException($"Another instance of app: {appName} is already running."); } }
private void OnApplicationThreadException(object sender, ThreadExceptionEventArgs e) { ErrorDispatcher.DispatchFatalError(e.Exception); }