예제 #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));
 }