示例#1
0
        private Rectangle GetButtonTextRect(TouchKey Key)
        {
            Rectangle TextRect = Key.TextRect;

            TextRect.Offset(Key.Position);
            return(TextRect);
        }
示例#2
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == MouseButtons.Left)
     {
         TouchKey Key = HitButton(e.Location);
         UpdateKeyState(Key);
     }
 }
示例#3
0
 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_);
     }
 }
示例#4
0
        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);
                    }
                }
            }
        }
示例#5
0
        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);
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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);
        }
示例#8
0
 private void OnRightKeyDown(TouchKey Key)
 {
     ++CaretPosition;
 }
示例#9
0
 private void OnLeftKeyDown(TouchKey Key)
 {
     --CaretPosition;
 }
示例#10
0
 private void OnBackKeyDown(TouchKey Key)
 {
     Rubout();
 }
示例#11
0
 private void OnAltGrKeyDown(TouchKey Key)
 {
     altGrPressed_ = !altGrPressed_;
     Invalidate();
 }
示例#12
0
 private void OnCapsLockKeyDown(TouchKey Key)
 {
     capsLockActive_ = !capsLockActive_;
     Invalidate();
 }
示例#13
0
 private void OnShiftKeyDown(TouchKey Key)
 {
     shiftPressed_ = !shiftPressed_;
     Invalidate();
 }
示例#14
0
 private Rectangle GetKeyRectangle(TouchKey Key)
 {
     return(new Rectangle(Key.Position, GetKeyBitmap(Key).Size));
 }