private void CreateNumericLayout(Container p)
        {
            string keyLine = NumericKeys[0];

            int keyWidth = (p._width - 20 - (keyLine.Length + 2) * _uiMargin) / (keyLine.Length + 1);
            int keyHeight = (p._height - (NumericKeys.Length + 1) * _uiMargin) / NumericKeys.Length;

            int widthRemaining = p._width - ((keyLine.Length + 2) * _uiMargin + (keyLine.Length + 1) * keyWidth);

            int x, y;

            x = _uiMargin;
            y = 0;
            for (int i = 0; i < NumericKeys.Length; i++)
            {
                x = _uiMargin + widthRemaining / 2;
                string line = NumericKeys[i];
                for (int j = 0; j < line.Length; j++)
                {
                    TextButton numBut = new TextButton(line[j].ToString(), x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)line[j] & (int)KeyFlags.KeyMask) }; ;
                    numBut.ButtonPressed += _key_ButtonPressed;
                    p.AddChild(numBut);
                    x += _uiMargin + keyWidth;
                }
                y += keyHeight + _uiMargin;
            }

            y = 0;
            ImageButton backBut = new ImageButton(_bmpBackspace, x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.BackSpace };
            backBut.RepeatKeyPress = true;
            backBut.ButtonPressed += _key_ButtonPressed;
            p.AddChild(backBut);
            y += backBut._height + _uiMargin;

            TextButton modeSwitch = new TextButton("Mode", x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.ModeSwitch };
            modeSwitch.ButtonPressed += _keyModeSwitch_ButtonPressed;
            p.AddChild(modeSwitch);
            y += modeSwitch._height + _uiMargin;
        }
        private void CreateQwertyLayout(Container p)
        {
            string keyLine = Keys[0][_charSetUsed];

            int keyWidth = (p._width - (keyLine.Length + 1) * _uiMargin) / keyLine.Length;
            int keyHeight = (p._height - 5 * _uiMargin) / 4;

            int widthRemaining = p._width - ((keyLine.Length + 1) * _uiMargin + keyLine.Length * keyWidth);

            int x, y;

            #region 1st row keys
            x = _uiMargin + widthRemaining / 2;
            y = 0;
            for (int i = 0; i < keyLine.Length; i++)
            {
                TextButton keyBut = new TextButton(keyLine[i].ToString(), x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)keyLine[i] & (int)KeyFlags.KeyMask) };
                keyBut.ButtonPressed += _key_ButtonPressed;
                p.AddChild(keyBut);
                x += _uiMargin + keyWidth;
            }
            #endregion

            #region 2nd row keys
            x = _uiMargin + keyWidth / 2 + widthRemaining / 2;
            y += _uiMargin + keyHeight;
            keyLine = Keys[1][_charSetUsed];
            for (int i = 0; i < keyLine.Length; i++)
            {
                TextButton keyBut = new TextButton(keyLine[i].ToString(), x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)keyLine[i] & (int)KeyFlags.KeyMask) };
                keyBut.ButtonPressed += _key_ButtonPressed;
                p.AddChild(keyBut);
                x += _uiMargin + keyWidth;
            }
            #endregion

            #region 3rd row keys
            x = _uiMargin + widthRemaining / 2;
            y += _uiMargin + keyHeight;

            _capsButton = new TextButton("abc", x, y, keyWidth + keyWidth / 2, keyHeight) { Tag = (int)KeyFlags.CapsLock };
            _capsButton.ButtonPressed += _key_ButtonPressed;
            p.AddChild(_capsButton);
            x += _uiMargin + _capsButton._width;

            keyLine = Keys[2][_charSetUsed];
            for (int i = 0; i < keyLine.Length; i++)
            {
                TextButton keyBut = new TextButton(keyLine[i].ToString(), x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)keyLine[i] & (int)KeyFlags.KeyMask) };
                keyBut.ButtonPressed += _key_ButtonPressed;
                p.AddChild(keyBut);
                x += _uiMargin + keyWidth;
            }

            ImageButton backBut = new ImageButton(_bmpBackspace, x, y, keyWidth + keyWidth / 2, keyHeight) { Tag = (int)KeyFlags.BackSpace };
            backBut.RepeatKeyPress = true;
            backBut.ButtonPressed += _key_ButtonPressed;
            p.AddChild(backBut);
            #endregion

            #region 4th row keys
            x = _uiMargin + widthRemaining / 2;
            y += _uiMargin + keyHeight;

            TextButton modeSwitch = new TextButton("123?", x, y, keyWidth + keyWidth / 2, keyHeight) { Tag = (int)KeyFlags.ModeSwitch };
            modeSwitch.ButtonPressed += _key_ButtonPressed;
            modeSwitch.ButtonLongPressed += _keyModeSwitch_ButtonPressed;

            p.AddChild(modeSwitch);
            x += modeSwitch._width + _uiMargin;

            TextButton slashButton = new TextButton(",", x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)',' & (int)KeyFlags.KeyMask) };
            slashButton.ButtonPressed += _key_ButtonPressed;
            p.AddChild(slashButton);
            x += slashButton._width + _uiMargin;

            TextButton spaceButton = new TextButton("________", x, y, keyWidth * 4 + _uiMargin * 4 + keyWidth / 2, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)' ' & (int)KeyFlags.KeyMask) };
            spaceButton.ButtonPressed += _key_ButtonPressed;
            p.AddChild(spaceButton);
            x += spaceButton._width + _uiMargin;

            TextButton pointButton = new TextButton(".", x, y, keyWidth, keyHeight) { Tag = (int)KeyFlags.NormalKey | ((int)'.' & (int)KeyFlags.KeyMask) };
            pointButton.ButtonPressed += _key_ButtonPressed;
            p.AddChild(pointButton);
            x += pointButton._width + _uiMargin;

            _enterButton = new ImageButton(_bmpEnter, x, y, keyWidth * 2, keyHeight) { Tag = (int)KeyFlags.Enter };
            _enterButton.ButtonPressed += _key_ButtonPressed;
            p.AddChild(_enterButton);
            #endregion
        }