예제 #1
0
        /// <summary>
        /// Die CD-Daten asynchron laden.
        /// </summary>
        public void ReadCDInformation()
        {
            cdUserControl.IsEnabled     = false;
            GridWaitProgress.Visibility = System.Windows.Visibility.Visible;

            CD.Clear();
            //CD = new DataBaseEngine.CD();
            //cdUserControl.CD = null;

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += delegate
            {
                // CD-Informationen im Hintergrund einlesen, damit Hitbase nicht blockiert ist.
                CDInfo cdInfo = SoundEngine.SoundEngine.Instance.ReadCDInformation(CDEngine.DriveLetter);

                if (cdInfo != null)
                {
                    bool mp3AudioCD = false;

                    if (cdInfo.IsPureDataCD())
                    {
                        Dispatcher.Invoke((Action) delegate
                        {
                            WpfMessageBoxResult result = WPFMessageBox.Show(System.Windows.Application.Current.MainWindow,
                                                                            StringTable.PureDataCDTitle, StringTable.PureDataCD,
                                                                            "/Big3.Hitbase.SharedResources;component/Images/Info.png",
                                                                            WpfMessageBoxButtons.YesNo, "PureDataCDScanFiles", false, 300);

                            if (result == WpfMessageBoxResult.Yes)
                            {
                                ScanDataCD(CDEngine.DriveLetter.ToString() + ":\\");
                                mp3AudioCD = true;
                            }
                        });
                    }

                    if (!mp3AudioCD)
                    {
                        CopyCDInfoToCD(cdInfo);
                    }

                    if (!FindCDInDataBase())
                    {
                        ReadCDTextInformation(cdInfo);

                        if (CD.Tracks.Count > 0 && string.IsNullOrEmpty(CD.Artist) && string.IsNullOrEmpty(CD.Title) && CD.Tracks.All(x => string.IsNullOrEmpty(x.Artist)))
                        {
                            SearchCDInCDArchive();
                        }

                        if (Settings.Current.AutoDateToday && this.dataBase.Master.DateType != DateType.None)
                        {
                            CD.Date = Misc.GetDate();
                        }

                        if (Settings.Current.AutoSearchCover)
                        {
                            if (!string.IsNullOrEmpty(CD.Artist) && !string.IsNullOrEmpty(CD.Title))
                            {
                                CDCoverAmazon.GetCDCover(this.CD);
                            }
                        }

                        if (Settings.Current.AutoSearchLyrics)
                        {
                            Dispatcher.Invoke((Action) delegate
                            {
                                waitProgress.WaitText = StringTable.SearchLyrics;
                            });

                            foreach (var track in this.CD.Tracks)
                            {
                                if (!string.IsNullOrEmpty(track.Artist) && !string.IsNullOrEmpty(track.Title))
                                {
                                    string lyrics = LyricsSearch.Search(track.Artist, track.Title);
                                    if (!string.IsNullOrEmpty(lyrics))
                                    {
                                        track.Lyrics = lyrics;
                                    }
                                }
                            }
                        }
                    }
                }
            };
            bw.RunWorkerCompleted += delegate
            {
                cdUserControl.IsEnabled = true;

                GridWaitProgress.Visibility = System.Windows.Visibility.Collapsed;

                cdUserControl.CD = CD;

                // Automatisch CD kopieren?
                if (CDEngine.IsCDInDrive && Big3.Hitbase.Configuration.Settings.Current.RecordAutoCDCopy)
                {
                    int numsoundfile = 0;

                    foreach (Track track in CD.Tracks)
                    {
                        if (track.SoundFileExists)
                        {
                            numsoundfile += 1;
                        }
                    }

                    // Wenn bereits für alle Tracks ein Soudnfile vorhanden ist mache nix...
                    if (numsoundfile != CD.NumberOfTracks)
                    {
                        HitbaseCommands.StartRecord.Execute(null, this);
                    }
                }

                UpdateTabCaption();

                // Automatisch abspielen? Wenn im Explorer ein CD-Laufwerk doppelgeklickt wurde.
                if (autoPlayTrackNumber > 0)
                {
                    if (this.CD != null && this.CD.Tracks != null && this.CD.Tracks.Count >= autoPlayTrackNumber)
                    {
                        AddToPlaylist(this.CD.Tracks[autoPlayTrackNumber - 1].ID, AddTracksToPlaylistType.Now);
                    }

                    autoPlayTrackNumber = 0;
                }
            };

            bw.RunWorkerAsync();
        }
예제 #2
0
        private void pictureButtonFrontCover_LoadFromWeb()
        {
            CDCoverAmazon.GetCDCover(this.CD);

            FillCD();
        }