private void btUpdate_Click(object sender, EventArgs e)
        {
            if (lvSearchResults.SelectedItems.Count > 0)
            {
                stopSearch();
                ListViewItem item  = lvSearchResults.Items[0];
                string       site  = lvSearchResults.SelectedItems[0].Text;
                string       lyric = tbLyrics.Text;

                if (markedDatabase && moveLyricFromMarkedDatabase)
                {
                    parent.RemoveSong(originalArtist, originalTitle);
                    string key = DatabaseUtil.CorrectKeyFormat(originalArtist, originalTitle);
                    MyLyricsSettings.LyricsDB[key] = new LyricsItem(originalArtist, originalTitle, lyric, site);
                    DatabaseUtil.SerializeLyricDB();
                    parent.updateInfo();
                }
                else if (markedDatabase)
                {
                    DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsSettings.LyricsMarkedDB, originalArtist, originalTitle, lyric, site);
                    DatabaseUtil.SerializeDBs();
                    parent.updateInfo();
                    parent.highlightSong(originalArtist, originalTitle, false);
                }
                else
                {
                    DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsSettings.LyricsDB, originalArtist, originalTitle, lyric, site);
                    DatabaseUtil.SerializeDBs();
                    parent.updateInfo();
                    parent.highlightSong(originalArtist, originalTitle, false);
                }
                this.Close();
            }
        }
Exemplo n.º 2
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 (lc != null)
            {
                lc.StopSearches = true;
                DatabaseUtil.SerializeDBs();
                lyricsLibraryUC.updateLyricsTree();
            }
            bgWorkerSearch.CancelAsync();
            StopThread();
            progressBar.ResetText();
            progressBar.Enabled = false;
            lbStep1a.Text       = "Completed";
            lbStep2a.Text       = "Completed";
            lbMessage.Text      = "#" + ((int)(++m_noOfMessages)).ToString() + " - " + message + "\r\n" + lbMessage.Text + "\r\n";
            btImportAll.Enabled = true;
            btCancel.Enabled    = false;
            isSearching(false);
        }
Exemplo n.º 3
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.");
        }
Exemplo n.º 4
0
        private void UpdateSong()
        {
            if (lvSearchResults.SelectedItems.Count > 0)
            {
                StopSearch();
                var site  = lvSearchResults.SelectedItems[0].Text;
                var lyric = tbLyrics.Text;

                if (_markedDatabase && _mMoveLyricFromMarkedDatabase)
                {
                    _parent.RemoveSong(_originalArtist, _originalTitle, true);
                    var key = DatabaseUtil.CorrectKeyFormat(_originalArtist, _originalTitle);
                    MyLyricsUtils.LyricsDB[key] = new LyricsItem(_originalArtist, _originalTitle, lyric, site);
                    DatabaseUtil.SerializeLyricDB();
                    _parent.UpdateInfo();
                }
                else if (_markedDatabase)
                {
                    DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsUtils.LyricsMarkedDB, _originalArtist, _originalTitle,
                                                         lyric, site);
                    DatabaseUtil.SerializeDBs();
                    _parent.UpdateInfo();
                    _parent.HighlightSong(_originalArtist, _originalTitle, false);
                }
                else
                {
                    DatabaseUtil.ReplaceInLyricsDatabase(MyLyricsUtils.LyricsDB, _originalArtist, _originalTitle, lyric,
                                                         site);
                    DatabaseUtil.SerializeDBs();
                    _parent.UpdateInfo();
                    _parent.HighlightNextSong(_treeArtistIndex, _treeTitleIndex);
                }

                if (_mAutomaticWriteToMusicTag)
                {
                    TagReaderUtil.WriteLyrics(_originalArtist, _originalTitle, lyric);
                }

                _parent.UpdateLyricDatabaseStats();
            }
        }
Exemplo n.º 5
0
        private void MoveLyricToOtherDatabase()
        {
            var artist = "";
            var title  = "";

            if (treeView.SelectedNode != null)
            {
                var temp = treeView.SelectedNode.Text;

                if (treeView.SelectedNode.Parent != null)
                {
                    artist = treeView.SelectedNode.Parent.Text;
                    title  = temp;
                }
                else
                {
                    artist = temp;
                }
            }

            if (artist.Length == 0 && title.Length == 0)
            {
                MessageBox.Show("No artist or track selected");
            }
            else if (title.Length == 0)
            {
                var artistNode = treeView.SelectedNode;

                LyricsDatabase otherDatabase;
                if (CurrentLyricsDatabase.Equals(MyLyricsUtils.LyricsDB))
                {
                    otherDatabase = MyLyricsUtils.LyricsMarkedDB;
                }
                else
                {
                    otherDatabase = MyLyricsUtils.LyricsDB;
                }

                foreach (TreeNode node in artistNode.Nodes)
                {
                    var key  = DatabaseUtil.CorrectKeyFormat(artist, node.Text);
                    var item = CurrentLyricsDatabase[key];
                    CurrentLyricsDatabase.Remove(key);

                    if (!DatabaseUtil.IsSongInLyricsDatabase(otherDatabase, artist, item.Title).Equals(DatabaseUtil.LyricNotFound))
                    {
                        otherDatabase.Add(key, item);
                    }
                    else
                    {
                        otherDatabase[key] = item;
                    }
                }
                UpdateLyricsTree(false);
                DatabaseUtil.SerializeDBs();
            }
            else
            {
                var key  = DatabaseUtil.CorrectKeyFormat(artist, title);
                var item = CurrentLyricsDatabase[key];

                // remove song from treeview and current database
                RemoveSong(artist, title, true);

                // add song to other database and serialize it
                if (CurrentLyricsDatabase.Equals(MyLyricsUtils.LyricsDB))
                {
                    MyLyricsUtils.LyricsMarkedDB.Add(key, item);
                    DatabaseUtil.SerializeDB(MyLyricsUtils.LyricsMarkedDB);
                }
                else
                {
                    MyLyricsUtils.LyricsDB.Add(key, item);
                    DatabaseUtil.SerializeDB(MyLyricsUtils.LyricsDB);
                }
                UpdateLyricDatabaseStats();
            }

            treeView.Focus();
        }
        private void btSwitch_Click(object sender, EventArgs e)
        {
            string temp   = "";
            string artist = "";
            string title  = "";

            if (treeView.SelectedNode != null)
            {
                temp = treeView.SelectedNode.Text;

                if (treeView.SelectedNode.Parent != null)
                {
                    artist = treeView.SelectedNode.Parent.Text;
                    title  = temp;
                }
                else
                {
                    artist = temp;
                }
            }

            if (artist.Length == 0 && title.Length == 0)
            {
                MessageBox.Show("No artist or track selected");
            }
            else if (title.Length == 0)
            {
                TreeNode artistNode = treeView.SelectedNode;

                LyricsDatabase otherDatabase = null;
                if (CurrentDB.Equals(MyLyricsSettings.LyricsDB))
                {
                    otherDatabase = MyLyricsSettings.LyricsMarkedDB;
                }
                else
                {
                    otherDatabase = MyLyricsSettings.LyricsDB;
                }

                foreach (TreeNode node in artistNode.Nodes)
                {
                    string     key  = DatabaseUtil.CorrectKeyFormat(artist, node.Text);
                    LyricsItem item = CurrentDB[key];
                    CurrentDB.Remove(key);

                    if (!DatabaseUtil.IsTrackInLyricsDatabase(otherDatabase, artist, item.Title).Equals(DatabaseUtil.LYRIC_NOT_FOUND))
                    {
                        otherDatabase.Add(key, item);
                    }
                    else
                    {
                        otherDatabase[key] = item;
                    }
                }
                updateLyricsTree();
                DatabaseUtil.SerializeDBs();
            }
            else
            {
                string     key  = DatabaseUtil.CorrectKeyFormat(artist, title);
                LyricsItem item = CurrentDB[key];

                // remove song from treeview and current database
                RemoveSong(artist, title);

                // add song to other database and serialize it
                if (CurrentDB.Equals(MyLyricsSettings.LyricsDB))
                {
                    MyLyricsSettings.LyricsMarkedDB.Add(key, item);
                    DatabaseUtil.SerializeDB(MyLyricsSettings.LyricsMarkedDB);
                }
                else
                {
                    MyLyricsSettings.LyricsDB.Add(key, item);
                    DatabaseUtil.SerializeDB(MyLyricsSettings.LyricsDB);
                }
                updateLyricDatabaseStats();
            }

            treeView.Focus();
        }