示例#1
0
        /// <summary>
        /// Event handler for individual miniGrid (holding 1-4 sounds) in mastergrid
        /// </summary>
        void OnMiniGridTapped(MiniGrid miniGrid)
        {
            Instrument selectedInstrument = selectedInstrButton.Instrument;

            // Changes UI represenation and returns new set of colors on this grid
            bool added = miniGrid.ToggleColor(selectedInstrument.color);

            // If sidebar color isn't part of button's new set of colors, remove it
            Instrument.Note toggledNote = selectedInstrument.AtPitch(miniGrid.semitoneShift);

            //If sidebar button color = clicked button color
            if (added)
            {
                song.AddNote(toggledNote, Grid.GetColumn(miniGrid));        // Add the note

                if (!player.IsPlaying)
                {
                    SingleNotePlayer.PlayNote(selectedInstrument.AtPitch(miniGrid.semitoneShift));   // Play note so long as not already playing a song
                }
            }
            else
            {
                song.RemoveNote(toggledNote, Grid.GetColumn(miniGrid));
            }

            //Undo clear stops woking when user adds stuff to grid so they don't accidentally undo clear
            clearedSong       = null;
            loadedSongChanged = true;  // If song is empty, no need to worry about changes, otherwise
        }
示例#2
0
        /// <summary>
        /// Event handler for the more options button. Sends user to more options page.
        /// </summary>
        async void OnMoreOptionsClicked(object sender, EventArgs e)
        {
            if (player.IsPlaying)
            {
                StopPlayingSong();
            }
            SingleNotePlayer.StopPlayingNote();

            await Navigation.PushAsync(new MoreOptionsPage(this));
        }
示例#3
0
        /// <summary>
        /// Event handler for buttons in the sidebar
        /// </summary>
        void OnSidebarClicked(object sender, EventArgs e)
        {
            InstrumentButton button = (InstrumentButton)sender;

            if (!player.IsPlaying)  // So long as the music isn't currently playing, the sidebar buttons play their sound when clicked
            {
                SingleNotePlayer.PlayNote(button.Instrument.AtPitch(0));
            }
            if (button != selectedInstrButton)
            {
                SetSelectedSidebarButton(button);
            }
        }
示例#4
0
 /// <summary>
 /// Starts playing the song
 /// </summary>
 private void StartPlayingSong()
 {
     stepgrid.Children.Add(highlights[0], 0, 0);
     Grid.SetRowSpan(highlights[0], highlight2StartRow);
     stepgrid.Children.Add(highlights[1], 0, highlight2StartRow);
     Grid.SetRowSpan(highlights[1], NumRows - highlight2StartRow);
     player.BeginPlaying(song);
     //We call this after BeginPlaying because we know no more notes will try to play.
     //If we did it before, the user could theoretically start a note playing in between StopPlayingNote and BeginPlaying and it
     //wouldn't be stopped
     SingleNotePlayer.StopPlayingNote();
     playStopButton.Image = stopImageName;
 }
        /// <summary>
        /// Event handler for instrument slots (currently selected instruments)
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public void OnSlotClicked(Object sender, EventArgs e)
        {
            InstrumentButton slotClicked = (InstrumentButton)sender;

            SingleNotePlayer.PlayNote(slotClicked.Instrument.AtPitch(0));

            if (slotClicked.Selected == false)
            {
                slotClicked.Selected  = true;        // Slot we just clicked is highlighted
                selectedSlot.Selected = false;       // Previously highlighted slot is de-highlighted
                selectedSlot          = slotClicked; // Update selectedSlot
            }
        }
        /// <summary>
        /// Event handler for the Instrument Buttons
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public void OnInstrumentClicked(Object sender, EventArgs e)
        {
            InstrumentButton clickedButton = (InstrumentButton)sender;

            SingleNotePlayer.PlayNote(clickedButton.Instrument.AtPitch(0));

            if (!selectedInstruments.Contains(clickedButton.Instrument))
            {
                selectedInstruments.Remove(selectedSlot.Instrument);      // Remove current instrument from list of instruments selected
                selectedSlot.Instrument = clickedButton.Instrument;       // Set slot to hold the new instrument
                selectedInstruments.Add(selectedSlot.Instrument);         // Update the list of colors selected
                doneButton.TextColor = Color.White;                       // Make sure cancel button is no longer gray
            }
        }
 /// <summary>
 /// Returns to main page.
 /// </summary>
 async void ReturnToMainPage()
 {
     Device.BeginInvokeOnMainThread(delegate
     {
         foreach (InstrumentButton btn in mainpage.instrumentButtons)
         {
             if (btn.Instrument == selectedSlot.Instrument)
             {
                 mainpage.SetSelectedSidebarButton(btn);
                 break;
             }
         }
     });
     SingleNotePlayer.StopPlayingNote();
     await Navigation.PopToRootAsync();
 }
 /// <summary>
 /// Returns to MoreOptions page.
 /// </summary>
 async void ReturnToMoreOptionsPage()
 {
     SingleNotePlayer.StopPlayingNote();
     await Navigation.PopAsync();
 }