Exemple #1
0
 /// <summary>
 /// Draws a key of the VirtualKeyboard.
 /// </summary>
 /// <param name="args">Provides context information.</param>
 public abstract void DrawKey(KeyRendererEventArgs args);
Exemple #2
0
        /// <summary>
        /// Draws the key of a VirtualKeyboard.
        /// </summary>
        /// <param name="args">Provides context information.</param>
        public override void DrawKey(KeyRendererEventArgs args)
        {
            Key key = args.Key;

            if (ColorTable != null)
            {
                Rectangle rect = args.Bounds;

                if (args.ClipRectangle.IntersectsWith(rect))
                {
                    Brush keyBrush = ColorTable.KeysBrush;
                    if (key.Style == KeyStyle.Dark)
                        keyBrush = ColorTable.DarkKeysBrush;
                    else if (key.Style == KeyStyle.Light)
                        keyBrush = ColorTable.LightKeysBrush;
                    else if (key.Style == KeyStyle.Pressed)
                        keyBrush = ColorTable.PressedKeysBrush;
                    else if (key.Style == KeyStyle.Toggled)
                        keyBrush = ColorTable.KeysBrush;

                    if (args.IsDown)
                        keyBrush = ColorTable.DownKeysBrush;

                    Brush textBrush = ColorTable.TextBrush;
                    if (key.Style == KeyStyle.Toggled)
                        textBrush = ColorTable.ToggleTextBrush;
                    if (args.IsDown)
                        textBrush = ColorTable.DownTextBrush;

                    args.Graphics.FillRectangle(keyBrush, rect);


                    if (key.Info == "{BACKSPACE}")
                    {
                        DrawBackspaceSign(args.Graphics, rect, keyBrush, textBrush);
                    }
                    else if (key.Caption == ":-)")
                    {
                        DrawSmileySign(args.Graphics, rect, keyBrush, textBrush);
                    }
                    else if (key.Caption == "Shift")
                    {
                        DrawUpArrow(args.Graphics, rect, keyBrush, textBrush);
                    }
                    else
                    {
                        args.Graphics.DrawString(key.Caption, _KeyFont, textBrush, rect, _CenteredTextStringFormat);

                        if (key.Hint != null)
                        {
                            args.Graphics.DrawString(key.Hint, _HintFont, textBrush, rect, _TopCenteredTextStringFormat);
                        }
                    }
                }
            }
        }