Пример #1
0
        string opmShellList_QueryDisplayName(string fsi)
        {
            if (fsi != null)
            {
                if (fsi.ToUpperInvariant().EndsWith("CDA"))
                {
                    CDAFileInfo cdfi = MediaFileInfo.FromPath(fsi) as CDAFileInfo;
                    if (cdfi != null)
                    {
                        return(cdfi.DisplayName);
                    }
                }

                return(Path.GetFileName(fsi));
            }

            return(string.Empty);
        }
Пример #2
0
        private void InternalShowProperties(bool deepLoad)
        {
            PerformTranslation();

            lii = new List <object>();
            foreach (string item in strItems)
            {
                CDAFileInfo ii = new CDAFileInfo(item, deepLoad && (strItems.Count == 1));
                if (ii.IsValid)
                {
                    lii.Add(ii);
                }
            }

            FileAttributesBrowser.ProcessObjectAttributes(lii);

            pgProperties.SelectedObjects = lii.ToArray();
            base.Modified = false;
        }
Пример #3
0
        private void LoadFiles()
        {
            OPMOpenFileDialog dlg = new OPMOpenFileDialog();

            dlg.Title       = Translator.Translate("TXT_LOADMEDIAFILES");
            dlg.Multiselect = true;

            dlg.InheritAppIcon = false;
            dlg.Icon           = Resources.btnLoad.ToIcon((uint)Color.White.ToArgb());

            string filter = string.Empty;

            filter += MediaRenderer.DefaultInstance.AvailableFileTypesFilter;
            filter += Translator.Translate("TXT_ALL_FILES_FILTER");

            filter = filter.Replace("TXT_AUDIO_FILES", Translator.Translate("TXT_AUDIO_FILES"));
            filter = filter.Replace("TXT_VIDEO_FILES", Translator.Translate("TXT_VIDEO_FILES"));
            filter = filter.Replace("TXT_VIDEO_HD_FILES", Translator.Translate("TXT_VIDEO_HD_FILES"));
            filter = filter.Replace("TXT_PLAYLISTS", Translator.Translate("TXT_PLAYLISTS"));

            dlg.Filter = filter;

            dlg.FilterIndex      = ProTONEConfig.LastFilterIndex;
            dlg.InitialDirectory = ProTONEConfig.LastOpenedFolder;

            dlg.FillFavoriteFoldersEvt += () => { return(ProTONEConfig.GetFavoriteFolders("FavoriteFolders")); };
            dlg.AddToFavoriteFolders   += (s) => { return(ProTONEConfig.AddToFavoriteFolders(s)); };

            dlg.QueryDisplayName += (fsi) =>
            {
                if (fsi != null)
                {
                    if (fsi.ToUpperInvariant().EndsWith("CDA"))
                    {
                        CDAFileInfo cdfi = MediaFileInfo.FromPath(fsi) as CDAFileInfo;
                        if (cdfi != null)
                        {
                            return(cdfi.DisplayName);
                        }
                    }

                    return(Path.GetFileName(fsi));
                }

                return(string.Empty);
            };

            dlg.ShowAddToFavorites = true;

            dlg.OpenDropDownOptions = new List <OpenOption>(new OpenOption[]
            {
                new MediaPlayerOpenOption(CommandType.PlayFiles),
                new MediaPlayerOpenOption(CommandType.EnqueueFiles)
            });

            if (dlg.ShowDialog() == DialogResult.OK && dlg.FileNames.Length > 0)
            {
                CommandType openOption = CommandType.PlayFiles;
                try
                {
                    openOption = (CommandType)dlg.OpenOption;
                }
                catch
                {
                    openOption = CommandType.PlayFiles;
                }

                if (openOption == CommandType.EnqueueFiles)
                {
                    EnqueueFiles(dlg.FileNames);
                }
                else
                {
                    LoadFiles(dlg.FileNames);
                }

                ProTONEConfig.LastFilterIndex = dlg.FilterIndex;

                try
                {
                    string file = dlg.FileNames[0];
                    ProTONEConfig.LastOpenedFolder = Path.GetDirectoryName(file);
                }
                catch
                {
                    ProTONEConfig.LastOpenedFolder = dlg.InitialDirectory;
                }
            }
        }
Пример #4
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;
                }
            }
        }
        private void OnDriveSelected(object sender, EventArgs e)
        {
            Wizard.CanMoveNext = false;
            lvTracks.Items.Clear();

            DriveInfoItem item = cmbAudioCDDrives.SelectedItem as DriveInfoItem;

            if (item != null)
            {
                string rootPath = System.IO.Path.GetPathRoot(item.Path);
                if (!string.IsNullOrEmpty(rootPath))
                {
                    (BkgTask as Task).DrivePath = rootPath;

                    CDEntry cdEntry = null;
                    char    letter  = rootPath.ToUpperInvariant()[0];
                    using (CDDrive cd = new CDDrive())
                    {
                        if (cd.Open(letter) && cd.Refresh())
                        {
                            // Check whether the disc is already added to our persistent storage
                            string discId = cd.GetCDDBDiskID();
                            cdEntry = CDEntry.LoadPersistentDisc(discId);

                            if (cdEntry == null)
                            {
                                switch (ProTONEConfig.AudioCdInfoSource)
                                {
                                case CddaInfoSource.CdText:
                                    cdEntry = CDAFileInfo.BuildCdEntryByCdText(cd, cd.GetCDDBDiskID());
                                    break;

                                case CddaInfoSource.Cddb:
                                    cdEntry = CDAFileInfo.BuildCdEntryByCddb(cd, cd.GetCDDBDiskID());
                                    break;

                                case CddaInfoSource.CdText_Cddb:
                                {
                                    cdEntry = CDAFileInfo.BuildCdEntryByCdText(cd, cd.GetCDDBDiskID());
                                    CDEntry cde = CDAFileInfo.BuildCdEntryByCddb(cd, cd.GetCDDBDiskID());
                                    cdEntry = CDAFileInfo.Merge(cdEntry, cde);
                                }
                                break;

                                case CddaInfoSource.Cddb_CdText:
                                {
                                    cdEntry = CDAFileInfo.BuildCdEntryByCddb(cd, cd.GetCDDBDiskID());
                                    CDEntry cde = CDAFileInfo.BuildCdEntryByCdText(cd, cd.GetCDDBDiskID());
                                    cdEntry = CDAFileInfo.Merge(cdEntry, cde);
                                }
                                break;

                                default:
                                    break;
                                }

                                if (cdEntry != null)
                                {
                                    // Cache the disk to persistent storage for retrieving it faster later on
                                    cdEntry.PersistDisc();
                                }
                            }
                        }

                        if (cdEntry != null)
                        {
                            for (int i = 1; i <= cdEntry.NumberOfTracks; i++)
                            {
                                double size     = cd.TrackSize(i);
                                int    duration = cd.GetSeconds(i);

                                ListViewItem lvItem = new ListViewItem(i.ToString());

                                lvItem.SubItems.Add(TimeSpan.FromSeconds(duration).ToString());
                                lvItem.SubItems.Add(((size / (1024 * 1024)).ToString("F")) + " MB");

                                OPMListViewSubItem subItem = new OPMListViewSubItem(tbEditAlbum, lvItem,
                                                                                    cdEntry.Tracks[i - 1].Album ?? string.Empty);
                                subItem.ReadOnly = false;
                                lvItem.SubItems.Add(subItem);

                                subItem = new OPMListViewSubItem(tbEditArtist, lvItem,
                                                                 cdEntry.Tracks[i - 1].Artist ?? string.Empty);
                                subItem.ReadOnly = false;
                                lvItem.SubItems.Add(subItem);

                                subItem = new OPMListViewSubItem(tbEditTitle, lvItem,
                                                                 cdEntry.Tracks[i - 1].Title ?? string.Empty);
                                subItem.ReadOnly = false;
                                lvItem.SubItems.Add(subItem);

                                subItem = new OPMListViewSubItem(cmbEditgenre, lvItem,
                                                                 cdEntry.Tracks[i - 1].Genre ?? string.Empty);
                                subItem.ReadOnly = false;
                                lvItem.SubItems.Add(subItem);

                                if (Wizard.RepeatCount == 0)
                                {
                                    lvItem.ImageIndex = 1;
                                }
                                else
                                {
                                    //lvItem.ImageIndex = ((BkgTask as Task).Tracks.Contains(i)) ? 1 : 0;
                                }

                                lvItem.Tag = cdEntry.Tracks[i - 1];

                                lvTracks.Items.Add(lvItem);
                            }
                        }
                    }
                }
            }

            CheckNextButton();
        }