예제 #1
0
        private void HandleMostrarMusicaClick(object sender, RoutedEventArgs e)
        {
            object selected = lvSelecionadas.SelectedItem;

            if (selected != null)
            {
                SongListItem songListItem = selected as SongListItem;
                PlayingSong = PlayingSong.CreateInstance(songListItem.Song);
                dpPlayingSong.DataContext = PlayingSong;
                if (PresentationWindow == null)
                {
                    PresentationWindow = new PresentationWindow(PresentationController, ResourceConfiguration, StateConfiguration);
                    PresentationController.SetKeyEvents(PresentationWindow);
                    StateConfiguration.UpdatePresentationWindowPosition(Left, Top, ActualWidth, ActualHeight,
                                                                        PresentationWindow.Width, PresentationWindow.Height);
                    PresentationWindow.Left = StateConfiguration.PresentationWindowLeft;
                    PresentationWindow.Top  = StateConfiguration.PresentationWindowTop;
                    PresentationWindow.Show();
                }
                PresentationWindow.Visibility = Visibility.Visible;
                PresentationHidden            = false;
                HandlePresentationWindowButtons();
                PresentationController.ChangeSong(PlayingSong);
            }
        }
예제 #2
0
 public void GoToByKey(char key)
 {
     if (PlayingSong != null)
     {
         var index = PlayingSong.GetNextKeyIndex(key);
         if (index >= 0)
         {
             PlayingSong.SetCurrentSongItem(index);
             HandleZeroOnMove();
             SendEvent(PresentationEvents.NextKey, PlayingSong);
         }
     }
 }
예제 #3
0
        public void HandlePresentationEvent(PresentationEvents presentationEvent, params object[] arg)
        {
            PlayingSong pArg = null;

            if (arg != null && arg.Length > 0 && arg[0] is PlayingSong)
            {
                pArg = arg[0] as PlayingSong;
            }
            switch (presentationEvent)
            {
            case PresentationEvents.NewSong:
                PlayingSong = pArg;
                InitializePlayingVideo();
                break;

            case PresentationEvents.Stop:
                StopExecutingEverythingDueClosingEvent();
                Close();
                break;

            case PresentationEvents.ChangeBackgroundVideo:
                InitializePlayingVideo();
                break;
            }
            if (pArg != null)
            {
                if (!string.IsNullOrEmpty(pArg.CurrentSongItem.VerseTip))
                {
                    Settings.TipVisibility = Visibility.Visible;
                }
                else
                {
                    Settings.TipVisibility = Visibility.Collapsed;
                }
                if (pArg.IsZero)
                {
                    Settings.TitleVisibility  = Visibility.Visible;
                    Settings.SlidesVisibility = Visibility.Collapsed;
                }
                else
                {
                    Settings.TitleVisibility  = Visibility.Collapsed;
                    Settings.SlidesVisibility = Visibility.Visible;
                }
            }
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("PlayingSong"));
            }
        }
예제 #4
0
 public void GoToNext()
 {
     if (PlayingSong != null && PlayingSong.Song.Items != null)
     {
         var index  = PlayingSong.GetCurrentItemIndex();
         var offset = PlayingSong.IsZero ? 0 : 1;
         if (index + offset < PlayingSong.Song.Items.Count)
         {
             PlayingSong.CurrentSongItem = PlayingSong.Song.Items[index + offset];
         }
         HandleZeroOnMove();
         SendEvent(PresentationEvents.Next, PlayingSong);
     }
 }
예제 #5
0
 public void GoToPrevious()
 {
     if (PlayingSong != null && PlayingSong.Song != null && PlayingSong.Song.Items != null && !PlayingSong.IsZero)
     {
         var index  = PlayingSong.GetCurrentItemIndex();
         var offset = PlayingSong.IsZero ? 0 : 1;
         if (index - offset >= 0)
         {
             PlayingSong.CurrentSongItem = PlayingSong.Song.Items[index - offset];
             HandleZeroOnMove();
         }
         else
         {
             PlayingSong.IsZero = true;
         }
         SendEvent(PresentationEvents.Previous, PlayingSong);
     }
 }
예제 #6
0
        private static Flyout GenerateFlyOut(Song song, Album album, IEnumerable <Song> songs, IEnumerable <Album> albums, PlayingSong playListSong, IEnumerable <PlayingSong> playListSongs)
        {
            var stackPanel = new StackPanel();
            var flyout     = new Flyout();

            var textbox = new TextBox();

            stackPanel.Children.Add(textbox);

            var button = new Button()
            {
                Content = "Create Playlist"
            };

            button.Click += async(sender, e) =>
            {
                if (string.IsNullOrWhiteSpace(textbox.Text))
                {
                    return;
                }

                flyout.Hide();
                var playlist = await MusicStore.Instance.CreatePlaylist(textbox.Text.Trim());

                if (song != null)
                {
                    await MusicStore.Instance.AddPlaylistSong(playlist, song);
                }
                if (album != null)
                {
                    foreach (var s in album.Songs)
                    {
                        await MusicStore.Instance.AddPlaylistSong(playlist, s.Songs.First());
                    }
                }
                if (songs != null)
                {
                    foreach (var s in songs)
                    {
                        await MusicStore.Instance.AddPlaylistSong(playlist, song);
                    }
                }
                if (albums != null)
                {
                    foreach (var s in albums.SelectMany(x => x.Songs))
                    {
                        await MusicStore.Instance.AddPlaylistSong(playlist, s.Songs.First());
                    }
                }
                if (playListSong != null)
                {
                    await MusicStore.Instance.AddPlaylistSong(playlist, playListSong.Song);
                }
                if (playListSongs != null)
                {
                    foreach (var item in playListSongs.Select(x => x.Song))
                    {
                        await MusicStore.Instance.AddPlaylistSong(playlist, item);
                    }
                }
            };

            stackPanel.Children.Add(button);


            flyout.Content = stackPanel;
            return(flyout);
        }
예제 #7
0
        private static void UpdateEntys(IList <MenuFlyoutItemBase> items, Song song, Album album, IEnumerable <Song> songs, IEnumerable <Album> albums, bool supressCurrentPlaylist, PlayingSong playListSong, IEnumerable <PlayingSong> playListSongs)
        {
            if (!supressCurrentPlaylist)
            {
                var currentPlaying = new MenuFlyoutItem()
                {
                    Text = "Add To Now Playing"
                };

                currentPlaying.Click += async(sender, e) =>
                {
                    if (song != null)
                    {
                        await Viewmodels.MediaplayerViewmodel.Instance.AddSong(song);
                    }
                    if (songs != null)
                    {
                        foreach (var item in songs)
                        {
                            await Viewmodels.MediaplayerViewmodel.Instance.AddSong(song);
                        }
                    }
                    if (album != null)
                    {
                        foreach (var item in album.Songs)
                        {
                            await Viewmodels.MediaplayerViewmodel.Instance.AddSong(item.Songs.First());
                        }
                    }
                    if (albums != null)
                    {
                        foreach (var item in albums.SelectMany(x => x.Songs))
                        {
                            await Viewmodels.MediaplayerViewmodel.Instance.AddSong(item.Songs.First());
                        }
                    }
                    if (playListSong != null)
                    {
                        await Viewmodels.MediaplayerViewmodel.Instance.AddSong(playListSong.Song);
                    }
                    if (playListSongs != null)
                    {
                        foreach (var item in playListSongs.Select(x => x.Song))
                        {
                            await Viewmodels.MediaplayerViewmodel.Instance.AddSong(item);
                        }
                    }
                };

                items.Add(currentPlaying);
                items.Add(new MenuFlyoutSeparator());
            }


            var newPlaylist = new MenuFlyoutItem()
            {
                Text = "Create Playlist"
            };

            var flyOut = GenerateFlyOut(song, album, songs, albums, playListSong, playListSongs);

            newPlaylist.Click += (sender, e) =>
            {
                flyOut.ShowAt(App.Shell);
            };

            items.Add(newPlaylist);

            if (MusicStore.Instance.PlayLists?.Any() ?? false)
            {
                items.Add(new MenuFlyoutSeparator());
            }



            if (MusicStore.Instance.PlayLists != null)
            {
                foreach (var playList in MusicStore.Instance.PlayLists)
                {
                    var addToPlaylist = new MenuFlyoutItem()
                    {
                        Text = playList.Name
                    };

                    addToPlaylist.Click += async(sender, e) =>
                    {
                        if (song != null)
                        {
                            await MusicStore.Instance.AddPlaylistSong(playList, song);
                        }
                        if (album != null)
                        {
                            foreach (var s in album.Songs)
                            {
                                await MusicStore.Instance.AddPlaylistSong(playList, s.Songs.First());
                            }
                        }
                        if (songs != null)
                        {
                            foreach (var s in songs)
                            {
                                await MusicStore.Instance.AddPlaylistSong(playList, song);
                            }
                        }
                        if (albums != null)
                        {
                            foreach (var s in albums.SelectMany(x => x.Songs))
                            {
                                await MusicStore.Instance.AddPlaylistSong(playList, s.Songs.First());
                            }
                        }
                        if (playListSong != null)
                        {
                            await MusicStore.Instance.AddPlaylistSong(playList, playListSong.Song);
                        }
                        if (playListSongs != null)
                        {
                            foreach (var item in playListSongs.Select(x => x.Song))
                            {
                                await MusicStore.Instance.AddPlaylistSong(playList, item);
                            }
                        }
                    };

                    items.Add(addToPlaylist);
                }
            }
        }
예제 #8
0
 public void ChangeSong(PlayingSong playingSong)
 {
     PlayingSong = playingSong;
     SendEvent(PresentationEvents.NewSong, PlayingSong);
 }
예제 #9
0
 private void OnPlayingSongChanged()
 {
     PlayingSong.LoadAlbum();
 }