/// <summary> /// Collects title, time, and key signature information from the Create New Score popup /// and uses them to create a new Score object and load it in the viewer. /// Called when the 'Start' button is clicked on the popup. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void createNew(object sender, RoutedEventArgs e) { // Close the popup Loaded = false; KeyCover.Visibility = Visibility.Hidden; ScoreCreationWindow.Visibility = Visibility.Hidden; //make keys, music sheet, notes and keyboard control visible Print.Visibility = Visibility.Visible; Piano_KeyBoard_layout.Visibility = Visibility.Visible; Piano_White_Keys.Visibility = Visibility.Visible; Piano_Black_Keys.Visibility = Visibility.Visible; MusicSheet.Visibility = Visibility.Visible; Notes_Rest.Visibility = Visibility.Visible; Keyboard_Controls.Visibility = Visibility.Visible; WorkingButtons.Visibility = Visibility.Visible; // Calculate key signature based on selected value from array // If selected index < 13, keyIndex - seleted index -1, else keyIndex = selected index Console.WriteLine(MusicTitle); MusicNameLabel.Content = MusicTitle; // Calculate key signature int keyIndex = (KeySignatureCombo.SelectedIndex < 13) ? KeySignatureCombo.SelectedIndex - 1 : 12 - KeySignatureCombo.SelectedIndex; Manufaktura.Controls.Model.Key key = new Manufaktura.Controls.Model.Key(keyIndex); model.KeySig = new Manufaktura.Controls.Model.Key(keyIndex); // Calculate time signature TimeSignature timeSig = new TimeSignature(TimeSignatureType.Numbers, beatsPerMeasure, beatLength); model.TimeSig = new TimeSignature(TimeSignatureType.Numbers, beatsPerMeasure, beatLength); // **** GRAND STAFF ON HOLD -- SWITCHING TO SINGLE STAFF TO GET BUGS OUT **** // Build grand staff for now -- later may add options for more or fewer staves //Staff treble = new Staff(); //MusicalSymbol[] elements = { Clef.Treble, key, timeSig }; // Add treble clef, key sig, time sig //for (int i = 0; i < 3; i++) //{ // treble.Elements.Add(elements[i]); //} //Staff bass = new Staff(); //elements[0] = Clef.Bass; // Add bass clef, key sig, time sig //for (int i = 0; i < 3; i++) //{ // bass.Elements.Add(elements[i]); //} //Staff[] staves = { treble, bass }; //// Pass the title and the treble and bass staves to createNew //model.createNew(TitleBox.Text, staves); // Create a single staff score model.createNew(key, timeSig); }
/// <summary> /// Collects title, time, and key signature information from the Create New Score popup /// and uses them to create a new Score object and load it in the viewer. /// Called when the 'Start' button is clicked on the popup. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void createNew(object sender, RoutedEventArgs e) { // Close the popup isLoaded = false; KeyCover.Visibility = Visibility.Hidden; ScoreCreationWindow.Visibility = Visibility.Hidden; //make keys, music sheet, notes and keyboard control visible Print.Visibility = Visibility.Visible; Piano_KeyBoard_layout.Visibility = Visibility.Visible; Piano_White_Keys.Visibility = Visibility.Visible; Piano_Black_Keys.Visibility = Visibility.Visible; MusicSheet.Visibility = Visibility.Visible; Notes_Rest.Visibility = Visibility.Visible; Keyboard_Controls.Visibility = Visibility.Hidden; WorkingButtons.Visibility = Visibility.Visible; //reset note selection to quarter note NoteSelectionReset(); // Calculate key signature based on selected value from array Console.WriteLine(MusicTitle); MusicNameLabel.Content = MusicTitle; // Calculate key signature int keyIndex = (KeySignatureCombo.SelectedIndex < 13) ? KeySignatureCombo.SelectedIndex - 1 : 12 - KeySignatureCombo.SelectedIndex; Manufaktura.Controls.Model.Key key = new Manufaktura.Controls.Model.Key(keyIndex); model.KeySig = new Manufaktura.Controls.Model.Key(keyIndex); // Calculate time signature TimeSignature timeSig = new TimeSignature(TimeSignatureType.Numbers, beatsPerMeasure, beatLength); model.TimeSig = new TimeSignature(TimeSignatureType.Numbers, beatsPerMeasure, beatLength); // Create a single staff score model.FileName = ""; model.createNew(key, timeSig); Viewer.ScoreSource = model.Data; model.ResetPlayer(); }