public void Update(InputDecorator inputField)
        {
            IInputManager input = new InputManager();

            if (input.GetKeyboardState().GetPressedKeys().Length == 0)
            {
                return;
            }

            var keyPressed = input.GetKeyboardState().GetPressedKeys()[0];

            switch (keyPressed)
            {
            case Keys.Space:
                inputField.Text.Insert(inputField.Cursor, ' ');
                break;

            case Keys.Back:
                if (inputField.Text.Count == 0)
                {
                    break;
                }
                inputField.Text.RemoveAt(inputField.Cursor - 1);
                inputField.Cursor--;
                break;

            default:
                inputField.Text.Insert(inputField.Cursor, Convert.ToChar(keyPressed.ToString()));
                inputField.Cursor++;
                break;
            }
        }
        public void Draw(InputDecorator inputField) {
            spriteBatch.Begin();
            Texture2D rect = new Texture2D(spriteBatch.GraphicsDevice, inputField.Width, 20);
            Color[] colorData = new Color[rect.Width * rect.Height];

            for (int i = 0; i < rect.Height * rect.Width; i++) {
                colorData[i] = Color.White;
            }

            rect.SetData(colorData);

            spriteBatch.Draw(rect, new Rectangle((int)inputField.GetPosition().X, (int)inputField.GetPosition().Y, rect.Width, rect.Height), Color.White);
            spriteBatch.DrawString(Game1.font, CharsToString(inputField.Content), inputField.GetPosition(), Color.Black);
            spriteBatch.End();
        }
        public void Draw(InputDecorator input)
        {
            spriteBatch.Begin();
            Color[] colorData = new Color[input.Texture.Width * input.Texture.Height];

            for (int i = 0; i < input.Texture.Height * input.Texture.Width; i++)
            {
                colorData[i] = input.BackgroundColor;
            }

            input.Texture.SetData(colorData);
            spriteBatch.Draw(input.Texture, new Rectangle((int)input.GetPosition().X, (int)input.GetPosition().Y, (int)input.Texture.Width, (int)input.Texture.Height), input.BackgroundColor);
            spriteBatch.DrawString(Game1.Font, CharsToString(input.Text), input.GetPosition(), input.TextColor);
            spriteBatch.End();
        }
        public void Update(InputDecorator inputField) {
            counter++;
            Keys[] pressedKeys = Game1.keyboardState.GetPressedKeys();
            if (counter > 3) {
                if (pressedKeys.Length > 0)
                    if (pressedKeys[0] == Keys.Space)
                        inputField.Content.Add(' ');
                    else if (pressedKeys[0] == Keys.Back) {
                        if (inputField.Content.Count > 0)
                            inputField.Content.RemoveAt(inputField.Content.Count - 1);
                    }
                    else
                        inputField.Content.Add(pressedKeys[0].ToString().ToLower().ToCharArray()[0]);

                counter = 0;
            }
        }
Exemple #5
0
        InteractiveInkFeature _createInkFeature(Offset globalPosition)
        {
            MaterialInkController inkController   = Material.of(this.context);
            ThemeData             themeData       = Theme.of(this.context);
            BuildContext          editableContext = this._editableTextKey.currentContext;
            RenderBox             referenceBox    =
                (RenderBox)(InputDecorator.containerOf(editableContext) ?? editableContext.findRenderObject());
            Offset position = referenceBox.globalToLocal(globalPosition);
            Color  color    = themeData.splashColor;

            InteractiveInkFeature splash = null;

            void handleRemoved()
            {
                if (this._splashes != null)
                {
                    D.assert(this._splashes.Contains(splash));
                    this._splashes.Remove(splash);
                    if (this._currentSplash == splash)
                    {
                        this._currentSplash = null;
                    }

                    this.updateKeepAlive();
                } // else we're probably in deactivate()
            }

            splash = themeData.splashFactory.create(
                controller: inkController,
                referenceBox: referenceBox,
                position: position,
                color: color,
                containedInkWell: true,
                borderRadius: BorderRadius.zero,
                onRemoved: handleRemoved
                );

            return(splash);
        }
Exemple #6
0
 public void Visit(InputDecorator input)
 {
     adapter.Update(input);
 }
 public void Update(InputDecorator inputField)
 {
     throw new NotImplementedException();
 }
 public void Draw(InputDecorator textField)
 {
     throw new NotImplementedException();
 }
 public void Visit(InputDecorator input)
 {
     adapter.Draw(input);
 }