예제 #1
0
        /// <summary>
        /// Inserts an IEnumerable of Song objects randomly into SongList
        /// </summary>
        /// <param name="songsToAdd">The songs to insert randomly</param>
        public void ShuffleSongsInto(IEnumerable <Song> songsToAdd)
        {
            Random r = new Random();

            foreach (Song s in songsToAdd)
            {
                SongList.Insert(r.Next(songsToAdd.Count()), s);
            }
        }
예제 #2
0
        private void Button_DownSong_Click(object sender, EventArgs e)
        {
            if (SongList.Count <= 1 || ListView_Songs.SelectedItems.Count < 1 || ListView_Songs.SelectedItems[0].Index + 1 > ListView_Songs.Items.Count - 1)
            {
                return;
            }
            var index = ListView_Songs.SelectedItems[0].Index;
            var work  = SongList[index];

            SongList.RemoveAt(index);
            SongList.Insert(index + 1, work);
            SetCoursesFromList();
        }
예제 #3
0
        private async Task <bool> InsertMusicItemAsync(MHzSongBase song, int index = -1)
        {
            var find_index = SongList.ToList().FindIndex(i => i.SHA256 == song.SHA256);

            if (find_index != -1)
            {
                currentInsert = find_index;
                return(true);
            }
            var item = await MusicServiceHelper.CreatePlayItemAsync(song);

            var retuenIndex = InsertMusicItem(item, index);

            SongList.Insert(retuenIndex, song);
            RaisePropertyChanged("SongList");
            return(retuenIndex == -1 ? false : true);
        }
예제 #4
0
        public static List<songinstance> load()
        {
            string fileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
            fileName = Path.GetDirectoryName(fileName);
            fileName = Path.Combine(fileName, SAVEFILE);
            List<songinstance> returnlist = new List<songinstance>();
            try
            {
                TextReader tr = new StreamReader(fileName);
                string line;
                string value;
                while ((line = tr.ReadLine()) != null)
                {

//#if VERBOSE
//                    MessageBox.Show("csv loader: "+ line);
//#endif
                    songinstance si = new songinstance();

                    value = line.Substring(0, line.IndexOf(","));
                    line = line.Substring(line.IndexOf(",") + 1);
                    si.setwaveurl(value);

                    value = line.Substring(0, line.IndexOf(","));
                    line = line.Substring(line.IndexOf(",") + 1);
                    si.setdatetime(value);

                    value = line.Substring(0, line.IndexOf(","));
                    line = line.Substring(line.IndexOf(",") + 1);
                    si.setfingerprint(value); //this will not handle error.

                    SongList sl = new SongList();
                    int cindex;
                    while ((cindex = line.IndexOf(",")) != -1) //-1?
                    {
//#if VERBOSE
//                        MessageBox.Show(line);
//#endif                       
                        
                        Song s = new Song();
                        value = line.Substring(0, line.IndexOf(","));
                        line = line.Substring(line.IndexOf(",")+1);
                        s.artist = value;
                        value = line.Substring(0, line.IndexOf(","));
                        line = line.Substring(line.IndexOf(",") + 1);
                        s.title = value;
                        value = line.Substring(0, line.IndexOf(","));
//#if VERBOSE
//                        MessageBox.Show(line);
//#endif
                        line = line.Substring(line.IndexOf(",") + 1);
                        s.match = Int32.Parse(value);
//#if VERBOSE
//                        MessageBox.Show("csv adding match");
//#endif

                        //sl.Add(s); //add doesnt work.
                        sl.Insert(0, s);
                    } //this will not handle error. and is untested.
                    si.setmatches(sl);
#if VERBOSE
                    MessageBox.Show("csv matches count :"+sl.Count.ToString());
#endif

                    returnlist.Add(si);
                   
                }
#if VERBOSE
                MessageBox.Show("csv loader: list<instance>.lengith " + returnlist.Count.ToString());
#endif
                return returnlist;
            }
            catch (FileNotFoundException) { return returnlist; }//returnlist is empty, that should be fine.
            catch (IOException)
            {
                System.Windows.Forms.MessageBox.Show("IOException, this is odd.");
                return returnlist;
            }
        }