Exemplo n.º 1
0
        public void SelectAlbum(object sender, SelectionChangedEventArgs e)
        {
            var listbox = sender as ListBox;
            // Взимаме grid който показва страницата от MainWindow.
            var grid = ((MainWindow)Application.Current.MainWindow).GridPrincipal;

            grid.Children.Clear();
            // Активираме ABP с избрания албум от листа.
            MainViewModel.ActivateABP(MainViewModel.Collection.Albums[listbox.SelectedIndex]);
            grid.Children.Add(new ABPContent());
        }
Exemplo n.º 2
0
        public void TestMethod_MainViewModel()
        {
            var collection       = MainViewModel.Collection;
            var mediaPlayer      = MediaViewModel.Player;
            var mySongsNotify    = MainViewModel.MySongs;
            var nowPlayingNotify = MainViewModel.NowPlaying;
            var playlistNotify   = MainViewModel.PlayList;
            var abpNotify        = MainViewModel.ABP;
            var songStatus       = MediaViewModel.Status;
            var volumeState      = MediaViewModel.Volume;
            var theme            = MainViewModel.Theme;


            MediaViewModel.Status = Rozabto.Model.SongStatus.Paused;
            MediaViewModel.Volume = Rozabto.Model.VolumeState.High;
            MainViewModel.Theme   = false;

            Assert.AreEqual(MainViewModel.PlayList.PlayList.Count, MainViewModel.PlayList.PlayList.Count);
            MainViewModel.ActivateABP(new Band("test"));
            MainViewModel.ActivateABP(new Album("test"));
            MainViewModel.ActivateABP(new PlayList("test", new System.Collections.Generic.List <Song> {
                new Song {
                    Duration = TimeSpan.FromSeconds(120)
                }
            }));
            MainViewModel.AddPlayList("Test");
            MainViewModel.AddSongsToPlayList("Test", new Song[] { Song.EmptySong });
            MainViewModel.RefreshDataBase();
            MediaViewModel.Play();
            MediaViewModel.Status = Rozabto.Model.SongStatus.Playing;
            MediaViewModel.Play();
            MediaViewModel.Status = Rozabto.Model.SongStatus.Stopped;
            MediaViewModel.Play();
            Assert.AreEqual(MainViewModel.NowPlaying.Songs.Count, MainViewModel.NowPlaying.Songs.Count);
            var songband       = MainViewModel.NowPlaying.SongBand;
            var pausebutton    = MainViewModel.NowPlaying.PauseButton;
            var mutebutton     = MainViewModel.NowPlaying.MuteButton;
            var repeatsong     = MainViewModel.NowPlaying.RepeatSong;
            var shuflesong     = MainViewModel.NowPlaying.ShuffleSongs;
            var currentsongpos = MainViewModel.NowPlaying.CurrentSongPos;

            MainViewModel.NowPlaying.RepeatSong     = false;
            MainViewModel.NowPlaying.ShuffleSongs   = false;
            MainViewModel.NowPlaying.CurrentSongPos = 9;

            Assert.AreEqual(MainViewModel.MySongs.Albums.Count, MainViewModel.MySongs.Albums.Count);
            Assert.AreEqual(MainViewModel.MySongs.Bands.Count, MainViewModel.MySongs.Bands.Count);
            Assert.AreEqual(MainViewModel.MySongs.Songs.Count, MainViewModel.MySongs.Songs.Count);

            var totalTime  = MainViewModel.ABP.TotalTime;
            var name       = MainViewModel.ABP.Name;
            var songscount = MainViewModel.ABP.SongsCount;
            var songs      = MainViewModel.ABP.Songs;

            var context = new BlogDBContext();

            var factory = new MusicInformation();

            foreach (var song in Directory.EnumerateFiles(@"D:\song"))
            {
                factory.SearchMusic(song).Wait();
            }

            MainViewModel.RemoveSong("My Heart", true);
            MainViewModel.RemoveAlbum(context.Albums.First().Name);
            MainViewModel.RemoveBand(context.Bands.First().Name);

            MainViewModel.RemoveSongFromPlayList("Test");
        }