예제 #1
0
        public static void TryFindSubtitle(string strFile, int duration, bool askToOverwrite)
        {
            try
            {
                if (SubtitleDownloadProcessor.TestForExistingSubtitle(strFile))
                {
                    if (!askToOverwrite || MessageDisplay.Query(Translator.Translate("TXT_OVERWRITE_SUBTITLE"),
                                                                Translator.Translate("TXT_CONFIRM_OVERWRITE_SUBTITLE"), MessageBoxIcon.Information) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                if (SubtitleDownloadProcessor.CanPerformSubtitleDownload(strFile, duration))
                {
                    // We should display a subtitle but we don't have one.
                    // Try to grab one from internet.
                    ThreadPool.QueueUserWorkItem(
                        new WaitCallback(SubtitleDownloadProcessor.AttemptDownload), strFile);
                }
            }
            finally
            {
                // This is for enforcing playlist refresh
                EventDispatch.DispatchEvent(LocalEvents.UpdatePlaylistNames, false);
            }
        }
        void MainForm_Load(object sender, EventArgs e)
        {
            tsmiAbout.ToolTipText = string.Empty;
            tsmiAbout.AutoToolTip = false;

            tsmiAbout.Text = Translator.Translate("TXT_ABOUT",
                                                  Translator.TranslatedAppName);

            // First chance ...
            if (!GetNavigationAddons())
            {
                if (AddonAppSettingsForm.Show("TXT_S_ADDONSETTINGS", string.Empty) == DialogResult.Cancel)
                {
                    EventDispatch.DispatchEvent(EventNames.ShowMessageBox,
                                                Translator.Translate("TXT_NO_NAV_ADDONS"),
                                                Translator.TranslatedAppName,
                                                MessageBoxIcon.Error);

                    Logger.LogError("No navigation addons are currently configured. Application is exiting.");

                    // Exit application by closing the main form.
                    Close();
                    return;
                }
            }

            this.VSplitterDistance = AddonAppConfig.VSplitterDistance;
            this.HSplitterDistance = AddonAppConfig.HSplitterDistance;

            pnlContent.BringToFront();
        }
        /// <summary>
        /// Sets the interface language.
        /// </summary>
        /// <param name="languageId">The language id.</param>
        public static void SetInterfaceLanguage(string languageId)
        {
            if (AppConfig.AllowRealtimeGUISetup == false ||
                string.IsNullOrEmpty(languageId))
            {
                languageId = "en";
            }

            Logger.LogTrace("SetInterfaceLanguage: Requested UI language is: {0}", languageId);

            try
            {
                Logger.LogTrace("SetInterfaceLanguage: Previous UI language was: {0}",
                                Thread.CurrentThread.CurrentCulture.Name);

                CultureInfo culture = new CultureInfo(languageId);
                Thread.CurrentThread.CurrentCulture   = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                StringUtils.RebuildDateTimeFormatString();

                Logger.LogTrace("SetInterfaceLanguage: Current UI language was: {0}",
                                Thread.CurrentThread.CurrentCulture.Name);

                EventDispatch.DispatchEvent(EventNames.PerformTranslation);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
예제 #4
0
        private void DisplayCurrentPath()
        {
            Image  img  = null;
            string text = null;

            try
            {
                if (_curFolder != null)
                {
                    _prevPath = _curFolder.OrigItemPath;

                    img  = lvCatalogFolder.GetImageOfItemType(_curFolder.ItemType);
                    text = Translator.Translate("TXT_CURRENT_PATH", _curFolder.OrigItemPath);
                }
                else if (_cat != null)
                {
                    img  = ImageProvider.GetIconOfFileType("ctx");
                    text = Translator.Translate("TXT_CURRENT_PATH", _cat.Path);
                }
            }
            catch
            {
                img  = null;
                text = null;
            }

            EventDispatch.DispatchEvent(EventNames.SetMainStatusBar, text, img);
        }
        private void opmButton1_Click(object sender, EventArgs e)
        {
            ProTONEConfig.DetachedWindowLocation = new Point(100, 100);
            ProTONEConfig.DetachedWindowSize     = new Size(800, 600);


            EventDispatch.DispatchEvent(OPMedia.UI.ProTONE.GlobalEvents.EventNames.RestoreRenderingRegionPosition);
        }
 public static void DispatchCommand(OPMShortcut cmd)
 {
     if (enableShortcutDispatch)
     {
         EventDispatch.DispatchEvent(EventNames.ExecuteShortcut,
                                     new OPMShortcutEventArgs(cmd));
     }
 }
        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);
        }
예제 #8
0
 private static void InnerDisplayNonFatalError(string message, string title, bool showInTray)
 {
     if (showInTray)
     {
         EventDispatch.DispatchEvent(EventNames.ShowTrayMessage, message, title, ToolTipIcon.Warning);
     }
     else
     {
         EventDispatch.DispatchEvent(EventNames.ShowMessageBox, message, title, MessageBoxIcon.Warning);
     }
 }
예제 #9
0
 private void lvBookmarks_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (lvBookmarks.SelectedItems.Count > 0)
     {
         Bookmark bmk = lvBookmarks.SelectedItems[0].Tag as Bookmark;
         if (bmk != null)
         {
             BookmarkSubItem subItem = new BookmarkSubItem(_plItem, bmk);
             EventDispatch.DispatchEvent(LocalEventNames.JumpToBookmark, subItem);
         }
     }
 }
        protected override void SaveInternal()
        {
            MediaScreen            mediaScreen = MediaScreen.None;
            SignalAnalisysFunction functions   = SignalAnalisysFunction.None;

            if (chkShowPlaylist.Checked)
            {
                mediaScreen |= MediaScreen.Playlist;
            }
            if (chkShowTrackInfo.Checked)
            {
                mediaScreen |= MediaScreen.TrackInfo;
            }
            if (chkShowBookmarkInfo.Checked)
            {
                mediaScreen |= MediaScreen.BookmarkInfo;
            }

            if (chkShowSignalAnalisys.Checked)
            {
                mediaScreen |= MediaScreen.SignalAnalisys;

                if (chkVuMeter.Checked)
                {
                    functions |= SignalAnalisysFunction.VUMeter;
                }
                if (chkWaveform.Checked)
                {
                    functions |= SignalAnalisysFunction.Waveform;
                }
                if (chkSpectrogram.Checked)
                {
                    functions |= SignalAnalisysFunction.Spectrogram;
                }
            }

            if (chkWCFInterface.Checked)
            {
                functions |= SignalAnalisysFunction.WCFInterface;
                MediaRenderer.DefaultInstance.InitSignalAnalisysWCF();
            }
            else
            {
                MediaRenderer.DefaultInstance.CleanupSignalAnalisysWCF();
            }

            ProTONEConfig.ShowMediaScreens        = mediaScreen;
            ProTONEConfig.SignalAnalisysFunctions = functions;


            EventDispatch.DispatchEvent(LocalEventNames.UpdateMediaScreens);
        }
예제 #11
0
        public void NotifyGUI(string format, params object[] args)
        {
            if (MediaRenderer.DefaultInstance.HasRenderingErrors == false)
            {
                string text = Translator.Translate(format, args);

                MediaRenderer.DefaultInstance.DisplayOsdMessage(text);

                if (ProTONEConfig.MediaStateNotificationsEnabled)
                {
                    EventDispatch.DispatchEvent(EventNames.ShowTrayMessage, text, Translator.TranslatedAppName, 0);
                }
            }
        }
예제 #12
0
        static void dlg_SubtitleDownloadNotify(string movieFile, string subtitleFile)
        {
            // This is for enforcing playlist refresh
            EventDispatch.DispatchEvent(LocalEvents.UpdatePlaylistNames, false);

            SetCurrentSubtitle(movieFile, string.Empty);
            SetCurrentSubtitle(movieFile, subtitleFile);

            Logger.LogTrace("A subtitle was found: {0}, for movie: {1}", subtitleFile, movieFile);

            if (ProTONEConfig.SubDownloadedNotificationsEnabled)
            {
                string msg = Translator.Translate("TXT_SUB_LOADED");
                FireNotify(msg, ApplicationInfo.ApplicationName, MessageBoxIcon.Information);
            }
        }
예제 #13
0
        void _notifyIconMoveTimer_Tick(object sender, EventArgs e)
        {
            _notifyIconMoveTimer.Stop();

            string info = string.Empty;

            if (_hasMediaStateChangedAtLeastOnce == false)
            {
                return;
            }

            if (BuildMediaStateString(true, ref info))
            {
                EventDispatch.DispatchEvent(EventNames.ShowTrayMessage, info, Translator.TranslatedAppName, 0);
            }
        }
예제 #14
0
        void OnBackgroundDetect(object sender, DoWorkEventArgs e)
        {
            string versionFile     = "/Versions_build.txt";
            string versionFileUri  = AppConfig.DownloadUriBase + versionFile;
            string tempVersionFile = Path.GetTempFileName();
            bool   detectOnDemand  = (bool)e.Argument;

            WebFileRetriever retriever = null;

            try
            {
                retriever = new WebFileRetriever(AppConfig.ProxySettings, versionFileUri, tempVersionFile, false);
                StringBuilder sb = new StringBuilder();

                if (Kernel32.GetPrivateProfileString(Constants.SuiteName, "Version", "1.0.0.0", sb, 255, tempVersionFile) > 0)
                {
                    Version current   = new Version(SuiteVersion.Version);
                    Version available = new Version(sb.ToString());

                    if (available.CompareTo(current) > 0)
                    {
                        Logger.LogInfo("Current version: {0}, available on server: {1}. Update is required.",
                                       current, available);

                        EventDispatch.DispatchEvent(EventNames.NewVersionAvailable, sb.ToString());
                    }
                    else
                    {
                        Logger.LogInfo("Current version: {0}, available on server: {1}. Update is NOT required.",
                                       current, available);

                        if (detectOnDemand)
                        {
                            EventDispatch.DispatchEvent(EventNames.ShowMessageBox, "TXT_NOUPDATEREQUIRED", "TXT_APP_NAME", MessageBoxIcon.Information);
                        }
                    }
                }
            }
            finally
            {
                if (retriever != null)
                {
                    retriever.Dispose();
                }
            }
        }
예제 #15
0
        public static void OnSettingsChanged(ChangeType changeType, string persistenceId, string persistenceContext, string objectContent)
        {
            if (changeType != ChangeType.Saved)
            {
                return;
            }

            if (DetectSettingsChanges)
            {
                lock (_settingsChangesLock)
                {
                    try
                    {
                        switch (persistenceId)
                        {
                        case "LanguageID":
                        {
                            string langId = objectContent;
                            if (langId != _languageId)
                            {
                                _languageId = langId;
                                MainThread.Post((c) => Translator.SetInterfaceLanguage(_languageId));
                            }
                        }
                        break;

                        case "SkinType":
                        {
                            string skinType = objectContent;
                            if (skinType != _skinType)
                            {
                                _skinType = skinType;
                                MainThread.Post((c) => EventDispatch.DispatchEvent(EventNames.ThemeUpdated));
                            }
                        }
                        break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                }
            }
        }
예제 #16
0
        private void DisplayCurrentPath()
        {
            _prevPath = opmShellList.Path;

            Image  img  = null;
            string text = null;

            try
            {
                img  = ImageProvider.GetIcon(opmShellList.Path, false);
                text = Translator.Translate("TXT_CURRENT_PATH", opmShellList.Path);
            }
            catch
            {
                img  = null;
                text = null;
            }

            EventDispatch.DispatchEvent(EventNames.SetMainStatusBar, text, img);
        }
예제 #17
0
        void OnBackgroundWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                CatalogException cex = e.Error as CatalogException;
                if (cex != null)
                {
                    Logger.LogException(cex);
                    string msg = Translator.Translate(cex.Message, cex.Detail);
                    EventDispatch.DispatchEvent(EventNames.ShowMessageBox, msg, Translator.TranslatedAppName, MessageBoxIcon.Exclamation);
                }
                else
                {
                    ErrorDispatcher.DispatchError(e.Error, false);
                }
            }

            DisplayCatalog();
            CloseWaitDialog();
        }
예제 #18
0
        protected override void SaveInternal()
        {
            AddToPlaylistEntryFormatHistory(cmbPlaylistEntryFormat.Text);
            AddToFileNameFormatHistory(cmbFileNameFormat.Text);

            ProTONEConfig.UseFileNameFormat = chkFileNameFormat.Checked;
            ProTONEConfig.UseMetadata       = chkUseMetadata.Checked;

            ProTONEConfig.PlaylistEntryFormat = cmbPlaylistEntryFormat.Text;
            ProTONEConfig.FileNameFormat      = cmbFileNameFormat.Text;

            string[] customPlaylistEntryFormats = GetCustomFormats(cmbPlaylistEntryFormat);
            string[] customFileNameFormats      = GetCustomFormats(cmbFileNameFormat);

            ProTONEConfig.CustomPlaylistEntryFormats =
                StringUtils.FromStringArray(customPlaylistEntryFormats, '?');
            ProTONEConfig.CustomFileNameFormats =
                StringUtils.FromStringArray(customFileNameFormats, '?');

            EventDispatch.DispatchEvent(LocalEventNames.UpdatePlaylistNames, false);
        }
        protected override void HandleAction(string act)
        {
            var             selItems = this.SelectedItems;
            DeezerTrackItem selItem  = null;

            if (selItems != null && selItems.Count > 0)
            {
                selItem = selItems[0] as DeezerTrackItem;
            }

            string search = string.Empty;

            switch (act)
            {
            case "LookupDeezerArtist":
                search = string.Format("artist:\"{0}\"", selItem.Artist.ToLowerInvariant());
                break;

            case "LookupDeezerAlbum":
                search = string.Format("artist:\"{0}\" album:\"{1}\"", selItem.Artist.ToLowerInvariant(), selItem.Album.ToLowerInvariant());
                break;

            case "LookupDeezerTrack":
                search = string.Format("artist:\"{0}\" track:\"{1}\"", selItem.Artist.ToLowerInvariant(), selItem.Title.ToLowerInvariant());
                break;

            case "LookupMyPlaylists":
                EventDispatch.DispatchEvent(LocalEventNames.StartDeezerSearch, act);
                return;

            case "OpenDeezerPage":
                Process.Start("http://www.deezer.com");
                return;
            }

            if (string.IsNullOrEmpty(search) == false)
            {
                EventDispatch.DispatchEvent(LocalEventNames.StartDeezerSearch, search);
            }
        }
        public AddonPanel()
        {
            InitializeComponent();
            this.HandleCreated += new EventHandler(AddonPanel_HandleCreated);
            MainThread.MainWindow.FormClosing += new FormClosingEventHandler(AddonPanel_FormClosing);

            updateUiTimer          = new System.Windows.Forms.Timer();
            updateUiTimer.Enabled  = true;
            updateUiTimer.Interval = 1000;
            updateUiTimer.Start();
            updateUiTimer.Tick += new EventHandler(updateUiTimer_Tick);

            _il                  = new ImageList();
            _il.ImageSize        = new System.Drawing.Size(16, 16);
            _il.ColorDepth       = ColorDepth.Depth32Bit;
            _il.TransparentColor = Color.Magenta;
            tvThemes.ImageList   = _il;

            tvThemes.AfterSelect += new TreeViewEventHandler(tvThemes_AfterSelect);

            EventDispatch.DispatchEvent(EventNames.SetMainStatusBar, null, null);
        }
예제 #21
0
        protected void OnMenuClick(object sender, EventArgs e)
        {
            OPMToolStripMenuItem tsmi = sender as OPMToolStripMenuItem;

            if (tsmi != null)
            {
                string act = tsmi.Tag as string;
                if (string.IsNullOrEmpty(act) == false)
                {
                    var selItems = this.SelectedItems;
                    if (selItems != null && selItems.Count > 0)
                    {
                        switch (act)
                        {
                        case MediaBrowserAction.Play:
                            EventDispatch.DispatchEvent(LocalEventNames.LoadOnlineContent, selItems, false);
                            return;

                        case MediaBrowserAction.Enqueue:
                            EventDispatch.DispatchEvent(LocalEventNames.LoadOnlineContent, selItems, true);
                            return;

                        case MediaBrowserAction.AddFav:
                            EventDispatch.DispatchEvent(LocalEventNames.ManageOnlineContent, selItems, true);
                            return;

                        case MediaBrowserAction.DelFav:
                            EventDispatch.DispatchEvent(LocalEventNames.ManageOnlineContent, selItems, false);
                            return;
                        }
                    }

                    HandleAction(act);
                }
            }
        }
        void KeyCommandEditor_KeyUp(object sender, KeyEventArgs e)
        {
            KeyEventArgs args = GetKeyArgs(e);

            if (args != null &&
                (
                    (args.KeyData != Keys.Enter &&
                     args.KeyData != Keys.Escape &&
                     args.KeyData != Keys.Tab &&
                     args.KeyCode != Keys.PrintScreen &&
                     args.KeyData != Keys.F1)
                )
                ||
                (
                    (args.Control && (args.KeyData == Keys.F2 || args.KeyData == Keys.Left || args.KeyData == Keys.Right || args.KeyData == Keys.Up || args.KeyData == Keys.Down))
                )
                )
            {
                if (VerifyShortcut(args))
                {
                    if (_primary)
                    {
                        ShortcutMapper.KeyCommands[(int)_cmd] = args;
                    }
                    else
                    {
                        ShortcutMapper.AltKeyCommands[(int)_cmd] = args;
                    }

                    EventDispatch.DispatchEvent(EventNames.KeymapChanged);

                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
 private void btnCheckUpdates_Click(object sender, EventArgs e)
 {
     EventDispatch.DispatchEvent(EventNames.CheckForUpdates);
 }
        private void DisplayThemeFile()
        {
            tvThemes.Nodes.Clear();
            _il.Images.Clear();

            EventDispatch.DispatchEvent(EventNames.SetMainStatusBar, null, null);

            if (_themeFile != null)
            {
                EventDispatch.DispatchEvent(EventNames.SetMainStatusBar, _themeFile.FileName, imgThemeFile);

                _il.Images.Add(imgThemeFile);
                _il.Images.Add(Resources.ThemeNode);
                _il.Images.Add(Resources.ColorNode);
                _il.Images.Add(Resources.NumericNode);
                _il.Images.Add(Resources.StringNode);

                TreeNode themeFileNode = new TreeNode();
                if (_themeFile.IsModified)
                {
                    themeFileNode.Text += "[*]" + _themeFile.FileName;
                }
                else
                {
                    themeFileNode.Text = _themeFile.FileName;
                }

                themeFileNode.ImageIndex = themeFileNode.SelectedImageIndex = (int)NodeIndexes.ThemeFile;
                themeFileNode.Tag        = _themeFile;
                themeFileNode.NodeFont   = ThemeManager.NormalBoldFont;

                if (_themeFile.Themes != null)
                {
                    foreach (var theme in _themeFile.Themes)
                    {
                        TreeNode themeNode = new TreeNode(theme.Key);
                        themeNode.ImageIndex = themeNode.SelectedImageIndex = (int)NodeIndexes.Theme;
                        themeNode.Tag        = theme;
                        themeNode.NodeFont   = ThemeManager.NormalBoldFont;

                        if (theme.Value.ThemeElements != null)
                        {
                            foreach (var themeElement in theme.Value.ThemeElements)
                            {
                                bool isColorNode = themeElement.Key.ToLowerInvariant().Contains("color");

                                TreeNode themeElementNode = new TreeNode(themeElement.Key);
                                themeElementNode.Tag      = themeElement;
                                themeElementNode.NodeFont = ThemeManager.NormalFont;

                                if (isColorNode)
                                {
                                    themeElementNode.ForeColor = ThemeManager.ForeColor;

                                    Color  c   = ThemeManager.SafeColorFromString(themeElement.Value);
                                    Bitmap bmp = CreateColorBitmap(c);
                                    if (bmp != null)
                                    {
                                        themeElementNode.ImageIndex = themeElementNode.SelectedImageIndex =
                                            _il.Images.Add(bmp, Color.Magenta);
                                    }

                                    themeElementNode.Text = string.Format("{0} -> RGB=[{1}], HEX=#{2}", themeElement.Key, themeElement.Value,
                                                                          ValueAsHex(themeElement.Value).ToUpperInvariant());
                                }
                                else
                                {
                                    themeElementNode.ForeColor = ThemeManager.HighlightColor;

                                    int  x         = 0;
                                    bool isNumeric = int.TryParse(themeElement.Value, out x);
                                    themeElementNode.ImageIndex = themeElementNode.SelectedImageIndex =
                                        isNumeric ? (int)NodeIndexes.NumericThemeElement : (int)NodeIndexes.StringThemeElement;
                                }

                                themeNode.Nodes.Add(themeElementNode);
                            }
                        }

                        themeFileNode.Nodes.Add(themeNode);
                    }
                }

                tvThemes.Nodes.Add(themeFileNode);
                themeFileNode.Expand();
            }
        }
        private void OnPlayerEvent(IntPtr handle, IntPtr evtHandle, IntPtr userdata)
        {
            dz_player_event_t evtType = DeezerApi.dz_player_event_get_type(evtHandle);

            Logger.LogTrace("DeezerRenderer::OnPlayerEvent evtType={0}", evtType);

            switch (evtType)
            {
            case dz_player_event_t.DZ_PLAYER_EVENT_QUEUELIST_TRACK_SELECTED:
            {
                string  selectedInfo = DeezerApi.dz_player_event_track_selected_dzapiinfo(evtHandle);
                dynamic obj2         = JObject.Parse(selectedInfo);
                _duration = obj2.duration;
            }
            break;

            case dz_player_event_t.DZ_PLAYER_EVENT_RENDER_TRACK_START:
                _evtPlayerPlaybackStarted.Set();
                FilterState = FilterState.Running;
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_RENDER_TRACK_RESUMED:
                FilterState = FilterState.Running;
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_RENDER_TRACK_PAUSED:
                _evtPlayerPaused.Set();
                FilterState = FilterState.Paused;
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_RENDER_TRACK_END:
            case dz_player_event_t.DZ_PLAYER_EVENT_RENDER_TRACK_REMOVED:
                if (_needNaturalNext)
                {
                    // HACK: The Deezer Native SDK told us that we should advance
                    // to the next item by using a "natural next" (WTF is that anyways ??)
                    _needNaturalNext = false;
                    // So this is exactly what we'll give it ...
                    OPMShortcutEventArgs args = new OPMShortcutEventArgs(OPMShortcut.CmdNext);
                    EventDispatch.DispatchEvent(EventNames.ExecuteShortcut, args);
                }
                else
                {
                    _evtPlayerPlaybackStopped.Set();
                    FilterState    = FilterState.Stopped;
                    RenderPosition = 0;
                }
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_MEDIASTREAM_DATA_READY_AFTER_SEEK:
                _evtPlayerStreamReadyAfterSeek.Set();
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_QUEUELIST_NEED_NATURAL_NEXT:
                _needNaturalNext = true;
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_QUEUELIST_LOADED:
                _evtQueueListLoaded.Set();
                break;

            case dz_player_event_t.DZ_PLAYER_EVENT_QUEUELIST_NO_RIGHT:
                _evtQueueListLoaded.Reset();
                break;
            }
        }
예제 #26
0
 private void ReceiveCommand(List <MsgResponse> command)
 {
     EventDispatch.DispatchEvent(command);
 }
예제 #27
0
        public void HandlePlaylistItemMenuClick(object sender, EventArgs e)
        {
            OPMToolStripMenuItem senderMenu = (sender as OPMToolStripMenuItem);

            if (senderMenu != null)
            {
                try
                {
                    senderMenu.Enabled = false;

                    if (senderMenu.Tag != null)
                    {
                        if (senderMenu.Tag is PlaylistSubItem)
                        {
                            if (senderMenu.Tag is DvdSubItem)
                            {
                                DvdSubItem            si   = senderMenu.Tag as DvdSubItem;
                                DvdRenderingStartHint hint =
                                    (si != null) ?
                                    si.StartHint as DvdRenderingStartHint : null;

                                if (hint != null && hint.IsSubtitleHint)
                                {
                                    MediaRenderer.DefaultInstance.SubtitleStream = hint.SID;
                                    return;
                                }
                            }

                            if (senderMenu.Tag is AudioCdSubItem)
                            {
                                CDAFileInfo cdfi = (senderMenu.Tag as AudioCdSubItem).Parent.MediaFileInfo as CDAFileInfo;
                                if (cdfi != null)
                                {
                                    cdfi.RefreshDisk();
                                    EventDispatch.DispatchEvent(LocalEventNames.UpdatePlaylistNames, true);
                                }
                            }
                            else
                            {
                                PlaylistSubItem psi = senderMenu.Tag as PlaylistSubItem;
                                if (psi != null && psi.StartHint != null)
                                {
                                    JumpToPlaylistSubItem(senderMenu.Tag as PlaylistSubItem);
                                }
                            }
                        }
                        else if (senderMenu.Tag is PlaylistItem)
                        {
                            JumpToPlaylistItem(senderMenu.Tag as PlaylistItem);
                        }
                        else
                        {
                            ShortcutMapper.DispatchCommand((OPMShortcut)senderMenu.Tag);
                        }
                    }
                }
                finally
                {
                    senderMenu.Enabled = true;
                }
            }
        }
예제 #28
0
        void _wcdReceiver_DataReceived(string data)
        {
            BasicCommand cmd = BasicCommand.Create(data);

            EventDispatch.DispatchEvent(BasicCommand.EventName, cmd);
        }
예제 #29
0
        public static void AttemptDownload(object state)
        {
            try
            {
                Dictionary <SubtitleDownloader, List <SubtitleInfo> > subtitleDownloadInfo =
                    new Dictionary <SubtitleDownloader, List <SubtitleInfo> >();

                int totalSubtitlesFound = 0;

                string movieFilePath = state as string;

                if (!string.IsNullOrEmpty(movieFilePath))
                {
                    SetCurrentSubtitle(movieFilePath, string.Empty);

                    lock (__filesInProgress)
                    {
                        __filesInProgress.Add(movieFilePath.ToLowerInvariant());

                        // This is for enforcing playlist refresh
                        EventDispatch.DispatchEvent(LocalEvents.UpdatePlaylistNames, false);
                    }

                    Logger.LogTrace("A subtitle was not found for this movie. Attempting to download one ...");

                    try
                    {
                        string[] subtitleDownloadURIs = StringUtils.ToStringArray(ProTONEConfig.SubtitleDownloadURIs, '\\');
                        if (subtitleDownloadURIs != null)
                        {
                            int prio = 1;

                            foreach (string subtitleDownloadURI in subtitleDownloadURIs)
                            {
                                SubtitleDownloader  sd             = null;
                                List <SubtitleInfo> foundSubtitles = null;

                                try
                                {
                                    sd = SubtitleDownloader.FromDownloadURI(subtitleDownloadURI);
                                    if (sd.IsActive)
                                    {
                                        sd.Priority    = prio++;
                                        foundSubtitles = sd.GetSubtitles(movieFilePath);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.LogException(ex);
                                    FireNotify(Translator.Translate("TXT_SUB_DOWNLOAD_ERROR"),
                                               Translator.Translate("TXT_ERROR"), MessageBoxIcon.Warning);
                                }
                                finally
                                {
                                    if (sd != null)
                                    {
                                        if (foundSubtitles != null && foundSubtitles.Count > 0)
                                        {
                                            subtitleDownloadInfo.Add(sd, foundSubtitles);
                                            totalSubtitlesFound += foundSubtitles.Count;
                                        }
                                    }
                                }
                            }
                        }

                        if (totalSubtitlesFound < 1)
                        {
                            // No subtitles found, give message and exit

                            FireNotify(Translator.Translate("TXT_NO_SUBS_FOUND"),
                                       Translator.Translate("TXT_CAUTION"), MessageBoxIcon.Warning);

                            return;
                        }
                        else
                        {
                            MainThread.Post(delegate(object x)
                            {
                                SubtitleDownloadNotifyForm dlg = new SubtitleDownloadNotifyForm(movieFilePath, subtitleDownloadInfo);
                                dlg.SubtitleDownloadNotify    += new SubtitleDownloadNotifyHandler(dlg_SubtitleDownloadNotify);
                                dlg.Show();

                                //dlg.CenterToScreen();
                            });
                        }

                        // Perform cleanup

                        foreach (SubtitleDownloader sd in subtitleDownloadInfo.Keys)
                        {
                            if (sd != null)
                            {
                                sd.Dispose();
                            }
                        }
                    }
                    finally
                    {
                        lock (__filesInProgress)
                        {
                            __filesInProgress.Remove(movieFilePath.ToLowerInvariant());

                            // This is for enforcing playlist refresh
                            EventDispatch.DispatchEvent(LocalEvents.UpdatePlaylistNames, false);
                        }
                    }
                }
            }
            finally
            {
                // This is for enforcing playlist refresh
                EventDispatch.DispatchEvent(LocalEvents.UpdatePlaylistNames, false);
            }
        }
예제 #30
0
 private static void FireNotify(string message, string title, MessageBoxIcon icon)
 {
     EventDispatch.DispatchEvent(EventNames.ShowTrayMessage, message, title, icon);
 }