Ejemplo n.º 1
0
 public AddPlaylistWindow(MyData a, String zrodloPlaylisty)
 {
     InitializeComponent();
     playlistListBox.ItemsSource = a.GetSongs();
     mediaFolder = zrodloPlaylisty;
 }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        public ArtistAlbumsWindow(string Artist, MyData albumy)
        {
            InitializeComponent();

            albumList.ItemsSource = albumy.GetArtistAlbum(Artist);
        }