Example #1
0
        //Constructor
        public KeyBoardPad(String pFile)
        {
            //ParseXML into VirtualKeyBoard Object
            _virtualKeyBoard = new VirtualKeyBoard(pFile);

            //Transform VirtualKeyBoard Object into UI VBox of Rows
            VBox keyboard = InitVirtualKeyboard(_virtualKeyBoard);

            PackStart(keyboard);

            //Update after Allocated
            _vboxNumPadRows.SizeAllocated += delegate { UpdateKeyboardMode(); };
        }
Example #2
0
        //Initialize UI Keyboard from VirtualKeyboard
        private VBox InitVirtualKeyboard(VirtualKeyBoard pVirtualKeyboard)
        {
            List <VirtualKey> currentKeyboardRow;
            VirtualKey        currentKey;     //Virtual Key
            KeyboardPadKey    keyboardPadKey; //UI GTK Key

            //Init Lists
            List <HBox> hboxKeyBoard = new List <HBox>();
            List <HBox> hboxNumPad   = new List <HBox>();

            //Init VBoxs to strore Rows
            _vboxKeyboardRows = new VBox(true, 0);
            _vboxNumPadRows   = new VBox(true, 0);

            //loop rows
            for (int i = 0; i < pVirtualKeyboard.KeyBoard.Count; i++)
            {
                //Get current VirtualKeyboard Row to Work
                currentKeyboardRow = pVirtualKeyboard.KeyBoard[i];

                //add new Hbox to hboxKeyBoard/hboxNumPad rows List
                hboxKeyBoard.Add(new HBox(false, 0));
                hboxNumPad.Add(new HBox(false, 0));

                //loop columns in a row
                for (int j = 0; j < currentKeyboardRow.Count; j++)
                {
                    //Debug
                    //_log.Debug(string.Format("InitVirtualKeyboard(): tmpKey{0}:{1}:{2}", i, j, currentKey.L1.Glyph));

                    currentKey = currentKeyboardRow[j];

                    //Create UI Key
                    keyboardPadKey          = new KeyboardPadKey(currentKey);
                    keyboardPadKey.Clicked += keyboardPadKey_Clicked;
                    //Assign its UI reference to VirtualKey, usefull to have access to UI in VirtualKeyboard.VirtualKey
                    currentKey.UIKey = keyboardPadKey;

                    //If is a IsNumPad L1 key add to IsNumPad
                    if (currentKey.L1.IsNumPad)
                    {
                        hboxNumPad[i].PackStart(keyboardPadKey, false, false, 0);
                    }
                    //Else Add to KeyBoard
                    else
                    {
                        hboxKeyBoard[i].PackStart(keyboardPadKey, false, false, 0);
                    };
                }
                //In the end add row to Vbox
                _vboxKeyboardRows.PackStart(hboxKeyBoard[i]);
                _vboxNumPadRows.PackStart(hboxNumPad[i]);
            }

            //Pack KeyBoard and NumberPad into hboxResultReyboard
            HBox hboxResultReyboard = new HBox(false, 0);

            hboxResultReyboard.Spacing = _spacing;
            hboxResultReyboard.PackStart(_vboxKeyboardRows, false, false, 0);
            hboxResultReyboard.PackStart(_vboxNumPadRows, false, false, 0);
            //Init _textEntry
            Pango.FontDescription fontDescriptiontextEntry = Pango.FontDescription.FromString(_fontKeyboardPadTextEntry);
            _textEntry = new EntryValidation();
            _textEntry.ModifyFont(fontDescriptiontextEntry);
            //Change Selected Text, when looses entry focus
            _textEntry.ModifyBase(StateType.Active, Utils.ColorToGdkColor(Color.Gray));
            //Final Pack KeyBoard + TextEntry
            VBox vboxResult = new VBox(false, _spacing);

            vboxResult.PackStart(_textEntry);
            vboxResult.PackStart(hboxResultReyboard);

            //Events
            this.KeyReleaseEvent += KeyBoardPad_KeyReleaseEvent;

            //Add Space arround Keyboards
            return(vboxResult);
        }