private void UserControl_KeyDown(object sender, KeyEventArgs e) { if (KeyValidator.IsIgnoredKey(e.Key)) { e.Handled = true; return; } else if (KeyValidator.IsUpKey(e.Key)) { e.Handled = true; MoveUp?.Invoke(this, new EventArgs()); return; } else if (KeyValidator.IsDownKey(e.Key)) { e.Handled = true; MoveDown?.Invoke(this, new EventArgs()); return; } else if (KeyValidator.IsLeftKey(e.Key)) { e.Handled = true; MoveLeft?.Invoke(this, new EventArgs()); return; } else if (KeyValidator.IsRightKey(e.Key)) { e.Handled = true; MoveRight?.Invoke(this, new EventArgs()); return; } else if (KeyValidator.IsPageDownKey(e.Key)) { e.Handled = true; MovePageDown?.Invoke(this, new EventArgs()); return; } else if (KeyValidator.IsPageUpKey(e.Key)) { e.Handled = true; MovePageUp?.Invoke(this, new EventArgs()); return; } else if (KeyValidator.IsDeleteKey(e.Key)) { if (!ReadOnlyMode) { e.Handled = true; ByteDeleted?.Invoke(this, new EventArgs()); return; } } else if (KeyValidator.IsBackspaceKey(e.Key)) { if (!ReadOnlyMode) { e.Handled = true; ByteDeleted?.Invoke(this, new EventArgs()); MovePrevious?.Invoke(this, new EventArgs()); return; } } else if (KeyValidator.IsEscapeKey(e.Key)) { e.Handled = true; EscapeKey?.Invoke(this, new EventArgs()); return; } //MODIFY ASCII... //TODO : MAKE BETTER KEYDETECTION AND EXPORT IN KEYVALIDATOR if (!ReadOnlyMode) { bool isok = false; if (Keyboard.GetKeyStates(Key.CapsLock) == KeyStates.Toggled) { if (Keyboard.Modifiers != ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift) { StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key)); isok = true; } else if (Keyboard.Modifiers == ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift) { isok = true; StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key)).ToString().ToLower(); } } else { if (Keyboard.Modifiers != ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift) { StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key)).ToString().ToLower(); isok = true; } else if (Keyboard.Modifiers == ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift) { isok = true; StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key)); } } //Move focus event if (isok) { if (MoveNext != null) { Action = ByteAction.Modified; Byte = ByteConverters.CharToByte(StringByteLabel.Content.ToString()[0]); MoveNext(this, new EventArgs()); } } } }