private void ListboxArtistsUpdate(object sender, EventArgs e) { _mMDb = MusicDatabase.Instance; var artists = new ArrayList(); //mdb.GetArtists(0, String.Empty, ref artists); _mMDb.GetAllArtists(ref artists); lvArtists.Items.Clear(); lbSelectedArtist.Text = String.Empty; MDelegateStringUpdate = UpdateStringMethod; MDelegateStatusUpdate = UpdateStatusMethod; MDelegateLyricFound = LyricFoundMethod; MDelegateLyricNotFound = LyricNotFoundMethod; MDelegateThreadFinished = ThreadFinishedMethod; MDelegateThreadException = ThreadExceptionMethod; foreach (var artist in artists) { var lvi = new ListViewItem((string)artist); lvArtists.Items.Add(lvi); } lvArtists.Sorting = SortOrder.Ascending; lvSongs.Items.Clear(); lbArtistNumber.Text = String.Format("{0} artists found", lvArtists.Items.Count); }
public MyLyricsSetup_SearchTitleDialog(MyLyricsSetup_LyricsLibrary form, string artist, string title, bool markedDatabase) { InitializeComponent(); this.parent = form; this.markedDatabase = markedDatabase; // initialize delegates m_DelegateStringUpdate = new DelegateStringUpdate(this.updateStringMethod); m_DelegateStatusUpdate = new DelegateStatusUpdate(this.updateStatusMethod); m_DelegateLyricFound = new DelegateLyricFound(this.lyricFoundMethod); m_DelegateLyricNotFound = new DelegateLyricNotFound(this.lyricNotFoundMethod); m_DelegateThreadFinished = new DelegateThreadFinished(this.ThreadFinishedMethod); m_DelegateThreadException = new DelegateThreadException(this.ThreadExceptionMethod); // initialize events m_EventStopThread = new ManualResetEvent(false); tbArtist.Text = artist; tbTitle.Text = title; originalArtist = artist; originalTitle = title; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) { cbLyricWiki.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricWiki", "True")).ToString().Equals("True") ? true : false; cbEvilLabs.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useEvilLabs", "True")).ToString().Equals("True") ? true : false; cbLyrics007.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyrics007", "True")).ToString().Equals("True") ? true : false; cbLyricsOnDemand.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricsOnDemand", "True")).ToString().Equals("True") ? true : false; cbSeekLyrics.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useSeekLyrics", "True")).ToString().Equals("True") ? true : false; cbHotLyrics.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useHotLyrics", "True")).ToString().Equals("True") ? true : false; automaticFetch = xmlreader.GetValueAsBool("myLyrics", "automaticFetch", true); automaticUpdate = xmlreader.GetValueAsBool("myLyrics", "automaticUpdateWhenFirstFound", false); moveLyricFromMarkedDatabase = xmlreader.GetValueAsBool("myLyrics", "moveLyricFromMarkedDatabase", true); } this.Show(); if (artist.Length != 0 && title.Length != 0) { if (automaticFetch) { fetchLyric(originalArtist, originalTitle); lvSearchResults.Focus(); } else { btFind.Focus(); } } else if (artist.Length != 0) { tbTitle.Focus(); } else { tbArtist.Focus(); } }
private void OnLoad(object sender, EventArgs e) { log.Trace(">>>"); BackColor = ServiceScope.Get <IThemeManager>().CurrentTheme.BackColor; ServiceScope.Get <IThemeManager>().NotifyThemeChange(); // Load the Settings gridColumns = new GridViewColumnsLyrics(); // Setup Dataview Grid dataGridViewLyrics.AutoGenerateColumns = false; dataGridViewLyrics.DataSource = tracks; // Now Setup the columns, we want to display CreateColumns(); Localisation(); sitesToSearch = Options.MainSettings.LyricSites; // initialize delegates m_DelegateLyricFound = new DelegateLyricFound(lyricFound); m_DelegateLyricNotFound = new DelegateLyricNotFound(lyricNotFound); m_DelegateThreadFinished = new DelegateThreadFinished(threadFinished); m_DelegateThreadException = new DelegateThreadException(threadException); m_EventStopThread = new ManualResetEvent(false); bgWorkerLyrics = new BackgroundWorker(); bgWorkerLyrics.DoWork += bgWorkerLyrics_DoWork; bgWorkerLyrics.ProgressChanged += bgWorkerLyrics_ProgressChanged; bgWorkerLyrics.RunWorkerCompleted += bgWorkerLyrics_RunWorkerCompleted; bgWorkerLyrics.WorkerSupportsCancellation = true; lbFinished.Visible = false; lyricsQueue = new Queue(); dataGridViewLyrics.ReadOnly = true; foreach (TrackData track in tracks) { string[] lyricId = new string[2] { track.Artist, track.Title }; lyricsQueue.Enqueue(lyricId); } bgWorkerLyrics.RunWorkerAsync(); log.Trace("<<<"); }
public FindLyric(LyricsLibrary parent, string artist, string title, bool markedDatabase, int treeArtistIndex, int treeTitleIndex) { InitializeComponent(); Text = String.Format("Find a lyric for {0} - {1}", artist, title); _parent = parent; _markedDatabase = markedDatabase; _treeArtistIndex = treeArtistIndex; _treeTitleIndex = treeTitleIndex; // initialize delegates MDelegateStringUpdate = UpdateStringMethod; MDelegateStatusUpdate = UpdateStatusMethod; MDelegateLyricFound = LyricFoundMethod; MDelegateLyricNotFound = LyricNotFoundMethod; MDelegateThreadFinished = ThreadFinishedMethod; MDelegateThreadException = ThreadExceptionMethod; // initialize events _mEventStopThread = new ManualResetEvent(false); tbArtist.Text = artist; tbTitle.Text = title; _originalArtist = artist; _originalTitle = title; var lyricsSitesNames = LyricsSiteFactory.LyricsSitesNames(); singleRunSitesList.Items.Clear(); foreach (var site in lyricsSitesNames) { singleRunSitesList.Items.Add(site, SettingManager.GetParamAsBool(SettingManager.SitePrefix + site, false)); } _mAutomaticFetch = SettingManager.GetParamAsBool(SettingManager.AutomaticFetch, true); _mAutomaticUpdate = SettingManager.GetParamAsBool(SettingManager.AutomaticUpdateWhenFirstFound, false); _mMoveLyricFromMarkedDatabase = SettingManager.GetParamAsBool(SettingManager.MoveLyricFromMarkedDatabase, true); _mAutomaticWriteToMusicTag = SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true); _mFind = SettingManager.GetParamAsString(SettingManager.Find, ""); _mReplace = SettingManager.GetParamAsString(SettingManager.Replace, ""); _mStrippedPrefixStrings = MediaPortalUtil.GetStrippedPrefixStringArray(); BeginSearchIfPossible(artist, title); ShowDialog(); }
public LyricsSearch(object parent, string artist, string title, bool automaticUpdate) { InitializeComponent(); BackColor = ServiceScope.Get <IThemeManager>().CurrentTheme.BackColor; ServiceScope.Get <IThemeManager>().NotifyThemeChange(); this.parent = parent; m_automaticUpdate = automaticUpdate; // initialize delegates m_DelegateStringUpdate = new DelegateStringUpdate(updateStringMethod); m_DelegateStatusUpdate = new DelegateStatusUpdate(updateStatusMethod); m_DelegateLyricFound = new DelegateLyricFound(lyricFoundMethod); m_DelegateLyricNotFound = new DelegateLyricNotFound(lyricNotFoundMethod); m_DelegateThreadFinished = new DelegateThreadFinished(ThreadFinishedMethod); m_DelegateThreadException = new DelegateThreadException(ThreadExceptionMethod); // initialize events m_EventStopThread = new ManualResetEvent(false); tbArtist.Text = artist; tbTitle.Text = title; if (Options.MainSettings.SwitchArtist) { btSwitchArtist_Click(btSwitchArtist, new EventArgs()); } originalArtist = tbArtist.Text; originalTitle = title; LocaliseScreen(); BeginSearchIfPossible(artist, title); this.CenterToScreen(); ShowDialog(); }
public LyricsSearch(object parent, string artist, string title, bool automaticUpdate) { InitializeComponent(); BackColor = ServiceScope.Get<IThemeManager>().CurrentTheme.BackColor; ServiceScope.Get<IThemeManager>().NotifyThemeChange(); this.parent = parent; m_automaticUpdate = automaticUpdate; // initialize delegates m_DelegateStringUpdate = new DelegateStringUpdate(updateStringMethod); m_DelegateStatusUpdate = new DelegateStatusUpdate(updateStatusMethod); m_DelegateLyricFound = new DelegateLyricFound(lyricFoundMethod); m_DelegateLyricNotFound = new DelegateLyricNotFound(lyricNotFoundMethod); m_DelegateThreadFinished = new DelegateThreadFinished(ThreadFinishedMethod); m_DelegateThreadException = new DelegateThreadException(ThreadExceptionMethod); // initialize events m_EventStopThread = new ManualResetEvent(false); tbArtist.Text = artist; tbTitle.Text = title; if (Options.MainSettings.SwitchArtist) btSwitchArtist_Click(btSwitchArtist, new EventArgs()); originalArtist = tbArtist.Text; originalTitle = title; LocaliseScreen(); BeginSearchIfPossible(artist, title); this.CenterToScreen(); ShowDialog(); }
private void OnLoad(object sender, EventArgs e) { log.Trace(">>>"); BackColor = ServiceScope.Get<IThemeManager>().CurrentTheme.BackColor; ServiceScope.Get<IThemeManager>().NotifyThemeChange(); // Load the Settings gridColumns = new GridViewColumnsLyrics(); // Setup Dataview Grid dataGridViewLyrics.AutoGenerateColumns = false; dataGridViewLyrics.DataSource = tracks; // Now Setup the columns, we want to display CreateColumns(); Localisation(); sitesToSearch = new List<string>(); if (Options.MainSettings.SearchLyricWiki) sitesToSearch.Add("LyricWiki"); if (Options.MainSettings.SearchHotLyrics) sitesToSearch.Add("HotLyrics"); if (Options.MainSettings.SearchLyrics007) sitesToSearch.Add("Lyrics007"); if (Options.MainSettings.SearchLyricsOnDemand) sitesToSearch.Add("LyricsOnDemand"); if (Options.MainSettings.SearchLyricsPlugin) sitesToSearch.Add("LyricsPluginSite"); if (Options.MainSettings.SearchActionext) sitesToSearch.Add("Actionext"); if (Options.MainSettings.SearchLyrDB) sitesToSearch.Add("LyrDB"); if (Options.MainSettings.SearchLRCFinder) sitesToSearch.Add("LrcFinder"); // initialize delegates m_DelegateLyricFound = new DelegateLyricFound(lyricFound); m_DelegateLyricNotFound = new DelegateLyricNotFound(lyricNotFound); m_DelegateThreadFinished = new DelegateThreadFinished(threadFinished); m_DelegateThreadException = new DelegateThreadException(threadException); m_EventStopThread = new ManualResetEvent(false); bgWorkerLyrics = new BackgroundWorker(); bgWorkerLyrics.DoWork += bgWorkerLyrics_DoWork; bgWorkerLyrics.ProgressChanged += bgWorkerLyrics_ProgressChanged; bgWorkerLyrics.RunWorkerCompleted += bgWorkerLyrics_RunWorkerCompleted; bgWorkerLyrics.WorkerSupportsCancellation = true; lbFinished.Visible = false; lyricsQueue = new Queue(); dataGridViewLyrics.ReadOnly = true; foreach (TrackData track in tracks) { string[] lyricId = new string[2] {track.Artist, track.Title}; lyricsQueue.Enqueue(lyricId); } bgWorkerLyrics.RunWorkerAsync(); log.Trace("<<<"); }
public MyLyricsSetup() { LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, MyLyricsSettings.LogName)); //LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log)); #region Initialize GUI and class InitializeComponent(); lyricsLibraryUC = new MyLyricsSetup_LyricsLibrary(this); this.tabPageLyricsDatabase.Controls.Add(lyricsLibraryUC); // initialize delegates m_DelegateLyricFound = new DelegateLyricFound(this.lyricFoundMethod); m_DelegateLyricNotFound = new DelegateLyricNotFound(this.lyricNotFoundMethod); m_DelegateThreadFinished = new DelegateThreadFinished(this.ThreadFinishedMethod); m_DelegateThreadException = new DelegateThreadException(this.ThreadExceptionMethod); // Grab music database MusicDatabase dbs = new MusicDatabase(); m_TotalTitles = dbs.GetNumOfSongs(); #endregion #region Get settings from in MediaPortal.xml using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) { try { tbLimit.Text = xmlreader.GetValueAsString("myLyrics", "limit", m_TotalTitles.ToString()); tbPluginName.Text = xmlreader.GetValueAsString("myLyrics", "pluginsName", "My Lyrics"); cbAutoFetch.Checked = xmlreader.GetValueAsBool("myLyrics", "automaticFetch", true); cbAutomaticUpdate.Checked = xmlreader.GetValueAsBool("myLyrics", "automaticUpdateWhenFirstFound", false); cbMoveSongFrom.Checked = xmlreader.GetValueAsBool("myLyrics", "moveLyricFromMarkedDatabase", true); lbSongsLimitNote.Text = ("(You have currently " + m_TotalTitles.ToString() + " titles in your music database)"); rdDefault.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useDefaultSitesMode", "True")).ToString().Equals("True") ? true : false; trackBar.Value = ((int)xmlreader.GetValueAsInt("myLyrics", "defaultSitesModeValue", 2)); trackBar_Scroll(null, null); if (!rdDefault.Checked) { trackBar.Enabled = false; rbUserDefined.Checked = true; cbLyricWiki.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricWiki", "True")).ToString().Equals("True") ? true : false; cbEvilLabs.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useEvilLabs", "True")).ToString().Equals("True") ? true : false; cbLyrics007.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyrics007", "True")).ToString().Equals("True") ? true : false; cbLyricsOnDemand.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricsOnDemand", "True")).ToString().Equals("True") ? true : false; cbSeekLyrics.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useSeekLyrics", "True")).ToString().Equals("True") ? true : false; cbHotLyrics.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useHotLyrics", "True")).ToString().Equals("True") ? true : false; } } catch { MessageBox.Show("Something has gone wrong when reading Mediaportal.xml"); } } #endregion #region Serialzie/deserialize lyricsdatabases string lyricsXMLpath = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Base, MyLyricsSettings.LyricsXMLName); FileInfo lyricsXMLfileInfo = new FileInfo(lyricsXMLpath); // If lyrics.xml present, then convert database to new format... if (lyricsXMLfileInfo.Exists) { string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); FileInfo fileInfo = new FileInfo(path); // .. but only if it hasn't already been converted if (fileInfo.Exists == false) { if (MessageBox.Show(this, "Your database will have to be upgraded to work with this version\r\nUpgrade now?", "Upgrade lyricsdatabase", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { ConvertFromXMLtoLyricsDatabase convertFromXMLtoLyricsDatabase = new ConvertFromXMLtoLyricsDatabase(); MyLyricsSettings.LyricsDB = convertFromXMLtoLyricsDatabase.Convert(lyricsXMLpath); // Create file to save the database to FileStream fs = new FileStream(path, FileMode.Create); // Create a BinaryFormatter object to perform the serialization BinaryFormatter bf = new BinaryFormatter(); // Use the BinaryFormatter object to serialize the database to the file bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); // Create likewise a database for the remainingLyrics path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Create); MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); // Close the file fs.Close(); } } // ... else deserialize the databases and save reference in LyricsDB and LyricsMarkedDB else { DeserializeBothDB(); } } // If no Lyrics.xml present in base, then create new serialized databases else { string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); FileInfo fileInfo = new FileInfo(path); // .. but only if the databases hasn't been created if (fileInfo.Exists == false) { path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); // Serialize empty LyricsDatabase if no lyrics.xml present FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); MyLyricsSettings.LyricsDB = new LyricsDatabase(); bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); // Serialize empty LyricsMarkedDatabase path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Create); MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); fs.Close(); } else { DeserializeBothDB(); } } MyLyricsSetup_LyricsLibrary.CurrentDB = MyLyricsSettings.LyricsDB; #endregion lyricsLibraryUC.updateLyricsTree(); }
private void OnLoad(object sender, EventArgs e) { log.Trace(">>>"); BackColor = ServiceScope.Get<IThemeManager>().CurrentTheme.BackColor; ServiceScope.Get<IThemeManager>().NotifyThemeChange(); // Load the Settings _gridColumns = new GridViewColumnsLyrics(); // Setup Dataview Grid dataGridViewLyrics.AutoGenerateColumns = false; dataGridViewLyrics.DataSource = _tracks; // Now Setup the columns, we want to display CreateColumns(); Localisation(); _sitesToSearch = Options.MainSettings.LyricSites; // initialize delegates _delegateLyricFound = lyricFound; _delegateLyricNotFound = lyricNotFound; _delegateThreadFinished = threadFinished; _delegateThreadException = threadException; _eventStopThread = new ManualResetEvent(false); _bgWorkerLyrics = new BackgroundWorker(); _bgWorkerLyrics.DoWork += bgWorkerLyrics_DoWork; _bgWorkerLyrics.ProgressChanged += bgWorkerLyrics_ProgressChanged; _bgWorkerLyrics.RunWorkerCompleted += bgWorkerLyrics_RunWorkerCompleted; _bgWorkerLyrics.WorkerSupportsCancellation = true; lbFinished.Visible = false; _lyricsQueue = new Queue(); dataGridViewLyrics.ReadOnly = true; foreach (TrackData track in _tracks) { string[] lyricId = new string[] {track.Artist, track.Title}; _lyricsQueue.Enqueue(lyricId); } _bgWorkerLyrics.RunWorkerAsync(); log.Trace("<<<"); }
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); }