コード例 #1
0
        private void NewPlaylist_Click(object sender, RoutedEventArgs e)
        {
            AddPlaylistWindow dlg = new AddPlaylistWindow(allCollections, mediaFolder);

            if (dlg.ShowDialog() == true)
            {
                playlistCollection          = new MyData(mediaFolder);
                playlistListBox.ItemsSource = playlistCollection.GetPlaylists();
            }
        }
コード例 #2
0
        private void EditPlaylist_Click(object sender, RoutedEventArgs e)
        {
            List <String> newPlaylist = new List <String>();

            if (playlistListBox.SelectedIndex != -1)
            {
                Song selectedSong = playlistListBox.Items.GetItemAt(playlistListBox.SelectedIndex) as Song;


                int nk = 0;
                try
                {
                    using (var fileStream = new FileStream(mediaFolder + "//Playlist//" + selectedSong.Title + ".txt", FileMode.Open))
                    {
                        StreamReader reader = new StreamReader(fileStream);

                        String line;

                        while ((line = reader.ReadLine()) != null)
                        {
                            if (nk == 1)
                            {
                                newPlaylist.Add(line);
                            }
                            if (nk < 3)
                            {
                                nk++;
                            }
                            if (nk == 3)
                            {
                                nk = 0;
                            }
                        }
                        reader.Close();
                    }



                    EditPlaylistWindow dlg = new EditPlaylistWindow(allCollections, selectedSong.Title + ".txt", newPlaylist, mediaFolder);
                    if (dlg.ShowDialog() == true)
                    {
                        playlistCollection          = new MyData(mediaFolder);
                        playlistListBox.ItemsSource = playlistCollection.GetPlaylists();
                    }
                }

                catch (System.UnauthorizedAccessException)
                {
                }
            }
        }
コード例 #3
0
        private void RemovePlaylist_Click(object sender, RoutedEventArgs e)
        {
            if (playlistListBox.SelectedIndex != -1)
            {
                Song song = playlistListBox.Items.GetItemAt(playlistListBox.SelectedIndex) as Song;

                try
                {
                    File.Delete(mediaFolder + "//Playlist//" + song.Title + ".txt");
                    playlistCollection          = new MyData(mediaFolder);
                    playlistListBox.ItemsSource = playlistCollection.GetPlaylists();
                }
                catch (IOException iox)
                {
                    Console.WriteLine(iox.Message);
                }
            }
        }
コード例 #4
0
        public CollectionMusicWindow(String path)
        {
            InitializeComponent();
            selected    = false;
            mediaFolder = path;

            Utility.CheckExistDirectories(path);
            Utility.LoadingMp3(path, pathList, songList);
            Utility.LoadingImages(path + "//Okladki", albumImageList, nameAlbumImageList);
            Utility.LoadingImages(path + "//ZdjeciaArtysty", artistImageList, nameArtistImageList);

            allCollections                = new MyData(songList, pathList, albumImageList, artistImageList, nameAlbumImageList, nameArtistImageList);
            albumCollection               = new MyData(songList, pathList, albumImageList, nameAlbumImageList);
            playlistCollection            = new MyData(mediaFolder);
            albumListBox.ItemsSource      = allCollections.GetAlbums();
            artistListListBox.ItemsSource = allCollections.GetArtists();
            playlistListBox.ItemsSource   = playlistCollection.GetPlaylists();
            allSongsListBox.ItemsSource   = allCollections.GetSongs();
            wyborWykonawcy.ItemsSource    = allCollections.GetArtists();
            grupowanie.SelectedIndex      = 0;
            grupowanie2.SelectedIndex     = 0;
        }
コード例 #5
0
        public void changeAlbumImage(Image AlbumPoster)
        {
            Album album = albumListBox.Items.GetItemAt(albumListBox.SelectedIndex) as Album;

            album.AlbumImage = AlbumPoster.Source;

            BitmapSource bitmapSource = AlbumPoster.Source as BitmapSource;
            String       content      = mediaFolder + "//Okladki//";
            String       path         = album.Name;

            path = path.Remove(path.Length - 2);
            String           fileType = ".png";
            String           allPath  = content + path + fileType;
            MessageBoxResult e        = MessageBox.Show(allPath);

            try
            {
                using (var fileStream = new FileStream(allPath, FileMode.Create))
                {
                    BitmapEncoder encoder = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(bitmapSource));

                    encoder.Save(fileStream);
                }
            }
            catch (System.UnauthorizedAccessException)
            {
            }
            if (playlistListBox.Items.Count > 0)
            {
                for (int i = 0; i < playlistListBox.Items.Count; i++)
                {
                    List <String> newList   = new List <String>();
                    List <String> songsList = new List <String>();

                    Song selectedSong = playlistListBox.Items.GetItemAt(i) as Song;


                    int nk = 0;
                    try
                    {
                        using (var fileStream = new FileStream(mediaFolder + "//Playlist//" + selectedSong.Title + ".txt", FileMode.Open))
                        {
                            StreamReader reader = new StreamReader(fileStream);

                            String line;

                            while ((line = reader.ReadLine()) != null)
                            {
                                if (nk == 1)
                                {
                                    songsList.Add(line);
                                }
                                if (nk < 3)
                                {
                                    nk++;
                                }
                                if (nk == 3)
                                {
                                    nk = 0;
                                }
                            }
                            newList = songsList;
                            reader.Close();
                        }


                        EditPlaylistWindow dlg = new EditPlaylistWindow(allCollections, selectedSong.Title, newList, mediaFolder);


                        dlg.UpdatePlaylist();
                        playlistCollection          = new MyData(mediaFolder);
                        playlistListBox.ItemsSource = playlistCollection.GetPlaylists();
                    }

                    catch (System.UnauthorizedAccessException)
                    {
                    }
                }
            }
            DirectoryInfo dir = new DirectoryInfo(mediaFolder + "//Okladki");

            foreach (FileInfo file in dir.GetFiles("*.*", SearchOption.AllDirectories))
            {
                if (file.Extension == ".png")
                {
                    Image n = new Image();
                    n.Source = new BitmapImage(new Uri(file.DirectoryName + "//" + file.Name));

                    albumImageList.Add(n);
                    nameAlbumImageList.Add(file.Name);
                }
            }
            albumCollection             = new MyData(songList, pathList, albumImageList, nameAlbumImageList);
            allSongsListBox.ItemsSource = allCollections.GetSongs();
        }