Ejemplo n.º 1
0
 public VirtualKey()
 {
     RowIndex = -1;
     ColIndex = -1;
     VirtualKeyProperties L1 = new VirtualKeyProperties();
     VirtualKeyProperties L2 = new VirtualKeyProperties();
     VirtualKeyProperties L3 = new VirtualKeyProperties();
 }
Ejemplo n.º 2
0
        //Process Keyboard Inputs
        private void keyboardPadKey_Clicked(object sender, EventArgs e)
        {
            KeyboardPadKey       vKey           = (KeyboardPadKey)sender;
            VirtualKeyProperties vKeyProperties = null;
            Char   _unicodeChar;
            bool   _requireUpdate = false;
            bool   _skipInsert    = false;
            int    _tempCursorPosition;
            String _stringChar;

            int selectionStart, selectionEnd;

            _textEntry.GetSelectionBounds(out selectionStart, out selectionEnd);
            if (selectionStart > 0 || selectionEnd > 0)
            {
                _textEntry.DeleteSelection();
            }

            //Get Level and Assign Level Properties to current vKeyProperties
            switch (_activeModifierKey)
            {
            case ModifierKeys.Shift:
                vKeyProperties = vKey.Properties.L2;
                break;

            case ModifierKeys.Alt:
                vKeyProperties = vKey.Properties.L3;
                break;

            default:
                vKeyProperties = vKey.Properties.L1;
                break;
            }

            //DeadKey
            if (vKeyProperties != null && vKeyProperties.IsDeadKey)
            {
                _requireUpdate     = true;
                _skipInsert        = true;
                _activeDiacritical = vKeyProperties.Diacritical;
            }
            ;

            //Process Keys, Modifiers
            switch (vKey.Properties.Type)
            {
            //Sticky Caps Lock
            case "caps":
                _requireUpdate = true;
                if (_isCapsEnabled == false)
                {
                    _isCapsEnabled = true;
                }
                else
                {
                    _isCapsEnabled = false;
                }
                break;

            //Modifier Shift
            case "shift":
                _requireUpdate = true;
                if (_activeModifierKey == ModifierKeys.Shift)
                {
                    _activeModifierKey = ModifierKeys.None;
                }
                else
                {
                    _activeModifierKey = ModifierKeys.Shift;
                };
                break;

            //Modifier Alt
            case "alt":
                _requireUpdate = true;
                if (_activeModifierKey == ModifierKeys.Alt)
                {
                    _activeModifierKey = ModifierKeys.None;
                }
                else
                {
                    _activeModifierKey = ModifierKeys.Alt;
                };
                break;

            //Modifier Shift
            case "ctrl":
                _requireUpdate = true;
                if (_activeModifierKey == ModifierKeys.Ctrl)
                {
                    _activeModifierKey = ModifierKeys.None;
                }
                else
                {
                    _activeModifierKey = ModifierKeys.Ctrl;
                };
                break;

            //Modal Cancel
            case "esc":
                ParentDialog.Respond(ResponseType.Cancel);
                break;

            //Modal Confirm
            case "enter":
                if (_textEntry.Validated)
                {
                    // This Will Crash only in Debug, if Run Outside it Wont Crash (Simply disappear without log error)
                    try
                    {
                        ParentDialog.Respond(ResponseType.Ok);
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message, ex);
                    }
                }
                else
                {
                    Utils.ShowMessageTouch(ParentDialog, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.dialog_message_field_validation_error_keyboardpad);
                };
                break;

            //Show/Hide Number Lock
            case "tab":
                if (_activeKeyboardMode == KeyboardMode.AlfaNumeric)
                {
                    if (_vboxNumPadRows.Visible)
                    {
                        ParentDialog.WidthRequest -= _vboxNumPadRows.Allocation.Width + _spacing;
                        _vboxNumPadRows.HideAll();
                    }
                    else
                    {
                        ParentDialog.WidthRequest += _vboxNumPadRows.Allocation.Width + _spacing;
                        _vboxNumPadRows.ShowAll();
                    };
                }
                break;

            //Enable/Disable Internal Keyboard
            case "ekey":
                break;

            //Delete
            case "back":
                _textEntry.DeleteText(_textEntry.Position - 1, _textEntry.Position);
                break;

            //Cursor Move to Start
            case "home":
                _textEntry.Position = 0;
                break;

            //Cursor Move to End
            case "end":
                _textEntry.Position = _textEntry.Text.Length;
                break;

            //Does Nothing
            case "up":
                break;

            //Does Nothing
            case "down":
                break;

            //Move Cursor to Left
            case "left":
                if (_textEntry.Position > 0)
                {
                    _textEntry.Position -= 1;
                }
                break;

            //Move Cursor to Right
            case "right":
                if (_textEntry.Position < _textEntry.Text.Length)
                {
                    _textEntry.Position += 1;
                }
                break;

            //All Other Keys
            default:
                //NumberPad always work only with L1
                if (vKey.Properties.L1.IsNumPad == true || vKey.Properties.Type == "space")
                {
                    vKeyProperties = vKey.Properties.L1;
                }
                //If Caps enabled and is Letter, change to Level 2 (Uppercase)
                else if (_isCapsEnabled && Utils.IsLetter(Utils.UnicodeHexadecimalStringToChar(vKeyProperties.UnicodeId)))
                {
                    vKeyProperties = vKey.Properties.L2;
                }
                ;
                //Get unicodeChar from UnicodeId after Caps
                _unicodeChar = Utils.UnicodeHexadecimalStringToChar(vKeyProperties.UnicodeId);
                //Modifie _unicodeChar Keys ex Culture Decimal Separator . with , [3,15 = Key NumberPad .]
                //if (vKey.Properties.RowIndex == 3 && vKey.Properties.ColIndex == 15) _unicodeChar = (char) GlobalFramework.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];
                //Always Disable Modifiers Keys After Use
                if (_activeModifierKey != ModifierKeys.None)
                {
                    _requireUpdate = true;
                    //Process Modifiers aBefore Disable Modifier
                    switch (_activeModifierKey)
                    {
                    case ModifierKeys.Ctrl:
                        switch (Convert.ToString(_unicodeChar).ToUpper())
                        {
                        case "X":
                            _textEntry.CutClipboard();
                            _skipInsert = true;
                            break;

                        case "C":
                            _textEntry.CopyClipboard();
                            _skipInsert = true;
                            break;

                        case "V":
                            _textEntry.PasteClipboard();
                            _skipInsert = true;
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                    //After Process Modifiers, restore default Non Modifiers State
                    _activeModifierKey = ModifierKeys.None;
                }
                ;

                //Debug
                //_log.Debug(string.Format("keyboardKey_Clicked(): L1.Glyph:[{1}] L1.UnicodeId:[{2}] L1.CharacterName:[{3}] unicodeChar[{4}]", vKey.Properties.Type, vKeyProperties.Glyph, vKeyProperties.UnicodeId, vKeyProperties.CharacterName, _unicodeChar));

                //Add to TextEntry
                _tempCursorPosition = _textEntry.Position;

                if (!_skipInsert)
                {
                    _stringChar = Convert.ToString(_unicodeChar);
                    //Diacritical
                    if (_activeDiacritical != null)
                    {
                        _stringChar += Convert.ToString(Utils.UnicodeHexadecimalStringToChar(_activeDiacritical));
                        //Convert Diacritial chars to ISO chars to work with Validations and Peristence Database
                        _stringChar = ReplaceDiacritial(_stringChar);
                        //Reset activeDiacritical
                        _activeDiacritical = null;
                    }
                    _textEntry.InsertText(_stringChar, ref _tempCursorPosition);
                    _textEntry.Text.Normalize();
                }
                ;
                _textEntry.Position = _tempCursorPosition;
                break;
            }

            //HACK: to Activate TextEntry and place Cursor
            _tempCursorPosition = _textEntry.Position;
            _textEntry.GrabFocus();
            _textEntry.Position = _tempCursorPosition;

            //Update Keyboard if ModifierKey has Changed
            if (_requireUpdate)
            {
                UpdateKeyboard();
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        //Render a CSV String with VirtualKey properties, used in ExportToCsv
        private String GetVirtualKeyCSVProperties(String pType, int pRow, int pCol, int pLevel, VirtualKeyProperties pKeyProperties)
        {
            String result = "";

            if (pKeyProperties != null)
            {
                result += pType + "\t";
                if (pKeyProperties.Glyph != string.Empty)
                {
                    result += pKeyProperties.Glyph + "\t";
                }
                else
                {
                    result += "\t";
                };
                result += pRow + "\t";
                result += pCol + "\t";
                result += pLevel + "\t";
                if (pKeyProperties.IbmId != string.Empty)
                {
                    result += pKeyProperties.IbmId + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.IsDeadKey)
                {
                    result += pKeyProperties.IsDeadKey.ToString() + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.Diacritical != string.Empty)
                {
                    result += pKeyProperties.Diacritical + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.IsNotEngraved)
                {
                    result += pKeyProperties.IsNotEngraved.ToString() + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.CharacterName != string.Empty)
                {
                    result += pKeyProperties.CharacterName + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.UnicodeId != string.Empty)
                {
                    result += pKeyProperties.UnicodeId + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.KeyWidth > 0)
                {
                    result += pKeyProperties.KeyWidth.ToString() + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.IsNumPad)
                {
                    result += pKeyProperties.IsNumPad.ToString() + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.HideL2)
                {
                    result += pKeyProperties.HideL2.ToString() + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.IsBold)
                {
                    result += pKeyProperties.IsBold.ToString() + "\t";
                }
                else
                {
                    result += "\t";
                };
                if (pKeyProperties.HAlign != string.Empty)
                {
                    result += pKeyProperties.HAlign + "\t";
                }
                else
                {
                    result += "\t";
                };
            }
            ;
            return(result);
        }