private void ButtonOK_Click(object sender, RoutedEventArgs e) { this.RecorderItem.Dir = (this.comboUpDownButton.SelectedItem as UpDownItem).Dir; IKeyRecorderItem keyItem = this.RecorderItem as IKeyRecorderItem; VirtualKeyCode vkCode = (this.comboKey.SelectedItem as KeyItem).VKKeyCode; keyItem.VkCode = (int)vkCode; keyItem.Keyname = AUtil.ToVKeyToString(vkCode); this.DialogResult = true; }
private void ButtonOK_Click(object sender, RoutedEventArgs e) { KeyPressRecorderItem rootItem = this.RecorderItem as KeyPressRecorderItem; List <KeyPressData> gridItems = this.dataGridKeys.ItemsSource as List <KeyPressData>; var keyData = gridItems[0]; rootItem.VkCode = (int)keyData.Key.VKKeyCode; rootItem.Keyname = AUtil.ToVKeyToString(keyData.Key.VKKeyCode); rootItem.ChildItems.Clear(); for (int i = 1; i < gridItems.Count; i++) { keyData = gridItems[i]; rootItem.ChildItems.Add(new KeyPressRecorderItem() { Time = rootItem.Time + TimeSpan.FromSeconds(ESRRecorder.MinimumTimeSpan * i), VkCode = (int)keyData.Key.VKKeyCode, Keyname = AUtil.ToVKeyToString(keyData.Key.VKKeyCode), }); } this.DialogResult = true; }
public override string ToString() { return(AUtil.ToVKeyToString(VKKeyCode)); }
public void Add(KeyInputEventArgs e) { IRecorderItem newRecorder = null; if (e.KeyData.EventType == KeyEvent.up) { if (IsIncludedKeyItem(e)) { ALog.Debug("KeyEvent.Up.IsIncludedKeyItem == true"); return; } IRecorderItem prevRecorder = GetPrviousKeyDownItem(e); if (prevRecorder != null) { //Delete Previous Key up Items ALog.Debug("Delete Items::Recorder={0}, VkCode={1}", prevRecorder.Recorder, AUtil.ToVKeyToString((prevRecorder as IKeyRecorderItem).VkCode)); this.ESRRecorder.DeleteItem(prevRecorder); //New Key Press this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; //If Current Is KeyPress, this KeyPress add into ChildItem if (this.CurrentRecorder?.Recorder == RecorderType.KeyPress) { ALog.Debug("Add KeyPress into KeyPress.ChildItem"); this.ESRRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } } else { ALog.Debug("KeyUp Item"); newRecorder = new KeyUpDownRecorderItem() { Dir = Dir.Up, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; } } else { //it's state on pressing key if (IsLastSameKeyDown(e.KeyData.VkCode)) { ALog.Debug("KeyEvent.Down, IsLastKeyDown: True"); return; } //If current is KeyPress, Add a item into ChildItem if (IsCurrentKeyPress() && !IsCtrlAltShift(e.KeyData.VkCode) && !IsCtrlAltShift(Control.ModifierKeys)) { //New Key Press this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; this.ESRRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } //If Current is Key Down, It means continuosly 2 item's Type is KeyDown. //So that, 1) Replace Previous KeyDown item to KeyPress // 2) Add a this time KeyDown item into Child Item if (IsCurrentKeyDown() && !IsCtrlAltShift(e.KeyData.VkCode) && !IsCtrlAltShift(Control.ModifierKeys)) { ReplaceKeyDownToKeyPress(this.CurrentRecorder); //New Key Press this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; this.ESRRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } //New Key Down newRecorder = new KeyUpDownRecorderItem() { Dir = Dir.Down, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; } this.ESRRecorder.AddKeyItem(newRecorder); }