Beispiel #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            YogUILibrary.YogUI.YogUI_LoadContent(this);
            font = Content.Load<SpriteFont>("Console");

            //Create a new Text Field with position (top-left) at 0, 10. Width 100, height 20 (don't change this to anything else yet),
            //White text, Black background, White border, SpriteFont font, doing nothing on text enter, and nothing on text changed.
            textField = new TextField(new Vector2(0, 10), 200, 20, Color.Black, font, (string s) => { /*Pressed Enter*/ }, (string s) => { /*Text changed*/});
            textField.SetText("TextField");
            textField.placeHolderText = "Default text";
            textField.scaleToText = true;

            filterTextField = new TextField(new Vector2(330, 10), 150, 20, Color.Black, font, (string s) => { });
            filterTextField.stringPattern = "^\\d+?\\.\\d+?\\.\\d+?\\.\\d+?$";
            //Create a new ListBox at (0, 150), 90 width, 100 height, and doing nothing on Selected Index Changed.
            listBox = new ListBox(new Vector2(0, 150), 90, 100, font, () => { /*Selected Index Changed*/});
            listBox.dataSource = new string[] { "Index 1", "Index 2", "Index 3" }.ToList<string>();

            //Create a new ProgressBar at (150, 100), 100 width, 30 height, 50% progress.
            progressBar = new ProgressBar(new Vector2(150, 100), 100, 30, 50f);

            //Create a new sliderbar at (150, 150), 100 width, 30 height, 0 minimum value, 200 maximum value, SpriteFont font, 25% progress.
            sliderBar = new SliderBar(new Vector2(150, 150), 100, 30, 0, 200, font, 25);

            //Create two new radiobuttons
            radioButton1 = new RadioButton(new Vector2(200, 50), font, "RadioButton 1");
            radioButton2 = new RadioButton(new Vector2(200, 65), font, "Radiobutton 2");

            //Add the radiobuttons to a RadioButtonGroup that controls only one being "checked" at a time.
            radioButtonGroup.addButton(radioButton1);
            radioButtonGroup.addButton(radioButton2);

            //Create a new CheckBox at (200, 90), SpriteFont font.
            checkBox = new CheckBox(new Vector2(200, 90), font);

            //Create a new ComboBox at (500, 200), SpriteFont font.
            comboBox = new ComboBox(new Vector2(500, 200), font, "Combo box option 1", "Combo box option 2", "Combo box option 3");

            //Create a new button at (500, 100), with the text "Button", Adding a new item to the listbox when it is clicked, the text being from the TextField.
            button = new Button(new Vector2(500, 100), "Button", font, () => { listBox.dataSource.Add(textField.GetText()); });
            //   button.paddingHeight = 10;
            // button.paddingWidth = 200;
        }
Beispiel #2
0
 public void SetTextTest()
 {
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     float width = 0F; // TODO: Initialize to an appropriate value
     float height = 0F; // TODO: Initialize to an appropriate value
     Color textColor = new Color(); // TODO: Initialize to an appropriate value
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     Action<string> onTextEnter = null; // TODO: Initialize to an appropriate value
     Action<string> onTextChanged = null; // TODO: Initialize to an appropriate value
     TextField target = new TextField(position, width, height, textColor, font, onTextEnter, onTextChanged); // TODO: Initialize to an appropriate value
     string text = string.Empty; // TODO: Initialize to an appropriate value
     target.SetText(text);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }