public SliderBar(Vector2 position, float width, float height, int min, int max, SpriteFont font, float progress = 0.0f) { this.width = width; this.height = height; this.min = min; this.max = max; progressBar = new ProgressBar(position, width, height, progress); Vector2 center = new Vector2((int)(position.X + (width / 2)), (int)(position.Y + (height / 2))); progressText = new TextDrawer(font, "", center, Color.White, TextAlign.Center); InputManager.BindMouse(() => { Point mousePoint = InputManager.GetMousePos(); Vector2 mouseVector = new Vector2(mousePoint.X, mousePoint.Y); if ((progressBar.BoundBox.Contains(mousePoint) || selected) && !selectedOutside) { int dist = (int)(mousePoint.X - progressBar.BoundBox.Left); float p = (dist / progressBar.width) * 100; p = (p > 0) ? (p < 100) ? p : 100 : 0; progressBar.setProgress(p); selected = true; } else { selectedOutside = true; } }, MouseButton.Left, true, true); InputManager.BindMouse(() => { selected = false; selectedOutside = false; }, MouseButton.Left, false); }
public void BoundBoxTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); // TODO: Initialize to an appropriate value Rectangle actual; actual = target.BoundBox; Assert.Inconclusive("Verify the correctness of this test method."); }
public void addProgressTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); // TODO: Initialize to an appropriate value float amount = 0F; // TODO: Initialize to an appropriate value target.addProgress(amount); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
/// <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; }
public void getProgressTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); // TODO: Initialize to an appropriate value float expected = 0F; // TODO: Initialize to an appropriate value float actual; actual = target.getProgress(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void DrawTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); // TODO: Initialize to an appropriate value SpriteBatch sb = null; // TODO: Initialize to an appropriate value target.Draw(sb); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void UpdateTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); // TODO: Initialize to an appropriate value GameTime time = null; // TODO: Initialize to an appropriate value target.Update(time); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void setBorderColorTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value target.setBorderColor(color); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void ProgressBarConstructorTest() { 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 float progress = 0F; // TODO: Initialize to an appropriate value ProgressBar target = new ProgressBar(position, width, height, progress); Assert.Inconclusive("TODO: Implement code to verify target"); }