示例#1
0
        public static void ratingDescending(Mp3_Container container)
        {
            container.gui.sortOptions.ratingDescending.Checked = true;

            container.gui.sortOptions.nameAscending.Checked    = false;
            container.gui.sortOptions.nameDescending.Checked   = false;
            container.gui.sortOptions.lengthAscending.Checked  = false;
            container.gui.sortOptions.lengthDescending.Checked = false;
            container.gui.sortOptions.artistAscending.Checked  = false;
            container.gui.sortOptions.artistDescending.Checked = false;
            container.gui.sortOptions.albumAscending.Checked   = false;
            container.gui.sortOptions.albumDescending.Checked  = false;
            container.gui.sortOptions.yearAscending.Checked    = false;
            container.gui.sortOptions.yearDescending.Checked   = false;
            container.gui.sortOptions.genreAscending.Checked   = false;
            container.gui.sortOptions.genreDescending.Checked  = false;
            container.gui.sortOptions.playsAscending.Checked   = false;
            container.gui.sortOptions.playsDescending.Checked  = false;
            container.gui.sortOptions.ratingAscending.Checked  = false;

            GuiControl.sort(container, "Rating");
        }
示例#2
0
        public static void createSong(Mp3_Container container, String file)
        {
            TagLib.File f = TagLib.File.Create(file);
            SongDetails song;

            if (f.Tag.Performers.Length == 0)
            {
                song = new SongDetails(f.Tag.Title, f.Tag.AlbumArtists[0], null,
                                       f.Tag.Album, f.Tag.Genres[0], f.Properties.Duration.ToString(),
                                       0, 0, file, f.Tag.Track.ToString(), f.Tag.Year.ToString());
            }
            else
            {
                song = new SongDetails(f.Tag.Title, f.Tag.AlbumArtists[0], f.Tag.
                                       Performers,
                                       f.Tag.Album, f.Tag.Genres[0], f.Properties.Duration.ToString(),
                                       0, 0, file, f.Tag.Track.ToString(), f.Tag.Year.ToString());
            }

            if (!Contains.xmlContainsSong(container, song))
            {
                container.gui.songList.Rows.Insert(0, 0, song.SongName, song.Length, song.Artist, song.Album, song.Track, song.Year, song.Genre, song.Plays, song.Rating, song.Path);
                container.songlists.masterSongList.Add(song);
                container.songlists.currentPlaylist.Add(song);

                XmlElement parent = container.xmlFile.xml.CreateElement("Song");

                XmlElement userElem = container.xmlFile.xml.CreateElement("name");
                XmlText    text     = container.xmlFile.xml.CreateTextNode(song.SongName);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("artist");
                text     = container.xmlFile.xml.CreateTextNode(song.Artist);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("album");
                text     = container.xmlFile.xml.CreateTextNode(song.Album);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("track");
                text     = container.xmlFile.xml.CreateTextNode(song.Track);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("year");
                text     = container.xmlFile.xml.CreateTextNode(song.Year);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("genre");
                text     = container.xmlFile.xml.CreateTextNode(song.Genre);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("length");
                text     = container.xmlFile.xml.CreateTextNode(song.Length);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("rating");
                text     = container.xmlFile.xml.CreateTextNode(song.Rating.ToString());
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("plays");
                text     = container.xmlFile.xml.CreateTextNode(song.Plays.ToString());
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                userElem = container.xmlFile.xml.CreateElement("path");
                text     = container.xmlFile.xml.CreateTextNode(song.Path);
                parent.AppendChild(userElem);
                parent.LastChild.AppendChild(text);

                container.xmlFile.xml.ChildNodes[1].ChildNodes[0].ChildNodes[0].AppendChild(parent);

                XmlTextWriter writer = new XmlTextWriter(container.xmlFile.userPath, null);
                writer.Formatting = Formatting.Indented;
                container.xmlFile.xml.Save(writer);
                writer.Close();
            }
            else
            {
                MessageBox.Show("The Song" + '\n' + file + '\n' + "has already been added", "Song has been added");
            }
            GuiControl.sort(container, container.trackers.lastSortParam);
        }
示例#3
0
        public static void search(Mp3_Container container, Tuple <String, int> field)
        {
            bool broke = false;
            List <DataGridViewRow> rows = new List <DataGridViewRow>();

            rows.Clear();

            foreach (SongDetails song in container.songlists.currentPlaylist)
            {
                String find = "";

                switch (field.Item1)
                {
                case "Song Name":
                    find = song.SongName;
                    break;

                case "Length":
                    find = song.Length;
                    break;

                case "Artist":
                    find = song.Artist;
                    break;

                case "Album":
                    find = song.Album;
                    break;

                case "Genre":
                    find = song.Genre;
                    break;

                case "Plays":
                    find = song.Plays.ToString();
                    break;

                case "Rating":
                    find = song.Rating.ToString();
                    break;

                case "Year":
                    find = song.Year.ToString();
                    break;
                }
                if (find.ToUpper().Contains(container.gui.searchTextBox.Text.ToUpper()))
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(container.gui.songList);
                    row.Cells[0].Value  = 0;
                    row.Cells[1].Value  = song.SongName;
                    row.Cells[2].Value  = song.Length;
                    row.Cells[3].Value  = song.Artist;
                    row.Cells[4].Value  = song.Album;
                    row.Cells[5].Value  = song.Track;
                    row.Cells[6].Value  = song.Year;
                    row.Cells[7].Value  = song.Genre;
                    row.Cells[8].Value  = song.Plays;
                    row.Cells[9].Value  = song.Rating;
                    row.Cells[10].Value = song.Path;
                    rows.Add(row);
                }
            }
            if (broke)
            {
                return;
            }
            else
            {
                container.gui.songList.Rows.Clear();
                container.gui.songList.Rows.InsertRange(0, rows.ToArray());
                GuiControl.sort(container, container.trackers.lastSortParam);
            }
        }