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();
            }
        }
Example #2
0
        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();
        }
Example #3
0
 public MyLyricsSetup_AddNewSong(MyLyricsSetup_LyricsLibrary parent)
 {
     InitializeComponent();
     this.parent = parent;
     this.Show();
 }