예제 #1
0
 // TODO Voisi miettiä viitteillä toteuttamista myös
 // Parse tracks from string array
 private List<Track> ParseTracks(List<string> strings)
 {
     if (strings != null)
     {
         List<Track> tracks = new List<Track>();
         Track newtrack = new Track();
         foreach (string item in strings)
         {
             if (item.StartsWith("file:"))
                 newtrack.File = item.Substring(item.IndexOf(":") + 2, item.Length - (item.IndexOf(":") + 2));
             else if (item.StartsWith("Artist:"))
                 newtrack.Artist = item.Substring(item.IndexOf(":") + 2, item.Length - (item.IndexOf(":") + 2));
             else if (item.StartsWith("Title:"))
                 newtrack.Title = item.Substring(item.IndexOf(":") + 2, item.Length - (item.IndexOf(":") + 2));
             else if (item.StartsWith("Album:"))
                 newtrack.Album = item.Substring(item.IndexOf(":") + 2, item.Length - (item.IndexOf(":") + 2));
             else if (item.StartsWith("Id:"))
             {
                 newtrack.ID = item.Substring(item.IndexOf(":") + 2, item.Length - (item.IndexOf(":") + 2));
                 tracks.Add(newtrack);
                 newtrack = new Track();
             }
             else if (item.StartsWith("Time:"))
             {
                 int number = 0;
                 Int32.TryParse(item.Substring(item.IndexOf(":") + 2, item.Length - (item.IndexOf(":") + 2)), out number);
                 newtrack.Length = number;
             }
         }
         return tracks;
     }
     return null;
 }
예제 #2
0
 // Set playcontrol page's info texts
 private void SetInfo(Track track)
 {
     textBlockSong.Text = track.Title;
     textBlockArtist.Text = track.Artist;
     textBlockAlbum.Text = track.Album;
 }
예제 #3
0
 internal void AddSong(Track track)
 {
     foreach (Album album in albums)
     {
         if (album.Title.Equals(track.Album))
         {
             album.Tracks.Add(track);
             return;
         }
     }
     Album newalbum = new Album() { Title = track.Album };
     newalbum.Tracks.Add(track);
     albums.Add(newalbum);
 }