/// <summary> /// Inject the character represented by the given "key" switch view-model, into whatever the target TextBox is. /// </summary> /// <param name="vm">The KeyAssignment that carries the information of what to inject</param> public void Inject(KeyModel vm, bool?isShifted = null) { // The Tag would've been another way to associate the view-model with the button. if (vm != null) { if (vm == EnterKey) { Inject(Environment.NewLine); } else { if (isShifted.HasValue) { if (isShifted.Value == true) { Inject(vm.ShiftedCodePoint.ToString()); } else { Inject(vm.UnshiftedCodePoint.ToString()); } } else { Debug.WriteLine("invoking Inject, _isCapsLock is " + _isCapsLock); Inject(vm.CodePointString); } } } // If we were in Shift-mode, reset that now. IsShiftLock = false; ClearShiftKeyResetTimer(); }
/// <summary> /// Execute the KeyPressedCommand. /// </summary> /// <param name="arg">The KeyModel of the key-button that was pressed</param> public void ExecuteKeyPressedCommand(object arg) { //Debug.WriteLine("KeyboardViewModel.ExecuteKeyPressedCommand, arg = " + arg); KeyModel keyModel = arg as KeyModel; // Do for every key except the AltGr key. if (keyModel != Alt_Right) { if (keyModel != null) { //Console.WriteLine("ExecuteKeyPressedCommand, btn.Name = " + btn.Name); Inject(keyModel); } else { String sWhat = arg as String; if (!String.IsNullOrEmpty(sWhat)) { Inject(sWhat); } } } }
/// <summary> /// Inject the character represented by the given "key" switch view-model, into whatever the target TextBox is. /// </summary> /// <param name="vm">The KeyAssignment that carries the information of what to inject</param> public void Inject(KeyModel vm, bool? isShifted = null) { // The Tag would've been another way to associate the view-model with the button. if (vm != null) { if (vm == EnterKey) { Inject(Environment.NewLine); } else { if (isShifted.HasValue) { if (isShifted.Value == true) { Inject(vm.ShiftedCodePoint.ToString()); } else { Inject(vm.UnshiftedCodePoint.ToString()); } } else { Debug.WriteLine("invoking Inject, _isCapsLock is " + _isCapsLock); Inject(vm.CodePointString); } } } // If we were in Shift-mode, reset that now. IsShiftLock = false; ClearShiftKeyResetTimer(); }