Ejemplo n.º 1
0
        //Constructor
        public KeyboardPadKey(VirtualKey virtualKey)
            : base("")
        {
            //Always Store full VirtualKey Properties in KeyBoardKey
            this.Properties = virtualKey;

            //Key Labels
            if (virtualKey.L1 != null)
            {
                _l1LabelText = virtualKey.L1.Glyph;
            }
            else
            {
                _l1LabelText = "";
            };
            if (virtualKey.L2 != null)
            {
                _l2LabelText = virtualKey.L2.Glyph;
            }
            else
            {
                _l2LabelText = "";
            };

            //Init Local Vars
            Size   sizeKeyboardPadDefaultKey   = Utils.StringToSize(GlobalFramework.Settings["sizeKeyboardPadDefaultKey"]);
            String fontKeyboardPadPrimaryKey   = GlobalFramework.Settings["fontKeyboardPadPrimaryKey"];
            String fontKeyboardPadSecondaryKey = GlobalFramework.Settings["fontKeyboardPadSecondaryKey"];

            //ByPass Defaults
            if (virtualKey.L1.KeyWidth > 0)
            {
                sizeKeyboardPadDefaultKey.Width = virtualKey.L1.KeyWidth;
            }
            ;

            //Defaults
            //Prepare Pango Fonts
            if (virtualKey.L1.IsBold)
            {
                fontKeyboardPadPrimaryKey = "Bold " + fontKeyboardPadPrimaryKey;
            }
            ;
            Pango.FontDescription fontDescriptionPrimaryKey   = Pango.FontDescription.FromString(fontKeyboardPadPrimaryKey);
            Pango.FontDescription fontDescriptionSecondaryKey = Pango.FontDescription.FromString(fontKeyboardPadSecondaryKey);

            //Vbox
            VBox vbox = new VBox(true, 0);

            vbox.BorderWidth = 2;
            //Labels
            _labelL1      = new Label();
            _labelL1.Text = _l1LabelText;
            //Align
            switch (virtualKey.L1.HAlign)
            {
            case "left":
                _labelL1.SetAlignment(0.00F, 0.5F);
                break;

            case "right":
                _labelL1.SetAlignment(1.00F, 0.5F);
                break;
            }
            _labelL1.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(_colorKeyboardPadKeyDefaultFont));
            _labelL1.ModifyFont(fontDescriptionPrimaryKey);
            vbox.PackEnd(_labelL1);
            //HideL2 dont show L2
            if (_l2LabelText != string.Empty && !virtualKey.L1.HideL2)
            {
                _labelL2      = new Label();
                _labelL2.Text = _l2LabelText;
                _labelL1.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(_colorKeyboardPadKeyDefaultFont));
                _labelL2.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(_colorKeyboardPadKeySecondaryFont));
                _labelL1.ModifyFont(fontDescriptionSecondaryKey);
                _labelL2.ModifyFont(fontDescriptionSecondaryKey);
                _labelL1.SetAlignment(0.60F, 0.50F);
                _labelL2.SetAlignment(0.40F, 0.50F);
                vbox.PackStart(_labelL2);
            }
            ;

            //InitObject("", _colorKeyboardPadKeyBackground, vbox, sizeKeyboardPadDefaultKey.Width, sizeKeyboardPadDefaultKey.Height);

            //Changed for theme
            this.BorderWidth = 1;
            InitObject("", Color.Transparent, vbox, sizeKeyboardPadDefaultKey.Width, sizeKeyboardPadDefaultKey.Height);
        }
Ejemplo n.º 2
0
        //Add VirtualKey to VirtualKeyboard
        private bool AddKey(XmlReader reader)
        {
            String currentType     = "";
            int    currentRowIndex = 0;
            int    currentColIndex = 0;
            int    currentLevel    = 0;
            bool   result          = false;

            try
            {
                //Get Attributes from Node
                if (reader.MoveToAttribute("type"))
                {
                    currentType = reader.ReadContentAsString();
                }
                if (reader.MoveToAttribute("row"))
                {
                    currentRowIndex = reader.ReadContentAsInt();
                }
                if (reader.MoveToAttribute("col"))
                {
                    currentColIndex = reader.ReadContentAsInt();
                }
                if (reader.MoveToAttribute("level"))
                {
                    currentLevel = reader.ReadContentAsInt();
                }

                //Always Validate if position exists, if not Allocate space to it
                ValidateKeyBoard(currentRowIndex, currentColIndex);

                //Init tmpSelectedKey
                VirtualKey tmpSelectedKey = null;

                //Create reference to position in VirtualKeyboard
                tmpSelectedKey = _internalKeyBoard[currentRowIndex][currentColIndex];

                //Init key position
                if (tmpSelectedKey.RowIndex == -1)
                {
                    tmpSelectedKey.RowIndex = currentRowIndex;
                }
                if (tmpSelectedKey.ColIndex == -1)
                {
                    tmpSelectedKey.ColIndex = currentColIndex;
                }

                //Get Attributes from node and Assign to Leve Properties
                VirtualKeyProperties tmpProperties = new VirtualKeyProperties();
                if (reader.MoveToAttribute("glyph"))
                {
                    tmpProperties.Glyph = reader.ReadContentAsString();
                }
                if (reader.MoveToAttribute("ibmid"))
                {
                    tmpProperties.IbmId = reader.ReadContentAsString();
                }
                if (reader.MoveToAttribute("deadkey"))
                {
                    tmpProperties.IsDeadKey = reader.ReadContentAsBoolean();
                }
                if (reader.MoveToAttribute("diacritical"))
                {
                    tmpProperties.Diacritical = reader.ReadContentAsString();
                }
                if (reader.MoveToAttribute("notengraved"))
                {
                    tmpProperties.IsNotEngraved = reader.ReadContentAsBoolean();
                }
                if (reader.MoveToAttribute("charactername"))
                {
                    tmpProperties.CharacterName = reader.ReadContentAsString();
                }
                if (reader.MoveToAttribute("unicodeid"))
                {
                    tmpProperties.UnicodeId = reader.ReadContentAsString();
                }
                if (reader.MoveToAttribute("keywidth"))
                {
                    tmpProperties.KeyWidth = reader.ReadContentAsInt();
                }
                if (reader.MoveToAttribute("numpad"))
                {
                    tmpProperties.IsNumPad = reader.ReadContentAsBoolean();
                }
                if (reader.MoveToAttribute("hidel2"))
                {
                    tmpProperties.HideL2 = reader.ReadContentAsBoolean();
                }
                if (reader.MoveToAttribute("bold"))
                {
                    tmpProperties.IsBold = reader.ReadContentAsBoolean();
                }
                if (reader.MoveToAttribute("halign"))
                {
                    tmpProperties.HAlign = reader.ReadContentAsString();
                }

                switch (currentLevel)
                {
                case 0:
                    tmpSelectedKey.Type = currentType;
                    tmpSelectedKey.L1   = tmpProperties;
                    break;

                case 1:
                    tmpSelectedKey.L2 = tmpProperties;
                    break;

                case 2:
                    tmpSelectedKey.L3 = tmpProperties;
                    break;

                default:
                    throw new Exception("Invalid key level");
                }
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("AddKey(): {0}", ex.Message), ex);
            }

            return(result);
        }