Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            musicPlayer = new MediaPlayer();

            try
            {
                musicLibrary = new MusicLib();
            }
            catch(Exception e)
            {
                MessageBox.Show("Songs could not be uploaded.");
            }

            musicLibrary.AddPlaylist("All Music");

            foreach (string s in musicLibrary.SongIds)
            {
                musicLibrary.AddSongToPlaylist(Int32.Parse(s), "All Music");
            }

            playlistListBox.ItemsSource = musicLibrary.Playlists;

            musicDataGrid.ItemsSource = musicLibrary.Songs.DefaultView;
        }
Пример #2
0
        private void playListBox_Drop(object sender, DragEventArgs e)
        {
            TextBlock tb           = e.Source as TextBlock;
            string    playListName = tb.Text;
            string    dataString   = (string)e.Data.GetData(DataFormats.StringFormat);
            int       songId       = Convert.ToInt32(dataString);

            //Add this song to current selected playlist
            musicLibrary.AddSongToPlaylist(songId, playListName);
        }
Пример #3
0
        private void PlaylistListBox_DragOver(object sender, DragEventArgs e)
        {
            Label playlist = sender as Label;

            if (playlist != null)
            {
                Song s = (Song)e.Data.GetData(e.Data.GetFormats()[0]);
                musicLib.AddSongToPlaylist(s.Id, playlist.Content.ToString());

                Playlist_Selected(playlistListBox, null);
            }
        }
Пример #4
0
        private void playlist_Drop(object sender, DragEventArgs e)
        {
            string playlistName = ((ListBoxItem)sender).Content.ToString();

            if (e.Data.GetDataPresent(typeof(List <int>)))
            {
                List <int> songIds = (List <int>)e.Data.GetData(typeof(List <int>));
                foreach (var id in songIds)
                {
                    musicLib.AddSongToPlaylist(playlistName, id);
                }
                musicLib.Save();
            }
        }
Пример #5
0
        private void TextBlock_Drop(object sender, DragEventArgs e)
        {
            // Initiate dragging the text from the textbox
            string songId = "";

            foreach (DataGridCellInfo data in dataGrid.SelectedCells)
            {
                DataRowView dvr = (DataRowView)data.Item;
                songId = (dvr[0].ToString());
            }

            TextBlock txtblock     = (TextBlock)sender;
            string    playlistName = txtblock.Text;
            int       song         = Int32.Parse(songId);

            musicLib.AddSongToPlaylist(song, playlistName);
        }