Пример #1
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            var      list1        = mainList.PlayList;
            ListPlay selectedItem = (ListPlay)Playlist.SelectedItem;

            mainList.PlayList.Remove(selectedItem);

            try
            {
                Playlist.SelectAll();
            }
            catch { MessageBox.Show("Vse je izbrisano"); }
        }
Пример #2
0
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            int            dolzina1 = Playlist.Items.Count;
            OpenFileDialog open     = new OpenFileDialog();

            open.Filter      = " Supported| *.mp3; *.asf; *.wma; *.wmv; *.wm; *.asx; *.wax; *.wvx; *.wmx; wpl; *.avi; *.mpg; *.mpeg; *.m1v; *.mp2; *.mp3; *.mpa; *.mpe; *.m3u; *.mid; *.midi; *.rmi; *.wav; *.m4a; *.mp4; *.m4v; *.mp4v; *.3g2; *.3gp2; *.3gp; *.3gpp; *.m4a; *.aac; *.adt; *.adts";
            open.Multiselect = true;
            if (open.ShowDialog() == true)
            {
                ObservableCollection <ListPlay> listPlay = new ObservableCollection <ListPlay>();
                int dolzina = Playlist.Items.Count;
                for (int i = 0; i < dolzina - dolzina1; i++)
                {
                    var      selectedItem = (dynamic)Playlist.Items[i];
                    string   item         = selectedItem.Lokacija;
                    ListPlay lp           = new ListPlay();

                    lp.Lokacija       = item;
                    lp.DatumSpremenbe = File.GetLastWriteTime(item).ToString();

                    double len = new FileInfo(item).Length;
                    while (len >= 1024)
                    {
                        len = len / 1024;
                    }
                    string result = String.Format(" {0:0.##} {1}", len, "MB");
                    lp.Velikost = result;

                    var file = TagLib.File.Create(item);
                    lp.Leto = file.Tag.Year.ToString();

                    lp.Naslov = System.IO.Path.GetFileNameWithoutExtension(item);
                    lp.Zvrst  = file.Tag.FirstGenre;


                    double minute  = file.Properties.Duration.Minutes;
                    double sekunde = file.Properties.Duration.Seconds;
                    if (sekunde < 10)
                    {
                        lp.Trajanje = minute.ToString() + ":0" + sekunde;
                    }
                    else
                    {
                        lp.Trajanje = minute.ToString() + ":" + sekunde;
                    }
                    listPlay.Add(lp);

                    //nov list
                    mainList.PlayList.Add(lp);
                }

                try
                {
                    foreach (String file in open.FileNames)
                    {
                        string   path = file.ToString();
                        ListPlay lp   = new ListPlay();

                        lp.Lokacija       = path;
                        lp.DatumSpremenbe = File.GetLastWriteTime(path).ToString();

                        double len = new FileInfo(path).Length;
                        while (len >= 1024)
                        {
                            len = len / 1024;
                        }
                        string result = String.Format(" {0:0.##} {1}", len, "MB");
                        lp.Velikost = result;

                        var file2 = TagLib.File.Create(path);
                        lp.Leto = file2.Tag.Year.ToString();

                        lp.Naslov = System.IO.Path.GetFileNameWithoutExtension(path);
                        lp.Zvrst  = file2.Tag.FirstGenre;


                        double minute  = file2.Properties.Duration.Minutes;
                        double sekunde = file2.Properties.Duration.Seconds;
                        if (sekunde < 10)
                        {
                            lp.Trajanje = minute.ToString() + ":0" + sekunde;
                        }
                        else
                        {
                            lp.Trajanje = minute.ToString() + ":" + sekunde;
                        }

                        //listPlay.Add(lp);
                        this.mainList.PlayList.Add(lp);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Loading Eror.\n");
                }
                listsPlays = listPlay;
            }
        }