private Rectangle GetButtonTextRect(TouchKey Key) { Rectangle TextRect = Key.TextRect; TextRect.Offset(Key.Position); return(TextRect); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { TouchKey Key = HitButton(e.Location); UpdateKeyState(Key); } }
private Bitmap GetKeyBitmap(TouchKey Key) { if (Key == pressedkey_) { Bitmap Bmp = Key.GetPressedBmp(IsKeyLocked(Key)); return(Bmp != null ? Bmp : pressedKeyBmp_); } else { Bitmap Bmp = Key.GetReleasedBmp(IsKeyLocked(Key)); return(Bmp != null ? Bmp : releasedKeyBmp_); } }
private void UpdateKeyState(TouchKey PressedKey) { if (PressedKey != pressedkey_) { Brush FontBrush = new SolidBrush(ForeColor); TouchKey OldPressedKey = pressedkey_; pressedkey_ = null; if (OldPressedKey != null) { Invalidate(GetKeyRectangle(OldPressedKey)); if (OldPressedKey.KeyUpAction != null) { OldPressedKey.KeyUpAction(OldPressedKey); } } pressedkey_ = PressedKey; if (PressedKey != null) { Invalidate(GetKeyRectangle(PressedKey)); if (PressedKey.KeyDownAction == null) { int OldCaretPos = CaretPosition; string Text = GetKeyString( PressedKey.Key, shiftPressed_, altGrPressed_, capsLockActive_, InputLanguage.CurrentInputLanguage ); InsertKeys(Text, OldCaretPos); CaretPosition += Text.Length; if (shiftPressed_) { shiftPressed_ = false; Invalidate(); } if (altGrPressed_) { altGrPressed_ = false; Invalidate(); } } else { PressedKey.KeyDownAction(PressedKey); } } } }
private string InsertKey(TouchKey Key, int Position) { string Txt = GetKeyString( Key.Key, shiftPressed_, altGrPressed_, capsLockActive_, InputLanguage.CurrentInputLanguage ); if (Key != null && Txt != "\0" && Txt != "") { InsertKeys(Txt, Position); } return(Txt); }
private bool IsKeyLocked(TouchKey Key) { switch (Key.Key) { case Keys.ShiftKey: return(shiftPressed_); case Keys.CapsLock: return(capsLockActive_); case Keys.Menu: return(altGrPressed_); default: return(false); } }
private void DrawButton(Graphics g, Brush FontBrush, TouchKey k) { Bitmap BtnBmp = GetKeyBitmap(k); g.DrawImage(BtnBmp, k.Position); string KeyChar = k.GetKeyText(shiftPressed_, altGrPressed_, capsLockActive_); Rectangle TextRect = GetButtonTextRect(k); if (k == pressedkey_) { TextRect.Offset(pressedOffset_); } //g.DrawRectangle(Pens.Red, TextRect); StringFormat Fmt = new StringFormat(); Fmt.Alignment = StringAlignment.Center; Fmt.LineAlignment = StringAlignment.Center; g.DrawString(KeyChar, Font, FontBrush, TextRect, Fmt); }
private void OnRightKeyDown(TouchKey Key) { ++CaretPosition; }
private void OnLeftKeyDown(TouchKey Key) { --CaretPosition; }
private void OnBackKeyDown(TouchKey Key) { Rubout(); }
private void OnAltGrKeyDown(TouchKey Key) { altGrPressed_ = !altGrPressed_; Invalidate(); }
private void OnCapsLockKeyDown(TouchKey Key) { capsLockActive_ = !capsLockActive_; Invalidate(); }
private void OnShiftKeyDown(TouchKey Key) { shiftPressed_ = !shiftPressed_; Invalidate(); }
private Rectangle GetKeyRectangle(TouchKey Key) { return(new Rectangle(Key.Position, GetKeyBitmap(Key).Size)); }