Exemplo n.º 1
0
        private void DataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            SingleEdit editForm = new SingleEdit(dataGridView1.SelectedCells[dataGridView1.SelectedCells.Count - 2].Value.ToString())
            {
                Text = dataGridView1.SelectedCells[1].Value.ToString()
            };

            try
            {
                editForm.ShowDialog();
            }
            catch
            {
                //MessageBox.Show("Something happened", "Message");
            }
        }
Exemplo n.º 2
0
        private void LyricsUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories);
                errorList = "No lyrics for the following: ";

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file        = new FileInfo(files[i]);
                    var      strFileName = file.DirectoryName + "\\" + file.Name;

                    ShellObject song   = ShellObject.FromParsingName(strFileName);
                    string      artist = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumArtist));
                    string      title  = GetValue(song.Properties.GetProperty(SystemProperties.System.Title));
                    string      lyrics = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.Lyrics));

                    if (artist != "" && title != "" && (lyrics == "" || lyrics.Contains(".com") || lyrics.Contains("www.") || lyrics.Contains("http")))
                    {
                        //string lyrics = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.Lyrics));

                        var fileshell = ShellFile.FromFilePath(strFileName);
                        ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();

                        try
                        {
                            var lyricsValues = SingleEdit.ChartLyricsGet(artist, title);

                            if (lyricsValues.Item1 != null && lyricsValues.Item1 != "")
                            {
                                propertyWriter.WriteProperty(SystemProperties.System.Music.Lyrics, new string[] { lyricsValues.Item1 });
                            }
                            else if (lyricsValues.Item2 == true)
                            {
                                break;
                            }
                            else
                            {
                                errorList += Environment.NewLine + file.Name;
                            }
                        }
                        finally
                        {
                            propertyWriter.Close();
                        }
                    }
                    progressBar1.Value = Convert.ToInt32(100 * (i + 1) / files.Length);

                    if (i == files.Length - 1)
                    {
                        progressBar1.Value = 100;
                    }
                }
                ErrorList errorForm = new ErrorList(errorList);
                errorForm.ShowDialog();
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("Files not found exception!", "Error!");
            }
        }
Exemplo n.º 3
0
        private void MusixmatchUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories);
                errorList = "No data for the following: ";

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file        = new FileInfo(files[i]);
                    var      strFileName = file.DirectoryName + "\\" + file.Name;

                    ShellObject song   = ShellObject.FromParsingName(strFileName);
                    string      artist = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumArtist));
                    string      title  = GetValue(song.Properties.GetProperty(SystemProperties.System.Title));

                    if (artist != "" && title != "")
                    {
                        var    year  = GetValue(song.Properties.GetProperty(SystemProperties.System.Media.Year));
                        string album = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumTitle));

                        Shell32.Shell      shell      = new Shell32.Shell();
                        Shell32.Folder     objFolder  = shell.NameSpace(System.IO.Path.GetDirectoryName(strFileName));
                        Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(strFileName));
                        var genre = objFolder.GetDetailsOf(folderItem, 16);

                        if (year.ToString() == "" || Convert.ToInt16(year) == 0 || album == "" || genre.ToString() == "")
                        {
                            var fileshell = ShellFile.FromFilePath(strFileName);
                            ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();

                            try
                            {
                                var trackJSON = SingleEdit.MusixmatchGet(artist, title);

                                if (trackJSON.Item1 != null)
                                {
                                    try
                                    {
                                        string yearMM = "";//trackJSON.Item1.FirstReleaseDate.Year.ToString();
                                        if ((year.ToString() == "" || Convert.ToInt16(year) == 0) && yearMM != "" && Convert.ToInt16(yearMM) <= Convert.ToInt16(DateTime.Now.Year) && Convert.ToInt16(yearMM) > 1900)
                                        {
                                            propertyWriter.WriteProperty(SystemProperties.System.Media.Year, new int[] { Convert.ToInt16(yearMM) });
                                        }
                                    }
                                    catch
                                    {
                                        errorList += Environment.NewLine + "Year error in: " + file.Name;
                                    }
                                    try
                                    {
                                        string albumMM = trackJSON.Item1.AlbumName.ToString();
                                        if (album == "" && albumMM != "")
                                        {
                                            propertyWriter.WriteProperty(SystemProperties.System.Music.AlbumTitle, new string[] { albumMM });
                                        }
                                    }
                                    catch
                                    {
                                        errorList += Environment.NewLine + "Album error in: " + file.Name;
                                    }
                                    if (genre.ToString() == "")
                                    {
                                        try
                                        {
                                            string genreMM = trackJSON.Item1.PrimaryGenres.MusicGenreList[0].MusicGenre.MusicGenreName.ToString();
                                            if (genreMM.ToString() != "")
                                            {
                                                propertyWriter.WriteProperty(SystemProperties.System.Music.Genre, new string[] { genreMM });
                                            }
                                        }
                                        catch (IndexOutOfRangeException)
                                        {
                                            errorList += Environment.NewLine + "Genre error in: " + file.Name;
                                        }
                                    }
                                }
                                else if (trackJSON.Item2 == true)
                                {
                                    break;
                                }
                                else
                                {
                                    errorList += Environment.NewLine + file.Name;
                                }
                            }
                            finally
                            {
                                propertyWriter.Close();
                            }
                        }
                    }
                    progressBar1.Value = Convert.ToInt32(100 * (i + 1) / files.Length);

                    if (i == files.Length - 1)
                    {
                        progressBar1.Value = 100;
                    }
                }
                ErrorList errorForm = new ErrorList(errorList);
                errorForm.ShowDialog();
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("Files not found exception!", "Message");
            }
        }