Esempio n. 1
0
      public Key(Xkey key, int iwidth, GUIKeyboard kb)
      {
        xKey = key;
        dwWidth = iwidth;

        // Create a button control template.
        if (button != null)
        {
          button.Dispose();
        }
        button = new GUIButtonControl(kb.GetID, -1, 0, 0, 0, 0, kb._keyTextureFocus, kb._keyTextureNoFocus,
                                      kb._keyTextShadowAngle, kb._keyTextShadowDistance, kb._keyTextShadowColor);

        button.SetBorderTF(
          kb._strBorderKTF,
          kb._borderPositionKTF,
          kb._borderTextureRepeatKTF,
          kb._borderTextureRotateKTF,
          kb._borderTextureFileNameKTF,
          kb._borderColorKeyKTF,
          kb._borderHasCornersKTF,
          kb._borderCornerTextureRotateKTF);

        button.SetBorderTNF(
          kb._strBorderKTNF,
          kb._borderPositionKTNF,
          kb._borderTextureRepeatKTNF,
          kb._borderTextureRotateKTNF,
          kb._borderTextureFileNameKTNF,
          kb._borderColorKeyKTNF,
          kb._borderHasCornersKTNF,
          kb._borderCornerTextureRotateKTNF);

        button.AllocResources();

        // Special keys get their own names
        switch (xKey)
        {
          case Xkey.XK_SPACE:
            name = "SPACE";
            break;
          case Xkey.XK_BACKSPACE:
            name = "BKSP";
            break;
          case Xkey.XK_SHIFT:
            name = "SHIFT";
            break;
          case Xkey.XK_CAPSLOCK:
            name = "CAPS";
            break;
          case Xkey.XK_ALPHABET:
            name = "ALPHABET";
            break;
          case Xkey.XK_SYMBOLS:
            name = "SYMB";
            break;
          case Xkey.XK_ACCENTS:
            name = "ACCENTS";
            break;
          case Xkey.XK_SMS:
            name = "SMS";
            break;
          case Xkey.XK_OK:
            name = GUILocalizeStrings.Get(804);
            break;
          case Xkey.XK_SEARCH_CONTAINS:
            name = GUILocalizeStrings.Get(801);
            break;
          case Xkey.XK_SEARCH_ENDS_WITH:
            name = GUILocalizeStrings.Get(802);
            break;
          case Xkey.XK_SEARCH_START_WITH:
            name = GUILocalizeStrings.Get(800);
            break;
          case Xkey.XK_SEARCH_IS:
            name = GUILocalizeStrings.Get(803);
            break;
          case Xkey.XK_SMS0:
            name = "0 [ ]";
            break;
        }
      }
Esempio n. 2
0
    protected void Press(Xkey xk)
    {
      ClearLabelAsInitialText();

      if (xk == Xkey.XK_NULL) // happens in Japanese keyboard (keyboard type)
      {
        xk = Xkey.XK_SPACE;
      }

      // If the key represents a character, add it to the word
      if (((uint)xk) < 0x10000 && xk != Xkey.XK_ARROWLEFT && xk != Xkey.XK_ARROWRIGHT)
      {
        // Don't add more than the maximum characters, and don't allow 
        // text to exceed the width of the text entry field
        if (_textEntered.Length < MAX_CHARS)
        {
          float fWidth = 0, fHeight = 0;
          _fontCharKey.GetTextExtent(_textEntered, ref fWidth, ref fHeight);

          if (fWidth < (GUIGraphicsContext.ScaleHorizontal((int) fTextBoxWidth)))
          {
            if (_position >= _textEntered.Length)
            {
              _textEntered += GetChar(xk);
              if (TextChanged != null)
              {
                TextChanged(_searchKind, _textEntered);
              }
            }
            else
            {
              _textEntered = _textEntered.Insert(_position, GetChar(xk));
              if (TextChanged != null)
              {
                TextChanged(_searchKind, _textEntered);
              }
            }
            ++_position; // move the caret
          }
        }

        // Unstick the shift key
        _shiftTurnedOn = false;
      }

        // Special cases
      else
      {
        switch (xk)
        {
          case Xkey.XK_BACKSPACE:
            if (_position > 0)
            {
              --_position; // move the caret
              _textEntered = _textEntered.Remove(_position, 1);
              if (TextChanged != null)
              {
                TextChanged(_searchKind, _textEntered);
              }
            }
            break;
          case Xkey.XK_DELETE: // Used for Japanese only
            if (_textEntered.Length > 0)
            {
              _textEntered = _textEntered.Remove(_position, 1);
              if (TextChanged != null)
              {
                TextChanged(_searchKind, _textEntered);
              }
            }
            break;
          case Xkey.XK_SHIFT:
            _shiftTurnedOn = !_shiftTurnedOn;
            break;
          case Xkey.XK_CAPSLOCK:
            _capsLockTurnedOn = !_capsLockTurnedOn;
            break;
          case Xkey.XK_ALPHABET:
            _currentKeyboard = KeyboardTypes.TYPE_ALPHABET;
            break;
          case Xkey.XK_SYMBOLS:
            _currentKeyboard = KeyboardTypes.TYPE_SYMBOLS;
            break;
          case Xkey.XK_ACCENTS:
            _currentKeyboard = KeyboardTypes.TYPE_ACCENTS;
            break;
          case Xkey.XK_SMS:
            //_useSmsStyleTextInsertion = !_useSmsStyleTextInsertion;
            SmsStyleText = !SmsStyleText;
            break;
          case Xkey.XK_ARROWLEFT:
            if (_position > 0)
            {
              --_position;
            }
            break;
          case Xkey.XK_ARROWRIGHT:
            if (_position < _textEntered.Length)
            {
              ++_position;
            }
            break;
          case Xkey.XK_OK:
            Close();
            _pressedEnter = true;
            break;
            // added to the original code VirtualKeyboard.cs
            // by Agree
            // starts here...

          case Xkey.XK_SEARCH_IS:
            _searchKind = (int)SearchKinds.SEARCH_STARTS_WITH;
            SetSearchKind();
            break;

          case Xkey.XK_SEARCH_CONTAINS:
            _searchKind = (int)SearchKinds.SEARCH_ENDS_WITH;
            SetSearchKind();
            break;

          case Xkey.XK_SEARCH_ENDS_WITH:
            _searchKind = (int)SearchKinds.SEARCH_IS;
            SetSearchKind();
            break;

          case Xkey.XK_SEARCH_START_WITH:
            _searchKind = (int)SearchKinds.SEARCH_CONTAINS;
            SetSearchKind();
            break;
            // code by Agree ends here
            //

          case Xkey.XK_SMS0:
            ProcessSmsInsertion(0);
            break;
          case Xkey.XK_SMS1:
            ProcessSmsInsertion(1);
            break;
          case Xkey.XK_SMS2:
            ProcessSmsInsertion(2);
            break;
          case Xkey.XK_SMS3:
            ProcessSmsInsertion(3);
            break;
          case Xkey.XK_SMS4:
            ProcessSmsInsertion(4);
            break;
          case Xkey.XK_SMS5:
            ProcessSmsInsertion(5);
            break;
          case Xkey.XK_SMS6:
            ProcessSmsInsertion(6);
            break;
          case Xkey.XK_SMS7:
            ProcessSmsInsertion(7);
            break;
          case Xkey.XK_SMS8:
            ProcessSmsInsertion(8);
            break;
          case Xkey.XK_SMS9:
            ProcessSmsInsertion(9);
            break;
        }
      }
    }
Esempio n. 3
0
    protected string GetChar(Xkey xk)
    {
      string smsResult = string.Empty;
      switch (xk)
      {
        case Xkey.XK_SMS1:
          smsResult = "1 (.!?)";
          break;
        case Xkey.XK_SMS2:
          smsResult = "2 (abc)";
          break;
        case Xkey.XK_SMS3:
          smsResult = "3 (def)";
          break;
        case Xkey.XK_SMS4:
          smsResult = "4 (ghi)";
          break;
        case Xkey.XK_SMS5:
          smsResult = "5 (jkl)";
          break;
        case Xkey.XK_SMS6:
          smsResult = "6 (mno)";
          break;
        case Xkey.XK_SMS7:
          smsResult = "7 (pqrs)";
          break;
        case Xkey.XK_SMS8:
          smsResult = "8 (tuv)";
          break;
        case Xkey.XK_SMS9:
          smsResult = "9 (wxyz)";
          break;
      }

      if (!string.IsNullOrEmpty(smsResult))
      {
        if ((_capsLockTurnedOn && !_shiftTurnedOn) || (!_capsLockTurnedOn && _shiftTurnedOn))
        {
          return smsResult.ToUpperInvariant();
        }
        else
        {
          return smsResult.ToLowerInvariant();
        }
      }
      
      // Handle case conversion
      char wc = (char)(((uint)xk) & 0xffff);

      if ((_capsLockTurnedOn && !_shiftTurnedOn) || (!_capsLockTurnedOn && _shiftTurnedOn))
      {
        wc = Char.ToUpper(wc);
      }
      else
      {
        wc = Char.ToLower(wc);
      }

      return wc.ToString();
    }
        private void ExecuteCapsCommand()
        {
            if (caps == false)
            {
                caps         = true;
                CapsEnabled  = true;
                CapsDisabled = false;

                Akey = Akey.ToUpper();
                Bkey = Bkey.ToUpper();
                Ckey = Ckey.ToUpper();
                Dkey = Dkey.ToUpper();
                Ekey = Ekey.ToUpper();
                Fkey = Fkey.ToUpper();
                Gkey = Gkey.ToUpper();
                Hkey = Hkey.ToUpper();
                Ikey = Ikey.ToUpper();
                Jkey = Jkey.ToUpper();
                Kkey = Kkey.ToUpper();
                Lkey = Lkey.ToUpper();
                Mkey = Mkey.ToUpper();
                Nkey = Nkey.ToUpper();
                Okey = Okey.ToUpper();
                Pkey = Pkey.ToUpper();
                Qkey = Qkey.ToUpper();
                Rkey = Rkey.ToUpper();
                Skey = Skey.ToUpper();
                Tkey = Tkey.ToUpper();
                Vkey = Vkey.ToUpper();
                Ukey = Ukey.ToUpper();
                Wkey = Wkey.ToUpper();
                Xkey = Xkey.ToUpper();
                Ykey = Ykey.ToUpper();
                Zkey = Zkey.ToUpper();
            }
            else
            {
                caps         = false;
                CapsEnabled  = false;
                CapsDisabled = true;
                Akey         = Akey.ToLower();
                Bkey         = Bkey.ToLower();
                Ckey         = Ckey.ToLower();
                Dkey         = Dkey.ToLower();
                Ekey         = Ekey.ToLower();
                Fkey         = Fkey.ToLower();
                Gkey         = Gkey.ToLower();
                Hkey         = Hkey.ToLower();
                Ikey         = Ikey.ToLower();
                Jkey         = Jkey.ToLower();
                Kkey         = Kkey.ToLower();
                Lkey         = Lkey.ToLower();
                Mkey         = Mkey.ToLower();
                Nkey         = Nkey.ToLower();
                Okey         = Okey.ToLower();
                Pkey         = Pkey.ToLower();
                Qkey         = Qkey.ToLower();
                Rkey         = Rkey.ToLower();
                Skey         = Skey.ToLower();
                Tkey         = Tkey.ToLower();
                Vkey         = Vkey.ToLower();
                Ukey         = Ukey.ToLower();
                Wkey         = Wkey.ToLower();
                Xkey         = Xkey.ToLower();
                Ykey         = Ykey.ToLower();
                Zkey         = Zkey.ToLower();
            }
        }