Exemplo n.º 1
0
        private void StackPanel_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e)
        {
            var songMenuFlyoutSubItem = new MenuFlyoutSubItem()
            {
                Text = "AddToPlayList"
            };

            var icon = new BitmapIcon()
            {
                UriSource = new Uri("ms-appx:///Assets/Images/songGeneral.png")
            };

            var playLists = PlayListManager.GetAllPlayLists();

            foreach (var playlist in playLists)
            {
                var playListMenuFlyoutItem = new MenuFlyoutItem()
                {
                    Text = playlist.Title
                };
                playListMenuFlyoutItem.Click += AddToPlaylistMenu_ItemClick;
                songMenuFlyoutSubItem.Items.Add(playListMenuFlyoutItem);
            }

            var addToPlaylistFlyout = new MenuFlyout();

            addToPlaylistFlyout.Items.Add(songMenuFlyoutSubItem);
            FrameworkElement senderElement = sender as FrameworkElement;

            addToPlaylistFlyout.ShowAt(sender as UIElement, e.GetPosition(sender as UIElement));
        }
Exemplo n.º 2
0
        public LuteBotForm()
        {
            InitializeComponent();

            onlineManager                             = new OnlineSyncManager();
            playList                                  = new PlayListManager();
            trackSelectionManager                     = new TrackSelectionManager();
            playList.PlayListUpdatedEvent            += new EventHandler <PlayListEventArgs>(HandlePlayListChanged);
            soundBoardManager                         = new SoundBoardManager();
            soundBoardManager.SoundBoardTrackRequest += new EventHandler <SoundBoardEventArgs>(HandleSoundBoardTrackRequest);
            player                                       = new MidiPlayer(trackSelectionManager);
            player.SongLoaded                           += new EventHandler <AsyncCompletedEventArgs>(PlayerLoadCompleted);
            hotkeyManager                                = new HotkeyManager();
            hotkeyManager.NextKeyPressed                += new EventHandler(NextButton_Click);
            hotkeyManager.PlayKeyPressed                += new EventHandler(PlayButton_Click);
            hotkeyManager.PreviousKeyPressed            += new EventHandler(PreviousButton_Click);
            trackSelectionManager.OutDeviceResetRequest += new EventHandler(ResetDevice);
            trackSelectionManager.ToggleTrackRequest    += new EventHandler <TrackItem>(ToggleTrack);

            PlayButton.Enabled       = false;
            StopButton.Enabled       = false;
            PreviousButton.Enabled   = false;
            NextButton.Enabled       = false;
            MusicProgressBar.Enabled = false;

            _hookID = SetHook(_proc);
            OpenDialogs();
            this.StartPosition = FormStartPosition.Manual;
            Point coords = WindowPositionUtils.CheckPosition(ConfigManager.GetCoordsProperty(PropertyItem.MainWindowPos));

            Top  = coords.Y;
            Left = coords.X;
        }
Exemplo n.º 3
0
        private static void ExportPlayList(string url, string fileName)
        {
            Console.WriteLine("* Playlist export");
            Console.WriteLine("url: {0}", url);
            Console.WriteLine("fileName: {0}", fileName);

            PlayListManager pl = new PlayListManager();

            Console.WriteLine("Playlist fetching ...");
            pl.Fetch(url);
            Console.WriteLine("Playlist fetched.");

            if (pl.PlayList.Count > 0)
            {
                string fn = fileName;

                if (string.IsNullOrEmpty(fn))
                {
                    fn = "playlist.txt";
                }

                Console.WriteLine("Playlist saving ...");
                pl.Save(fn, full);
                Console.WriteLine("Playlist saved.");
            }
            else
            {
                Console.WriteLine("Playlist does not contain video.");
            }
        }
Exemplo n.º 4
0
 private void MediaOpen()
 {
     InitWndSize();
     //this.Text = CommonHelper.SetPlayerTitle("Playing", CurrentVideoItem.Directory.FullName);
     PlayListManager.UpdateNowPlaying(CurrentVideoItem, false);
     playstate = 1;
 }
Exemplo n.º 5
0
 private void Next()
 {
     SavePlayed();
     if (PlayListManager.CanNext)
     {
         CurrentVideoItem          = PlayListManager.GetNextItem();
         axWindowsMediaPlayer1.URL = (CurrentVideoItem.Directory.FullName);
     }
 }
Exemplo n.º 6
0
 private void Previous()
 {
     SavePlayed();
     if (PlayListManager.CanPrevious)
     {
         CurrentVideoItem          = PlayListManager.GetPreviousItem();
         axWindowsMediaPlayer1.URL = (CurrentVideoItem.Directory.FullName);
     }
 }
Exemplo n.º 7
0
        public LuteBotForm()
        {
            InitializeComponent();

            onlineManager                             = new OnlineSyncManager();
            playList                                  = new PlayListManager();
            trackSelectionManager                     = new TrackSelectionManager();
            playList.PlayListUpdatedEvent            += new EventHandler <PlayListEventArgs>(HandlePlayListChanged);
            soundBoardManager                         = new SoundBoardManager();
            soundBoardManager.SoundBoardTrackRequest += new EventHandler <SoundBoardEventArgs>(HandleSoundBoardTrackRequest);
            player                                       = new MidiPlayer(trackSelectionManager);
            player.SongLoaded                           += new EventHandler <AsyncCompletedEventArgs>(PlayerLoadCompleted);
            hotkeyManager                                = new HotkeyManager();
            hotkeyManager.NextKeyPressed                += new EventHandler(NextButton_Click);
            hotkeyManager.PlayKeyPressed                += new EventHandler(PlayButton_Click);
            hotkeyManager.StopKeyPressed                += new EventHandler(StopButton_Click);
            hotkeyManager.SynchronizePressed            += HotkeyManager_SynchronizePressed;
            hotkeyManager.PreviousKeyPressed            += new EventHandler(PreviousButton_Click);
            trackSelectionManager.OutDeviceResetRequest += new EventHandler(ResetDevice);
            trackSelectionManager.ToggleTrackRequest    += new EventHandler <TrackItem>(ToggleTrack);
            liveMidiManager                              = new LiveMidiManager(trackSelectionManager);
            hotkeyManager.LiveInputManager               = liveMidiManager;

            PlayButton.Enabled       = false;
            StopButton.Enabled       = false;
            PreviousButton.Enabled   = false;
            NextButton.Enabled       = false;
            MusicProgressBar.Enabled = false;


            _hookID = SetHook(_proc);
            OpenDialogs();
            this.StartPosition = FormStartPosition.Manual;
            Point coords = WindowPositionUtils.CheckPosition(ConfigManager.GetCoordsProperty(PropertyItem.MainWindowPos));

            Top  = coords.Y;
            Left = coords.X;

            // We may package this with a guild library for now.  Check for it and extract it, if so
            var files = Directory.GetFiles(Environment.CurrentDirectory, "BGML*.zip", SearchOption.TopDirectoryOnly);

            if (files.Length > 0)
            {
                Task.Run(() =>
                {
                    // extract to libraryPath + "\songs\"
                    try
                    {
                        ZipFile.ExtractToDirectory(files[0], libraryPath + @"\songs\");
                        //File.Delete(files[0]);
                    }
                    catch (Exception e) { } // Gross I know, but no reason to do anything
                });
            }
        }
Exemplo n.º 8
0
        private void AddToPlaylistMenu_ItemClick(object sender, RoutedEventArgs e)
        {
            var flyoutItem = (MenuFlyoutItem)e.OriginalSource;

            // find playlist
            var playList = PlayListManager.GetPlayListByTitle(flyoutItem.Text);

            FrameworkElement senderElement = sender as FrameworkElement;
            var song = senderElement.DataContext as Song;

            playList.AddSong(song);
        }
Exemplo n.º 9
0
        public PlayListForm(PlayListManager playList)
        {
            InitializeComponent();
            this.playListManager = playList;
            this.playListManager.PlayListUpdatedEvent += new EventHandler <PlayListEventArgs>(PlayList_Updated);
            var lastPlayListPath = ConfigManager.GetProperty(PropertyItem.LastPlaylistLocation);

            if (lastPlayListPath != null && lastPlayListPath.Length > 0)
            {
                playListManager.LoadLastPlayList(lastPlayListPath);
            }
            RefreshPlayListBox();
        }
Exemplo n.º 10
0
        // When a playlist item is clicked
        private void PlayListMenuSidebarView_ItemClick(
            object sender, ItemClickEventArgs e)
        {
            var clickedPlayList = (PlayList)e.ClickedItem;


            // Populate the ObservableCollection<Song> displayingSongs with
            // the songs in the specified PlayList
            PlayListManager.GetSongsByPlayList(displayingSongs, clickedPlayList);

            // Show the playlist playback view set to the clicked playlist
            SwitchToContentView(ContentView.PlayListPlayBack);
        }
Exemplo n.º 11
0
        public Wmp_test()
        {
            InitializeComponent();
            axWindowsMediaPlayer1.uiMode           = "full";
            axWindowsMediaPlayer1.stretchToFit     = true;
            axWindowsMediaPlayer1.PlayStateChange +=
                new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(mediaElement1_PlayStateChange);

            axWindowsMediaPlayer1.MediaError += AxWindowsMediaPlayer1_MediaError;
            MediaPositionTimer          = new DispatcherTimer();
            MediaPositionTimer.Tick    += MediaPositionTimer_Tick;
            MediaPositionTimer.Interval = TimeSpan.FromMilliseconds(200);

            playListManager   = new PlayListManager();
            this.FormClosing += Wmp_test_FormClosing;
        }
Exemplo n.º 12
0
        // Which playlist is represented by these songs is not explicitly stored
        // Rather, handled entirely in the PlayListMenuSidebarView_ItemClick event handler

        public MainPage()
        {
            InitializeComponent();
            displayingPlayLists = new ObservableCollection <PlayList>();
            displayingSongs     = new ObservableCollection <Song>();

            PlayListManager.Setup();

            PlayListManager.GetAllPlayLists(displayingPlayLists);

            // Immediately enter playlist creation
            CreateNewPlayListHelper();

            //MediaPlayerElement mediaPlayerElement1 = new MediaPlayerElement();
            //mediaPlayerElement1.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Media/video1.mp4"));
            //mediaPlayerElement1.AutoPlay = true;
        }
Exemplo n.º 13
0
        private void SongSaveButton_Click(object sender, RoutedEventArgs e)
        {
            //Allow user to save name, artist, and genre
            string name     = SongTitle_UserInput.Text;
            string artist   = SongArtist_UserInput.Text;
            string genre    = Genre_UserInput.Text;
            string filepath = "test";

            //TODO Copy over filepath

            //Creates new song to add to all songs playlist
            var newSong = PlayListManager.AddNewSong(name, artist, genre);

            PlayListManager.GetAllSongs(displayingSongs);

            SwitchToContentView(ContentView.PlayListPlayBack);
        }
Exemplo n.º 14
0
        // When the app first loads and also
        // When the user clicks the new playlist button
        private void CreateNewPlayListHelper()
        {
            // Right now we're figuring out what default playlist name to offer to the user
            // Find the default playlist name with the biggest number N
            // Offer a name ending with the next number (N + 1)
            int?largestPlayListNumMatch = null;

            foreach (var playList in displayingPlayLists)
            {
                // If the playlist name matches the template text
                // and its number is the new largest match
                int?templateMatchNum = GetTemplateMatchNum(playList.Name, PLAYLIST_NAME_TEMPLATE);
                if (templateMatchNum.HasValue && templateMatchNum.Value > largestPlayListNumMatch.GetValueOrDefault())
                // 0 is the default for int if int? is null
                {
                    // Store the new largest match
                    largestPlayListNumMatch = templateMatchNum.Value;
                }
            }
            // Now either largestPlayListNumMatch is the number of the largest match or it is still null

            // If null, that means that there were no matches and we offer the starting default of 1
            // If not null, (rather, if N), then we offer N+1


            var playListNameNumToOffer = (largestPlayListNumMatch.HasValue ? largestPlayListNumMatch.Value + 1 : 1);

            StringBuilder playListNameToOfferSB = new StringBuilder(PLAYLIST_NAME_TEMPLATE);

            playListNameToOfferSB.Append(playListNameNumToOffer);



            // Write the default playlist offer into the user input text box

            PlayListName_UserInput.Text =
                playListNameToOfferSB.ToString();

            // Display all songs
            PlayListManager.GetAllSongs(displayingSongs);

            // Finally, show the PlayListCreationView
            SwitchToContentView(ContentView.PlayListCreation);
        }
Exemplo n.º 15
0
        private void FeaturesListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var Feature = (Feature)e.ClickedItem;

            if (Feature.Item == FeatureItems.Playlist)
            {
                ItemTextBlock.Text = "All Playlists";
                var allPlayLists = PlayListManager.GetAllPlayLists();
                PlayLists.Clear();
                allPlayLists.ForEach(pl => PlayLists.Add(pl));

                BackButton.Visibility       = Visibility.Visible;
                PlayListGridView.Margin     = new Thickness(20, 0, 0, 0);
                SongGridView.Visibility     = Visibility.Collapsed;
                PlayListGridView.Visibility = Visibility.Visible;
                ArtistsGridView.Visibility  = Visibility.Collapsed;
                AlbumsGridView.Visibility   = Visibility.Collapsed;
            }
            else
            {
                if (Feature.Item == FeatureItems.Artists)
                {
                    SongGridView.Visibility     = Visibility.Collapsed;
                    AlbumsGridView.Visibility   = Visibility.Collapsed;
                    ArtistsGridView.Visibility  = Visibility.Visible;
                    ItemTextBlock.Text          = "All Artists";
                    PlayListGridView.Visibility = Visibility.Collapsed;
                }
                else //Albums
                {
                    ItemTextBlock.Text          = Feature.Item.ToString();
                    BackButton.Visibility       = Visibility.Visible;
                    SongGridView.Visibility     = Visibility.Collapsed;
                    PlayListGridView.Visibility = Visibility.Collapsed;
                    ArtistsGridView.Visibility  = Visibility.Collapsed;
                    AlbumsGridView.Visibility   = Visibility.Visible;
                    ItemTextBlock.Text          = "All Albums";
                }
            }
        }
Exemplo n.º 16
0
        private void SaveNewPlayListHelper()
        {
            // TODO: Figure out why ShowMode is not working with Flyout, that is,
            // it is not showing up as a member of Flyout for some reason
            //((Button)sender).Flyout.ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway;

            // If the user has neglected to select any songs for their playlist
            if (PlayListSongSelectionEditView.SelectedItems.Count == 0)
            {
                // Show a flyout explaining why the playlist can't be saved
                FlyoutText_for_PlayListSaveButton.Text =
                    "Choose some songs first.";
                FlyoutBase.ShowAttachedFlyout(PlayListSaveButton);
                // See: "How to create a flyout"
                // https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/dialogs-and-flyouts/flyouts#how-to-create-a-flyout

                // ABORT saving the playlist
                // (Remain in PlayListCreationView, retaining the user input or
                // default offered playlist name)
                return;
            }



            // Ignore leading and trailing whtiespace from user input
            // Note that this is not just for comparison;
            // disallow leading and trailing whitespace from playlist names
            // because that is awkward, confusing and probably unintentional
            string newPlayListNameUserInput = PlayListName_UserInput.Text.Trim();


            // If user deleted the default playlist offer text, leaving the input empty
            if (newPlayListNameUserInput.Length == 0)
            {
                // Show a flyout explaining why the playlist can't be saved
                FlyoutText_for_PlayListName_UserInput.Text =
                    "Please set a name for your playlist.";
                FlyoutBase.ShowAttachedFlyout(PlayListName_UserInput);

                // ABORT saving the playlist
                // (Remain in PlayListCreationView, retaining any user-selected songs)
                return;
            }


            // Get a handle to the observable collection that we can use with a LINQ query
            bool playListNameAlreadyUsed = displayingPlayLists.ToList().Exists(
                playList => String.Equals(playList.Name, newPlayListNameUserInput));

            if (playListNameAlreadyUsed)
            {
                // Show a flyout explaining why the playlist can't be saved
                FlyoutText_for_PlayListName_UserInput.Text =
                    "Playlist name is already taken. Please use a new name.";
                FlyoutBase.ShowAttachedFlyout(PlayListName_UserInput);

                // ABORT saving the playlist
                // (Remain in PlayListCreationView, retaining any user-selected songs)
                return;
            }



            //IEnumerable<Type> symbol = TheCollection.Cast<Type>();
            // Optionally, if the IEnumberable<Type> doesn't do it for you:
            //var list = new List<Type>(symbol);
            // Converting observable collection back to regular collection
            // https://stackoverflow.com/a/1658656



            // Create an IEnumerable<Song> that we can pass to the PlayListManager
            // so that it can iterate through the list of selected songs
            IEnumerable <Song> selectedSongs =
                PlayListSongSelectionEditView.SelectedItems.Cast <Song>();
            // Following this example for how to use the Cast method on IEnumerable:
            // https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.cast?view=netframework-4.8
            // See also the ListViewBase.SelectedItems property:
            // https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.listviewbase.selecteditems



            // Pass the user input about the new playlist to the ViewModel
            // so the PlayList object to be created and stored/managed on the
            // back end
            // Store a reference to the new PlayList, we'll use it to
            // populate the playlist's songs into the view (avoiding doing
            // a lookup by playlist string name)
            var newPlaylist =
                PlayListManager.CreateNewPlayList(newPlayListNameUserInput, selectedSongs);

            // Re-populate the view's playlist collection
            // to reflect the new playlist
            PlayListManager.GetAllPlayLists(displayingPlayLists);

            // Prepare the view's songs collection to be the songs from the
            // new playlist
            PlayListManager.GetSongsByPlayList(displayingSongs, newPlaylist);

            // Switch to the songs view
            SwitchToContentView(ContentView.PlayListPlayBack);

            // Select/highlight the new playlist in the left sidebar view
            SelectPlayListInMenuSidebarView(newPlaylist);
        }