Esempio n. 1
0
    /// <summary>
    /// Handles a selected key.
    /// </summary>
    /// <param name="tapped">The key that was tapped.</param>
    public void HandleTap(KeyboardItem tapped)
    {
        string value = tapped.Value;

        if (value.Equals(Keys.QEH) || value.Equals(Keys.ABC))
        {
            SwitchSpecialKeys();
        }
        else if (value.Equals(Keys.UP) || value.Equals(Keys.LOW))
        {
            SwitchUpperAndLowerKeys();
        }
        else if (value.Equals(Keys.SPACE))
        {
            Output.OnKey(Keys.SPACE);
        }
        else if (value.Equals(Keys.BACK))
        {
            Output.OnBack();
        }
        else
        {
            Output.OnKey(value);
        }
    }
Esempio n. 2
0
 private Vector3 RestorePosition(KeyboardItem key)
 {
     return(new Vector3(
                key.transform.localPosition.x,
                key.transform.localPosition.y,
                key.transform.localPosition.z - distanceToCenter + RADIUS));
 }
Esempio n. 3
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="elementName"></param>
            /// <param name="elementValue"></param>
            /// <param name="attributes"></param>
            public void endElement(String elementName, String elementValue, NameValueCollection attributes)
            {
                if (elementName == ConstInterface.MG_TAG_KBDITM)
                {
                    List <KeyboardItem> kbdItemArray = null;
                    Int32     arrayKey;
                    int       actionId = 0;
                    int       keyCode  = 0;
                    Modifiers modifier = Modifiers.MODIFIER_NONE;
                    int       states   = 0;

                    IEnumerator enumerator = attributes.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        String attr = (String)enumerator.Current;
                        switch (attr)
                        {
                        case ConstInterface.MG_ATTR_ACTIONID:
                            actionId = Int32.Parse(attributes[attr]);
                            break;

                        case ConstInterface.MG_ATTR_KEYCODE:
                            keyCode = Int32.Parse(attributes[attr]);
                            break;

                        case ConstInterface.MG_ATTR_MODIFIER:
                            //modifier = (Modifiers)valueStr[0];
                            modifier = (Modifiers)(attributes[attr])[0];
                            break;

                        case ConstInterface.MG_ATTR_STATES:
                            states = Int32.Parse(attributes[attr]);
                            break;

                        default:
                            Logger.Instance.WriteExceptionToLog(
                                "There is no such tag in KeyboardItem class. Insert case to KeyboardItem.initElements() for: " +
                                attr);
                            break;
                        }
                    }
                    KeyboardItem kbdItm = new KeyboardItem(actionId, keyCode, modifier, states);
                    arrayKey     = _enclosingInstance.getKeyboardItemHashCode(kbdItm.getKeyCode(), kbdItm.getModifier());
                    kbdItemArray = (List <KeyboardItem>)_enclosingInstance._kbdMap[arrayKey];
                    if (kbdItemArray == null)
                    {
                        kbdItemArray = new List <KeyboardItem>();
                        _enclosingInstance._kbdMap[arrayKey] = kbdItemArray;
                    }
                    kbdItemArray.Add(kbdItm);
                }
                // It should come in this function only for KbdMap tag or for Kbditm tag..For other tags we should write error to log
                else if (elementName != ConstInterface.MG_TAG_KBDMAP)
                {
                    Logger.Instance.WriteExceptionToLog("There is no such tag in FontTable.endElement(): " + elementName);
                }
            }
Esempio n. 4
0
 public void HandleClick(KeyboardItem clicked)
 {
     // string value = clicked.GetLetter();
     // if (value.Equals(QEH) || value.Equals(ABC))// special signs pressed
     //     ChangeSpecialLetters();
     // else if (value.Equals(UP) || value.Equals(LOW)) // upper/lower case pressed
     //     LowerUpperKeys();
     // else if (value.Equals(SPACE))
     //     TypeKey(BLANKSPACE);
     // else if (value.Equals(BACK))
     //     BackspaceKey();
     // else// Normal letter
     //     TypeKey(value[0]);
 }
Esempio n. 5
0
    private void SetKeyPosition(KeyboardItem key)
    {
        int       iteration    = key.Index;
        Transform keyTransform = key.transform;
        // Check row and how many keys were placed
        float keysPlaced = CalculateKeyOffsetAndRow(iteration);
        float degree     = CalculateKeyRotation(Keys.LettersInRowsCount[row] - 1, iteration - keysPlaced);

        //caluclate position on cylinder with circle equation formula
        //http://www.mathopenref.com/coordparamcircle.html
        key.transform.localPosition = CalculatePositionOnCylinder(degree);
        //rotate keys by their placement angle
        key.transform.localEulerAngles = new Vector3(0, -degree * Mathf.Rad2Deg - 90f, 0);
        // keys are moved from center couse of increasing circle radius,
        // so position must be restored to radius
        key.transform.localPosition = RestorePosition(key);
    }
Esempio n. 6
0
 private void SetKeySize(KeyboardItem key)
 {
     key.transform.localScale = new Vector3(KEY_SIZE, KEY_SIZE, 0.1f);
 }
Esempio n. 7
0
        /// <summary>
        ///   This method returns the list of menu entries with access key
        /// </summary>
        public List <MenuEntry> getMenuEntriesWithAccessKey(KeyboardItem kbdItem)
        {
            String key = "" + kbdItem.getKeyCode() + kbdItem.getModifier();

            return((List <MenuEntry>)_menuEntriesWithAccessKey[key]);
        }