private void GoToTextMode(NoteInputMode mode, bool setFocus)
        {
            if (mode != NoteInputMode.Text && mode != NoteInputMode.Dictation)
            {
                return;
            }
            InputMode = mode;

            VisualStateManager.GoToState(this, "TextInput", true);

            if (setFocus)
            {
                _ = containerForText.Focus(FocusState.Keyboard);
            }

            // Move text controls to primary commands and
            // ink controls to secondary commands in the command bar.
            if (NoteCommandBar.PrimaryCommands.Contains(NoteTypeInk))
            {
                NoteCommandBar.PrimaryCommands.Remove(NoteTypeInk);
                NoteCommandBar.SecondaryCommands.Add(NoteTypeInk);
            }
            if (NoteCommandBar.SecondaryCommands.Contains(NoteTypeText))
            {
                NoteCommandBar.SecondaryCommands.Remove(NoteTypeText);
                NoteCommandBar.PrimaryCommands.Add(NoteTypeText);
            }

            containerForInk.Strokes.Clear();
        }
        /// <summary>
        /// Returns the visibility the passed in control should have
        /// </summary>
        /// <param name="value">The mode that the note has been changed to</param>
        /// <param name="targetType"></param>
        /// <param name="parameter">The control that is asking for visiblity information, e.g. if "Text", the text container is calling the converter</param>
        /// <param name="language"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            Debug.Assert(value != null, "Expecting a value to convert");
            Debug.Assert(parameter != null, "Expecting a parameter describing the caller");

            NoteInputMode currentNoteMode = (NoteInputMode)value;

            // If the ink control is calling, make it visible if the note is in Ink mode
            if (parameter.Equals("Ink"))
            {
                return(currentNoteMode == NoteInputMode.Ink ? Visibility.Visible : Visibility.Collapsed);
            }

            // If the text control is calling, make it visible if the note is in text mode
            if (parameter.Equals("Text"))
            {
                bool textMode =
                    currentNoteMode == NoteInputMode.Dictation ||
                    currentNoteMode == NoteInputMode.Text ||
                    currentNoteMode == NoteInputMode.Default;

                return(textMode ? Visibility.Visible : Visibility.Collapsed);
            }

            return(Visibility.Visible); // everything else should be visible.
        }
Beispiel #3
0
 public NoteInputConverter(
     KeyboardPitchMappings keyboardPitchMappings,
     MidiPitchMapping midiPitchMapping,
     NoteSink noteSink,
     NoteInputMode noteInputMode)
 {
     KeyboardPitchMappings = keyboardPitchMappings;
     NoteSink         = noteSink;
     NoteInputMode    = noteInputMode;
     MidiPitchMapping = midiPitchMapping;
 }
Beispiel #4
0
 public IReadOnlyDictionary <Key, Pitch> this[NoteInputMode mode]
 {
     get
     {
         if (mode == NoteInputMode.KeyboardNamed)
         {
             return(Named);
         }
         if (mode == NoteInputMode.KeyboardLinearDiatonic)
         {
             return(LinearDiatonic);
         }
         throw new ArgumentOutOfRangeException($"Keyboard mode expected, but given: {mode}");
     }
 }
Beispiel #5
0
 public static bool IsKeyboardMode(this NoteInputMode mode) =>
 !mode.IsMidi();
Beispiel #6
0
 public static bool IsMidi(this NoteInputMode mode) =>
 mode == NoteInputMode.Midi;
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputModeChangedEventArgs"/> class.
 /// </summary>
 /// <param name="sourceNote">The <see cref="Note"/> control that raised the event.</param>
 /// <param name="inputMode">The new input mode.</param>
 public InputModeChangedEventArgs(Note sourceNote, NoteInputMode inputMode)
 {
     this.SourceNote   = sourceNote;
     this.NewInputMode = inputMode;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InputModeChangedEventArgs"/> class. 
 /// </summary>
 /// <param name="sourceNote">The <see cref="Note"/> control that raised the event.</param>
 /// <param name="inputMode">The new input mode.</param>
 public InputModeChangedEventArgs(Note sourceNote, NoteInputMode inputMode)
 {
     this.SourceNote = sourceNote;
     this.NewInputMode = inputMode;
 }