private void tsbDeleteRemote_Click(object sender, EventArgs e) { try { TreeNode node = tvRemotes.SelectedNode; if (node != null) { if (node.Tag is RCCServiceConfig.RemoteControlRow && MessageDisplay.Query(Translator.Translate("TXT_CONFIRMDELETEREMOTE"), Translator.Translate("TXT_CONFIRM"), MessageBoxIcon.Question) == DialogResult.Yes) { _config.RemoteControl.RemoveRemoteControlRow(node.Tag as RCCServiceConfig.RemoteControlRow); _config.RemoteControl.AcceptChanges(); DisplayRemotes(); } else if (node.Tag is RCCServiceConfig.RemoteButtonsRow && MessageDisplay.Query(Translator.Translate("TXT_CONFIRMDELETEBUTTON"), Translator.Translate("TXT_CONFIRM"), MessageBoxIcon.Question) == DialogResult.Yes) { _config.RemoteButtons.RemoveRemoteButtonsRow(node.Tag as RCCServiceConfig.RemoteButtonsRow); _config.RemoteButtons.AcceptChanges(); DisplayRemotes(); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
private void tsbAddRemote_Click(object sender, EventArgs e) { try { UseWaitCursor = true; TreeNode node = tvRemotes.SelectedNode; if (node != null && (node.ImageIndex == 4 || node.Tag is RCCServiceConfig.RemoteButtonsRow)) { try { while (true) { ButtonConfigForm dlg = new ButtonConfigForm(); dlg.Config = _config; dlg.RemoteControl = (node.Tag is RCCServiceConfig.RemoteButtonsRow) ? _config.RemoteControl.FindByRemoteName((node.Tag as RCCServiceConfig.RemoteButtonsRow).RemoteName) : node.Tag as RCCServiceConfig.RemoteControlRow; DialogResult res = dlg.ShowDialog(this); if (res == DialogResult.OK || res == DialogResult.Retry) { _config.RemoteButtons.AddRemoteButtonsRow(dlg.Button); _config.RemoteButtons.AcceptChanges(); DisplayRemotes(); } if (res != DialogResult.Retry) { break; } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } } else { RemoteControlConfigForm dlg = new RemoteControlConfigForm(); dlg.Config = _config; if (dlg.ShowDialog(this) == DialogResult.OK) { _config.RemoteControl.AddRemoteControlRow(dlg.RemoteControl); _config.RemoteControl.AcceptChanges(); DisplayRemotes(); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } UseWaitCursor = false; BringToFront(); }
private void AttemptUninstallAddon(AddonLibraryInfo ali) { try { if (ali.IsNative) { ErrorDispatcher.DispatchError(Translator.Translate("TXT_CANT_UNINSTALL_BUILTIN"), false); return; } string[] codebaseParts = ali.CodeBase.Split(new char[] { '|' }); if (codebaseParts.Length > 0) { ScheduleForUninstall(codebaseParts[0]); if (_uninstallScheduled) { FindForm().DialogResult = DialogResult.OK; FindForm().Close(); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
private void OnInstallAddons(object sender, EventArgs e) { OPMOpenFileDialog dlg = new OPMOpenFileDialog(); dlg.Filter = Translator.Translate("TXT_INSTALLADDONFILTER"); dlg.Title = Translator.Translate("TXT_INSTALLADDONS"); if (dlg.ShowDialog() == DialogResult.OK) { try { if (dlg.FileName.ToLowerInvariant().Contains("builtin")) { ErrorDispatcher.DispatchError(Translator.Translate("TXT_CANT_INSTALL_BUILTIN"), false); } else if (!dlg.FileName.ToLowerInvariant().EndsWith("extension.dll")) { ErrorDispatcher.DispatchError(Translator.Translate("TXT_INVALID_NAME"), false); } else if (TestAssembly(dlg.FileName)) { AddonsConfig.InstallAddonLibrary(dlg.FileName); ReloadConfig(); } else { ErrorDispatcher.DispatchError(Translator.Translate("TXT_INVALID_ADDON"), false); } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } } }
private void btnAdd_Click(object sender, EventArgs e) { try { UseWaitCursor = true; while (true) { ButtonConfigForm dlg = new ButtonConfigForm(); dlg.Config = _config; dlg.RemoteControl = _remoteControl; DialogResult res = dlg.ShowDialog(this); if (res == DialogResult.OK || res == DialogResult.Retry) { _config.RemoteButtons.AddRemoteButtonsRow(dlg.Button); _config.RemoteButtons.AcceptChanges(); DisplayButtonsData(); } if (res != DialogResult.Retry) { break; } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } UseWaitCursor = false; }
void OnMediaRenderingException(RenderingExceptionEventArgs args) { string msg = args.RenderingException.ToString(); ErrorDispatcher.DispatchError(msg, false); args.Handled = true; }
private void OnFilterGraphMessage() { int p1, p2; EventCode code = EventCode.None; if (mediaEvent == null) { return; } while (mediaEvent.GetEvent(out code, out p1, out p2, 0) == 0) { try { int hr = mediaEvent.FreeEventParams(code, p1, p2); DsError.ThrowExceptionForHR(hr); Logger.LogTrace("HandleGraphEvent: code={0} p1={1} p2={2}", code, p1, p2); HandleGraphEvent(code, p1, p2); } catch (COMException ex) { Logger.LogTrace("Filter graph message loop broken because: {0}", ErrorDispatcher.GetErrorMessageForException(ex, false)); break; } catch (Exception ex) { Logger.LogException(ex); break; } } }
private void btnChange_Click(object sender, EventArgs e) { try { ListViewItem item = lvButtons.SelectedItems.Count > 0 ? lvButtons.SelectedItems[0] : null; if (item != null && item.Tag is RCCServiceConfig.RemoteButtonsRow) { ButtonConfigForm dlg = new ButtonConfigForm(); dlg.Config = _config; dlg.RemoteControl = _remoteControl; dlg.Button = item.Tag as RCCServiceConfig.RemoteButtonsRow; if (dlg.ShowDialog(this) == DialogResult.OK) { dlg.Button.AcceptChanges(); DisplayButtonsData(); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
public static bool ReconfigureRCCService() { try { ServiceController sc = new ServiceController( ProTONEConstants.RCCServiceShortName, Environment.MachineName); if (sc.Status == ServiceControllerStatus.Running) { sc.ExecuteCommand((int)ServiceCommand.Reconfigure); } else { sc.Start(); sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10)); } if (sc.Status != ServiceControllerStatus.Running) { return(false); } return(true); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } return(false); }
private void OpenFileWithCheck(string fileName, bool openRecent) { if (string.IsNullOrEmpty(fileName)) { return; } fileName = fileName.ToLowerInvariant(); if (File.Exists(fileName)) { LoadThemeFile(fileName); } else { if (_recentFiles.Contains(fileName)) { _recentFiles.Remove(fileName); } string mainMessage = Translator.Translate("TXT_FILE_NOT_FOUND", fileName); if (openRecent) { mainMessage += "\r\n"; mainMessage += Translator.Translate("TXT_RECENT_FILE_REMOVED"); } ErrorDispatcher.DispatchError(mainMessage, false); } }
private void OnMenuEnable(object sender, EventArgs e) { try { TreeNode node = tvRemotes.SelectedNode; if (node != null) { if (node.Tag is RCCServiceConfig.RemoteControlRow) { bool enabled = (node.Tag as RCCServiceConfig.RemoteControlRow).Enabled; (node.Tag as RCCServiceConfig.RemoteControlRow).Enabled = !enabled; (node.Tag as RCCServiceConfig.RemoteControlRow).AcceptChanges(); DisplayRemotes(); } else if (node.Tag is RCCServiceConfig.RemoteButtonsRow) { bool enabled = (node.Tag as RCCServiceConfig.RemoteButtonsRow).Enabled; (node.Tag as RCCServiceConfig.RemoteButtonsRow).Enabled = !enabled; (node.Tag as RCCServiceConfig.RemoteButtonsRow).AcceptChanges(); DisplayRemotes(); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
public static string Translate(string tag) { string retVal = tag; if (translate && !string.IsNullOrEmpty(tag) && tag.StartsWith("TXT_")) { string translatedTag = null; foreach (ResourceManager rm in _resManagers) { try { translatedTag = rm.GetString(tag, Thread.CurrentThread.CurrentCulture); if (translatedTag != null) { retVal = translatedTag; break; } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex); retVal = tag; } } } if (retVal == tag) { // Not translated //Logger.LogTranslationTrace(tag); } return(retVal); }
public void AddOnlineMediaItem(OnlineMediaItem omi) { try { if (omi is RadioStation) { Add(new RadioStationPlaylistItem(omi as RadioStation)); } else if (omi is DeezerTrackItem) { Add(new DeezerTrackPlaylistItem(omi as DeezerTrackItem)); } EventRaiser(Count - 1, -1, UpdateType.Added); SetupRandomSequence(-1); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, true); } finally { Application.DoEvents(); } }
private void OpenFileWithCheck(string fileName, bool openRecent) { if (string.IsNullOrEmpty(fileName)) { return; } fileName = fileName.ToLowerInvariant(); if (File.Exists(fileName)) { _bwOpen.RunWorkerAsync(fileName); ShowWaitDialog("TXT_WAIT_LOADING_CATALOG"); } else { if (_recentFiles.Contains(fileName)) { _recentFiles.Remove(fileName); } string mainMessage = Translator.Translate("TXT_FILE_NOT_FOUND", fileName); if (openRecent) { mainMessage += "\r\n"; mainMessage += Translator.Translate("TXT_RECENT_FILE_REMOVED"); } ErrorDispatcher.DispatchError(mainMessage, false); } }
public void InvokeCommand(IntPtr pici) { try { CMINVOKECOMMANDINFO ici = (CMINVOKECOMMANDINFO)Marshal.PtrToStructure( pici, typeof(CMINVOKECOMMANDINFO)); int cmd = (ici.verb.ToInt32()) & 0xffff; switch (cmd) { case (int)CommandType.PlayFiles: case (int)CommandType.EnqueueFiles: RemoteControlHelper.SendPlayerCommand((CommandType)cmd, fileList.ToArray()); break; default: Marshal.ThrowExceptionForHR(WinError.E_FAIL); break; } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (!_closedOnce) { foreach (TabPage tp in tabOptions.TabPages) { BaseCfgPanel panel = tp.Controls[0] as BaseCfgPanel; if (panel != null) { if (DialogResult == DialogResult.OK) { panel.Save(); } else { panel.Discard(); } } } _closedOnce = true; return; } } catch (SettingsSaveException ex) { ErrorDispatcher.DispatchError(ex.Message, false); } e.Cancel = true; }
/// <summary> /// Initialize all addons loaders. /// </summary> public void InitializeAddons() { bool errors = false; Logger.LogTrace("InitializeAddons() called ..."); navAddonsLoader = null; propAddonsLoader = null; previewAddonsLoader = null; try { // Initialize navigation addons Logger.LogTrace("Loading navigation addons ..."); navAddonsLoader = new NavAddonsLoader(); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); navAddonsLoader = null; return; // navigations addons are critical; if they fail loading don't continue. } try { // Initialize property addons. Logger.LogTrace("Loading property addons ..."); propAddonsLoader = new PropAddonsLoader(); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); propAddonsLoader = null; errors = true; } try { // Initialize preview addons. Logger.LogTrace("Loading preview addons ..."); previewAddonsLoader = new PreviewAddonsLoader(); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); previewAddonsLoader = null; errors = true; } if (errors) { ErrorDispatcher.DispatchError("Some errors were encountered while loading addons.\n" + "You can open Settings -> Addon Config to check which addons are operational.", false); } Logger.LogTrace("InitializeAddons() done."); }
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); } }
protected override bool ProcessInternal() { try { DateTime fileTimeStamp = DateTime.MinValue; string filePath = string.Empty; string fileName = "~" + _descName + ".frtmp"; _pendingDownloadFile = Path.Combine(_repositoryPath, fileName); using (WebFileRetriever downloader = new WebFileRetriever(_ns, _downloadUrl, _pendingDownloadFile, false)) { } string ext = PathUtils.GetExtension(_downloadUrl); if (!AreFilesIdentical(GetLatestFileInRepository(), _pendingDownloadFile)) { string newFileName = StringUtils.GetUniqueFileName(); string newFilePath = Path.Combine(_repositoryPath, newFileName + ext); File.Move(_pendingDownloadFile, newFilePath); if (NewFileRetrieved != null) { NewFileRetrieved(newFilePath, true, string.Empty); } } DeleteFile(_pendingDownloadFile); _pendingDownloadFile = string.Empty; } catch (ThreadAbortException) { if (!string.IsNullOrEmpty(_pendingDownloadFile) && File.Exists(_pendingDownloadFile)) { EventDispatch.DispatchEvent(EventNames.ShowMessageBox, "Download cancelled.", _descName, MessageBoxIcon.Warning); _retriever.Dispose(); _retriever = null; DeleteFile(_pendingDownloadFile); _pendingDownloadFile = string.Empty; } return(false); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } // DownloadInterval is in seconds Thread.Sleep(_downloadInterval * 1000); return(true); }
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); } }
protected CrudlessRequestHandler(IEntityContext context, CrudlessConfigManager profileManager) { Context = context; RequestConfig = profileManager.GetRequestConfigFor <TRequest>(); DataContext = new DataContext <TEntity>(RequestConfig); var errorHandler = RequestConfig.ErrorConfig.GetErrorHandlerFor <TEntity>(); ErrorDispatcher = new ErrorDispatcher(errorHandler); }
private void DeleteFile(string path) { try { File.Delete(path); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
public ShellIntegrationSuport() { try { hBitmap = Resources.player.GetHbitmap(); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); hBitmap = IntPtr.Zero; } }
internal void LoadBookmarks(bool raiseEvent, bool throwException) { _bookmarks.Clear(); try { if (File.Exists(_path) == false) { return; } using (StreamReader sr = new StreamReader(_path)) { string line = sr.ReadLine(); while (line != null) { if (!line.StartsWith("#")) { Bookmark bmk = Bookmark.FromString(line); if (bmk != null) { if (_bookmarks.ContainsKey(bmk.PlaybackTime)) { _bookmarks[bmk.PlaybackTime] = bmk; } else { _bookmarks.Add(bmk.PlaybackTime, bmk); } } } line = sr.ReadLine(); } } if (raiseEvent && BookmarkCollectionChanged != null) { BookmarkCollectionChanged(null, null); } } catch (Exception ex) { if (throwException) { ErrorDispatcher.DispatchError(ex, false); } else { Logger.LogException(ex); } } }
public virtual void AddItem(string itemPath) { try { bool added = false; Uri uri = null; try { uri = new Uri(itemPath, UriKind.Absolute); } catch { uri = null; } if (uri != null) { if (uri.IsFile) { itemPath = uri.LocalPath; } else { Add(new UrlPlaylistItem(itemPath)); added = true; } } if (!added) { if (DvdMedia.FromPath(itemPath) != null) { Add(new DvdPlaylistItem(itemPath)); } else { Add(new PlaylistItem(itemPath, false)); } } EventRaiser(Count - 1, -1, UpdateType.Added); SetupRandomSequence(-1); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, true); } finally { Application.DoEvents(); } }
protected async Task <Response <TResult> > HandleWithErrorsAsync <TResult>(TRequest request, IServiceProvider provider, CancellationToken token, Func <TRequest, IServiceProvider, CancellationToken, Task <TResult> > handleAsync) { var result = default(TResult); try { token.ThrowIfCancellationRequested(); try { result = await handleAsync(request, provider, token).Configure(); } catch (AggregateException e) { throw Unwrap(e); } } catch (Exception e) when(FailedToFindError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(FailedToFindError.From(request, e))); } catch (Exception e) when(RequestFailedError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(RequestFailedError.From(request, e))); } catch (Exception e) when(RequestCanceledError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(RequestCanceledError.From(request, e))); } catch (Exception e) when(HookFailedError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(HookFailedError.From(request, e))); } catch (Exception e) when(CreateEntityFailedError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(CreateEntityFailedError.From(request, e))); } catch (Exception e) when(UpdateEntityFailedError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(UpdateEntityFailedError.From(request, e))); } catch (Exception e) when(CreateResultFailedError.IsReturnedFor(e)) { return(ErrorDispatcher.Dispatch <TResult>(CreateResultFailedError.From(request, e))); } return(result.AsResponse()); }
public static bool ProcessCommandLine(bool testForShellExec) { string[] cmdLineArgs = Environment.GetCommandLineArgs(); if (testForShellExec && cmdLineArgs.Length > 1 && cmdLineArgs[1].ToLowerInvariant() == "launch") { List <string> files = new List <string>(); for (int i = 2; i < cmdLineArgs.Length; i++) { files.Add(cmdLineArgs[i]); } try { CommandType cmdType = (CommandType)Enum.Parse(typeof(CommandType), ProTONEConfig.ExplorerLaunchType); if (SuiteRegistrationSupport.IsContextMenuHandlerRegistered() && (cmdType == CommandType.PlayFiles || cmdType == CommandType.EnqueueFiles)) { if (RemoteControlHelper.IsPlayerRunning()) { // There is another player instance that is running. // Just pass the command to that instance and exit. RemoteControlHelper.SendPlayerCommand(cmdType, files.ToArray()); } else { // There is no other player instance. // This instance needs to process the command itself. // Note: when player is launched like this - clear previous playlist first. _commandQueue.Add(BasicCommand.Create(CommandType.ClearPlaylist)); _commandQueue.Add(BasicCommand.Create(cmdType, files.ToArray())); return(false); // Don't exit } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } return(true); } return(false); }
private void FillDriveList() { try { if (!Directory.Exists(this.InitialDirectory)) { this.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop, Environment.SpecialFolderOption.Create); } System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); foreach (System.IO.DriveInfo di in drives) { try { string path = di.RootDirectory.FullName.ToUpperInvariant(); string title = di.Name; if (di.IsReady) { title += $" [{di.VolumeLabel}]"; } OPMToolStripButton btn = new OPMToolStripButton(title); btn.Name = title; btn.Image = ImageProvider.GetIcon(path, true); btn.ToolTipText = path; btn.TextAlign = ContentAlignment.MiddleLeft; btn.ImageAlign = System.Drawing.ContentAlignment.TopCenter; btn.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit; btn.ImageTransparentColor = System.Drawing.Color.Magenta; btn.AutoSize = true; btn.Tag = path; btn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; tsSpecialFolders.Items.Add(btn); } catch (Exception ex) { Logger.LogException(ex); } } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
private void LoadM3UPlaylist(string fileName) { try { string text = File.ReadAllText(fileName); if (string.IsNullOrEmpty(text) == false) { LoadM3UPlaylistFromString(text, fileName); } } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } }
private bool DoSaveProperties() { foreach (ITaggedMediaFileInfo tmfi in pgProperties.SelectedObjects) { try { tmfi.Save(); } catch (Exception ex) { ErrorDispatcher.DispatchError(ex, false); } } return(true); }