Beispiel #1
0
        // Set initial state of controls.
        // Called from worker thread using delegate and Control.Invoke
        private void ThreadFinishedMethod(String artist, String title, String message, String site)
        {
            if (_timer != null)
            {
                _timer.Enabled = false;
                _timer.Stop();
                _timer.Dispose();
                _timer = null;
                _hour  = 0;
                _min   = 0;
                _sec   = 0;
            }

            if (_lyricsController != null)
            {
                _lyricsController.StopSearches = true;
                DatabaseUtil.SerializeDBs();
                _lyricsLibraryUserControl.UpdateLyricsTree(false);
            }
            bgWorkerSearch.CancelAsync();
            StopThread();
            progressBar.ResetText();
            progressBar.Enabled = false;

            if (site.Equals("error"))
            {
                lbStep1a.Text = "-";
                lbStep2a.Text = "-";
            }
            else
            {
                lbStep1a.Text = "Completed";
                lbStep2a.Text = "Completed";
            }

            lbMessage.Text += message + Environment.NewLine;

            btStartBatchSearch.Enabled = true;
            btCancel.Enabled           = false;
            IsSearching(false);

            var logText = string.Format("The search has ended with {0} found and {1} missed.", _mLyricsFound,
                                        _mLyricsNotFound);

            lbLastActivity2.Text = logText;

            BatchLogger.Info("{0}", logText);
            BatchLogger.Info("Batch search ended.");
        }
Beispiel #2
0
        public MyLyricsSetup()
        {
            #region Initialize GUI and class

            InitializeComponent();
            _lyricsLibraryUserControl       = new LyricsLibrary(this);
            _musicDatabaseBrowseUserControl = new MusicDatabaseBrowse(this);
            Information informationUserControl = new Information();
            Help        helpUserControl        = new Help();

            tabPageLyricsDatabase.Controls.Add(_lyricsLibraryUserControl);
            tabPageMusicDatabaseBrowse.Controls.Add(_musicDatabaseBrowseUserControl);
            tabPageAbout.Controls.Add(informationUserControl);
            tabPageHelp.Controls.Add(helpUserControl);

            // initialize delegates
            MDelegateLyricFound      = LyricFoundMethod;
            MDelegateLyricNotFound   = LyricNotFoundMethod;
            MDelegateThreadFinished  = ThreadFinishedMethod;
            MDelegateThreadException = ThreadExceptionMethod;

            // Grab music database
            var mDB = MusicDatabase.Instance;

            _mTotalTitles = mDB.GetTotalSongs();


            foreach (var lang in Language.TranslatableCollection)
            {
                comboBoxLanguages.Items.Add(string.Format("{0} ({1})", lang.Name, lang.Value));
            }

            #endregion

            InitSitesList();

            GetSettingsFromConfigurationXml();

            #region Serialzie/deserialize lyricsdatabases

            var path     = Config.GetFile(Config.Dir.Database, MyLyricsUtils.LyricsDBName);
            var fileInfo = new FileInfo(path);

            // .. but only if the databases hasn't been created
            if (fileInfo.Exists == false)
            {
                path = Config.GetFile(Config.Dir.Database, MyLyricsUtils.LyricsDBName);

                // Serialize empty LyricsDatabase if no lyrics.xml present
                var fs = new FileStream(path, FileMode.Create);
                var bf = new BinaryFormatter();
                MyLyricsUtils.LyricsDB = new LyricsDatabase();
                bf.Serialize(fs, MyLyricsUtils.LyricsDB);
                fs.Close();

                // Serialize empty LyricsMarkedDatabase
                path = Config.GetFile(Config.Dir.Database, MyLyricsUtils.LyricsMarkedDBName);
                fs   = new FileStream(path, FileMode.Create);
                MyLyricsUtils.LyricsMarkedDB = new LyricsDatabase();
                bf.Serialize(fs, MyLyricsUtils.LyricsMarkedDB);
                fs.Close();
            }
            else
            {
                DeserializeBothDB();
            }

            LyricsLibrary.CurrentLyricsDatabase = MyLyricsUtils.LyricsDB;

            #endregion

            _lyricsLibraryUserControl.UpdateLyricsTree(false);
        }