Exemplo n.º 1
0
        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            DisplayText = DisplayText.Remove(DisplayText.Length - 1);

            if (DisplayText == "-")
            {
                DisplayText = "";
            }
        }
        private void DeleteCommandExecute()
        {
            if (_hasOperation)
            {
                return;
            }

            if (!String.IsNullOrWhiteSpace(DisplayText))
            {
                DisplayText = DisplayText.Remove(DisplayText.Length - 1);
                _newDisplay = DisplayText;
            }
        }
Exemplo n.º 3
0
        void ProcessBackKey()
        {
            string displayText;

            if (DisplayText.Length > 1 && !(DisplayText.Length == 2 && DisplayText[0] == '-'))
            {
                displayText = DisplayText.Remove(DisplayText.Length - 1, 1);
            }
            else
            {
                displayText    = "0";
                _showNewNumber = true;
            }

            DisplayText = displayText;
        }
Exemplo n.º 4
0
        private void btnPlusMin_Click(object sender, RoutedEventArgs e)
        {
            if (DisplayText.Length == 0)
            {
                return;
            }

            if (DisplayText[0] != '-')
            {
                DisplayText = "-" + DisplayText;
            }
            else
            {
                DisplayText = DisplayText.Remove(0, 1);
            }
        }
Exemplo n.º 5
0
        // Make this more compact and extendable
        public virtual void OnKeyboardPressed()
        {
            _isShift   = _myclsinput.isShiftPressed(Keyboard.GetState().GetPressedKeys());
            _isControl = _myclsinput.isControlPressed(Keyboard.GetState().GetPressedKeys());


            if (Singleton.Input.KeyReleased(Keys.A))
            {
                _keyboardString += _isShift ? "A" : "a";
                CreateText(); KeyboardEvents.Released();
            }

            ////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.Space))
            {
                _keyboardString += " ";
                CreateText(); KeyboardEvents.Released();
            }


            if (Singleton.Input.KeyReleased(Keys.B))
            {
                _keyboardString += _isShift ? "B" : "b";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.Z))
            {
                _keyboardString += _isShift ? "Z" : "z";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.C))
            {
                _keyboardString += _isShift ? "C" : "c";
                CreateText(); KeyboardEvents.Released();
            }

            ////////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D))
            {
                _keyboardString += _isShift ? "D" : "d";
                CreateText(); KeyboardEvents.Released();
            }
            ////////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.E))
            {
                _keyboardString += _isShift ? "E" : "e";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.F))
            {
                _keyboardString += _isShift ? "F" : "f";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.G))
            {
                _keyboardString += _isShift ? "G" : "g";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.H))
            {
                _keyboardString += _isShift ? "H" : "h";
                CreateText(); KeyboardEvents.Released();
            }
            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.I))
            {
                _keyboardString += _isShift ? "I" : "i";
                CreateText(); KeyboardEvents.Released();
            }
            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.J))
            {
                _keyboardString += _isShift ? "J" : "j";
                CreateText(); KeyboardEvents.Released();
            }
            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.K))
            {
                _keyboardString += _isShift ? "K" : "k";
                CreateText(); KeyboardEvents.Released();
            }
            if (Singleton.Input.KeyReleased(Keys.L))
            {
                _keyboardString += _isShift ? "L" : "l";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.M))
            {
                _keyboardString += _isShift ? "M" : "m";
                CreateText(); KeyboardEvents.Released();
            }
            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.N))
            {
                _keyboardString += _isShift ? "N" : "n";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.O))
            {
                _keyboardString += _isShift ? "O" : "o";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.P))
            {
                _keyboardString += _isShift ? "P" : "p";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.Q))
            {
                _keyboardString += _isShift ? "Q" : "q";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.R))
            {
                _keyboardString += _isShift ? "R" : "r";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.S))
            {
                _keyboardString += _isShift ? "S" : "s";
                CreateText(); KeyboardEvents.Released();
            }
            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.T))
            {
                _keyboardString += _isShift ? "T" : "t";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.U))
            {
                _keyboardString += _isShift ? "U" : "u";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.V))
            {
                _keyboardString += _isShift ? "V" : "v";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.W))
            {
                _keyboardString += _isShift ? "W" : "w";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.Y))
            {
                _keyboardString += _isShift ? "Y" : "y";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.X))
            {
                _keyboardString += _isShift ? "X" : "x";
                CreateText(); KeyboardEvents.Released();
            }

            /////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemSemicolon))
            {
                _keyboardString += _isShift ? ":" : ";";
                CreateText(); KeyboardEvents.Released();
            }

            /////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemQuotes))
            {
                _keyboardString += _isShift ? "\"" : "'";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemComma))
            {
                _keyboardString += _isShift ? "<" : ",";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemPeriod))
            {
                _keyboardString += _isShift ? ">" : ".";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemQuestion))
            {
                _keyboardString += _isShift ? "?" : "/";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemOpenBrackets))
            {
                _keyboardString += _isShift ? "{" : "[";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemCloseBrackets))
            {
                _keyboardString += _isShift ? "}" : "]";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemPipe))
            {
                _keyboardString += _isShift ? "|" : "\\";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D1))
            {
                _keyboardString += _isShift ? "!" : "1";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D2))
            {
                _keyboardString += _isShift ? "@" : "2";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D3))
            {
                _keyboardString += _isShift ? "#" : "3";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D4))
            {
                _keyboardString += _isShift ? "$" : "4";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D5))
            {
                _keyboardString += _isShift ? "%" : "5";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D6))
            {
                _keyboardString += _isShift ? "^" : "6";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D7))
            {
                _keyboardString += _isShift ? "&" : "7";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D8))
            {
                _keyboardString += _isShift ? "*" : "8";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D9))
            {
                _keyboardString += _isShift ? "(" : "9";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.D0))
            {
                _keyboardString += _isShift ? ")" : "0";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemTilde))
            {
                _keyboardString += _isShift ? "~" : "`";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemMinus))
            {
                _keyboardString += _isShift ? "_" : "-";
                CreateText(); KeyboardEvents.Released();
            }

            ///////////////////////////////////////////////////////////
            if (Singleton.Input.KeyReleased(Keys.OemPlus))
            {
                _keyboardString += _isShift ? "+" : "=";
                CreateText(); KeyboardEvents.Released();
            }

            if (Singleton.Input.CurrentKey != Keys.None)
            {
                // ToDo
            }

            if (Singleton.Input.KeyReleased(Keys.Enter))
            {
                if (_myclsinput.EnterKeyState == "down")
                {
                    _myclsinput.EnterKeyState = "none";
                }
            }
            if (Singleton.Input.KeyReleased(Keys.Back))
            {
                if (!string.IsNullOrEmpty(_keyboardString))
                {
                    CurrItemRect = CharBucket.CurrentItemRectangle;

                    _keyboardString = _keyboardString.Remove(_keyboardString.Length - 1, 1);
                    int startIndex = _keyboardString.Length - DisplayText.Length;

                    if (IsOutOfBounds(TextSize.X) && startIndex >= 0)
                    {
                        string newChar = _keyboardString.Substring(startIndex, 1);
                        DisplayText = DisplayText.Insert(0, newChar);
                        DisplayText = DisplayText.Remove(DisplayText.Length - 1, 1);
                        startIndex--;
                        if (startIndex >= 0)
                        {
                            string extraChar = _keyboardString.Substring(startIndex, 1);
                            string tmp       = DisplayText.Insert(0, newChar);
                            float  newSize   = tmp.Size(TextFont).X - extraChar.Size(TextFont).X;
                            if (!IsOutOfBounds(newSize))
                            {
                                DisplayText = tmp;
                            }
                        }

                        RearrangeBox();
                    }
                    else
                    {
                        DisplayText = DisplayText.Remove(DisplayText.Length - 1, 1);
                    }

                    CharBucket.RemoveCharacter();
                }
                KeyboardEvents.Released();
            }
        }