Exemple #1
0
        public EditPlaylistWindow(MyData a, String name, List <string> list, String sourcePlaylist)
        {
            InitializeComponent();
            this.Name.Text = name.Remove(name.Length - 4);
            playlistListBox.ItemsSource = a.GetSongs();
            mediaFolder = sourcePlaylist;

            for (int i = 0; i < playlistListBox.Items.Count; i++)
            {
                Song song = playlistListBox.Items.GetItemAt(i) as Song;
                for (int s = 0; s < list.Count; s++)
                {
                    if (song.SecondPath.Equals(list.ElementAt(s)))
                    {
                        playlistListBox.SelectedItems.Add(playlistListBox.Items[i]);
                        s = list.Count;
                    }
                }
            }
        }
Exemple #2
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;
        }
Exemple #3
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();
        }
Exemple #4
0
 public AddPlaylistWindow(MyData a, String zrodloPlaylisty)
 {
     InitializeComponent();
     playlistListBox.ItemsSource = a.GetSongs();
     mediaFolder = zrodloPlaylisty;
 }