Ejemplo n.º 1
0
        public void AddSong(Model.Song song)
        {
            var songViewModel = songFactory();

            songViewModel.Song = song;
            AddItem(songViewModel);
        }
Ejemplo n.º 2
0
 //更新歌曲信息
 public void UpdateSong(int id, string _name, string _singer, string _path)
 {
     //this.selectedItem.id = id;
     this.selectedItem.name   = _name;
     this.selectedItem.singer = _singer;
     this.selectedItem.path   = _path;
     this.selectedItem        = null;
 }
Ejemplo n.º 3
0
 //更新歌曲信息
 public void UpdateSong(int id, string _name, string _singer, string _path)
 {
     //this.selectedItem.id = id;
     this.selectedItem.Title  = _name;
     this.selectedItem.Artist = _singer;
     this.selectedItem.Path   = _path;
     this.selectedItem        = null;
 }
        /// <summary>
        /// Appends a song to the end of a txt file in local storage storing all
        /// songs in the collection
        /// </summary>
        /// <param name="song">the song you want to save</param>
        public static async void addSong(Model.Song song)
        {
            var             songFile        = song.sourceSongFile;
            var             localFolder     = Windows.Storage.ApplicationData.Current.LocalFolder;
            MusicProperties musicProperties = await songFile.Properties.GetMusicPropertiesAsync();

            try
            {
                if (musicProperties.Title == null || musicProperties.Title == "")
                {
                    throw new ArgumentException("Cannot add music file without Title");
                }


                try
                {
                    Windows.Storage.StorageFile existingFile = await localFolder.GetFileAsync(songFile.Name);
                }
                catch (FileNotFoundException ex)
                {
                    await songFile.CopyAsync(localFolder);
                }

                //add song id and title and artist
                song.Title = musicProperties.Title;
                if (musicProperties.Artist == null || musicProperties.Artist == "")
                {
                    song.Artist = "Unknown";
                }
                else
                {
                    song.Artist = musicProperties.Artist;
                }

                if (musicProperties.Album == null || musicProperties.Album == "")
                {
                    song.Album = "Unknown";
                }
                else
                {
                    song.Album = musicProperties.Album;
                }

                song.ID = ++lastSongID;
                PlayListFileHelper.WriteSongToFileAsync(song);
            }
            catch (ArgumentException ex)
            {
                var messageDialog = new MessageDialog(ex.Message);
                // Show the message dialog
                await messageDialog.ShowAsync();

                return;
            }
        }
Ejemplo n.º 5
0
        private void ContentDialog_AddButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            foreach (StorageFile songFile in pickedFileList)
            {
                var song = new Model.Song
                {
                    sourceSongFile = songFile,
                };

                MainViewModel.addSong(song);
            }
        }
Ejemplo n.º 6
0
        public List <Model.Artist> Translate(Json.Music music)
        {
            var result = new List <Model.Artist>();

            if (music == null || music.Artists == null || !music.Artists.Any())
            {
                return(result);
            }

            foreach (var artistJson in music.Artists.OrderBy(i => i.Name))
            {
                var artist = new Model.Artist {
                    Name = artistJson.Name
                };

                foreach (var albumJason in artistJson.Albums.OrderBy(i => i.Date))
                {
                    var album = new Model.Album
                    {
                        Title       = albumJason.Title,
                        Description = albumJason.Description,
                        Image       = albumJason.Image,
                        Date        = DateTime.Parse(albumJason.Date),
                    };

                    foreach (var songJason in albumJason.Songs)
                    {
                        var song = new Model.Song
                        {
                            Title    = songJason.Title,
                            Length   = songJason.Length,
                            Favorite = songJason.Favorite,
                        };

                        album.Songs.Add(song);
                    }

                    artist.Albums.Add(album);
                }

                result.Add(artist);
            }

            return(result);
        }
Ejemplo n.º 7
0
 private void AddSong(Model.Song song, string path)
 {
     song.Path = GetDirectoryName(path);
     directoriesService.AddSong(song);
 }
Ejemplo n.º 8
0
 //删除歌曲
 public void RemoveSong()
 {
     this.allItems.Remove(this.selectedItem);
     this.selectedItem = null;
 }