public void BoundBoxTest() { Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value SpriteFont font = null; // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value Action lambdaTextEnter = null; // TODO: Initialize to an appropriate value string input = string.Empty; // TODO: Initialize to an appropriate value Action lambdaTextChanged = null; // TODO: Initialize to an appropriate value TextInput target = new TextInput(position, font, color, lambdaTextEnter, input, lambdaTextChanged); // TODO: Initialize to an appropriate value Rectangle actual; actual = target.BoundBox; Assert.Inconclusive("Verify the correctness of this test method."); }
public void CopyTest() { Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value SpriteFont font = null; // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value Action lambdaTextEnter = null; // TODO: Initialize to an appropriate value string input = string.Empty; // TODO: Initialize to an appropriate value Action lambdaTextChanged = null; // TODO: Initialize to an appropriate value TextInput target = new TextInput(position, font, color, lambdaTextEnter, input, lambdaTextChanged); // TODO: Initialize to an appropriate value target.Copy(); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void TextInputConstructorTest() { Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value SpriteFont font = null; // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value Action lambdaTextEnter = null; // TODO: Initialize to an appropriate value string input = string.Empty; // TODO: Initialize to an appropriate value Action lambdaTextChanged = null; // TODO: Initialize to an appropriate value TextInput target = new TextInput(position, font, color, lambdaTextEnter, input, lambdaTextChanged); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void getFixedSelectionTest() { Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value SpriteFont font = null; // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value Action lambdaTextEnter = null; // TODO: Initialize to an appropriate value string input = string.Empty; // TODO: Initialize to an appropriate value Action lambdaTextChanged = null; // TODO: Initialize to an appropriate value TextInput target = new TextInput(position, font, color, lambdaTextEnter, input, lambdaTextChanged); // TODO: Initialize to an appropriate value Vector2 expected = new Vector2(); // TODO: Initialize to an appropriate value Vector2 actual; actual = target.getFixedSelection(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public TextField(Vector2 position, float width, float height, Color textColor, SpriteFont font, Action <string> onTextEnter, Action <string> onTextChanged = null) { patchSelected = YogUI.textField_selected; patchSelectedRight = YogUI.textField_selected_right; patchSelectedWrong = YogUI.textField_selected_wrong; patchNormal = YogUI.textField_normal; this.Position = position; this.width = width; this.height = height; input = new TextInput(new Vector2(position.X + 2, position.Y), font, textColor, () => { TextEnter(); }, "", () => { TextChanged(); }); this.textColor = textColor; this.onTextEnter = onTextEnter; this.onTextChanged = onTextChanged; contextMenu = new DropDownList(Vector2.Zero, font); contextMenu.AddItem(new DropDownItem("Copy", input.Copy)); contextMenu.AddItem(new DropDownItem("Paste", input.Paste)); contextMenu.AddItem(new DropDownItem("Cut", input.Cut)); base.UIC_Initialize(); input.allowedWidth = allowedWidth(); InputManager.BindMouse(() => { input.selected = hovering; if (!hovering) { return; } float xDist = InputManager.GetMousePos().X - input.BoundBox.Left; string offset = input.offsetText; int maxBelow = offset.Length; string cur = ""; for (int i = 0; i < offset.Length; i++) { cur += offset[i]; float xWidth = input.tdI.font.MeasureString(cur).X; if (xWidth < xDist) { maxBelow = i + 1; } if (xDist < xWidth && i == 0) { maxBelow = 0; break; } if (xWidth >= xDist) { break; } } int pos = maxBelow; pos += input.offset; input.cursorPos = pos; input.selectionStart = pos; input.selectionEnd = -1; if (hovering) { dragging = true; } }, MouseButton.Left); InputManager.BindMouse(() => { dragging = false; }, MouseButton.Left, false); InputManager.BindMouse(() => { if (dragging) { float xDist = InputManager.GetMousePos().X - input.BoundBox.Left; string offset = input.offsetText; int maxBelow = offset.Length; string cur = ""; for (int i = 0; i < offset.Length; i++) { cur += offset[i]; float xWidth = input.tdI.font.MeasureString(cur).X; if (xWidth < xDist) { maxBelow = i + 1; } if (xDist < xWidth && i == 0) { maxBelow = 0; break; } if (xWidth >= xDist) { break; } } if (xDist < 0) { input.offset += -1; if (input.offset < 0) { input.offset = 0; } } if (xDist > input.BoundBox.Width) { input.offset += 1; if (input.offset > input.input.Length - offset.Length) { input.offset = input.input.Length - offset.Length; } } int pos = maxBelow; pos += input.offset; input.selectionEnd = pos; input.cursorPos = pos; } }, MouseButton.Movement, true, true); InputManager.BindMouse(() => { input.selected = hovering; if (hovering) { contextMenu.Position = InputManager.GetMousePosV() - new Vector2(3); contextMenu.Show(); } }, MouseButton.Right); }
public TextField(Vector2 position, float width, float height, Color textColor, SpriteFont font, Action<string> onTextEnter, Action<string> onTextChanged = null) { patchSelected = YogUI.textField_selected; patchSelectedRight = YogUI.textField_selected_right; patchSelectedWrong = YogUI.textField_selected_wrong; patchNormal = YogUI.textField_normal; this.Position = position; this.width = width; this.height = height; input = new TextInput(new Vector2(position.X + 2, position.Y), font, textColor, () => { TextEnter(); }, "", () => { TextChanged(); }); this.textColor = textColor; this.onTextEnter = onTextEnter; this.onTextChanged = onTextChanged; contextMenu = new DropDownList(Vector2.Zero, font); contextMenu.AddItem(new DropDownItem("Copy", input.Copy)); contextMenu.AddItem(new DropDownItem("Paste", input.Paste)); contextMenu.AddItem(new DropDownItem("Cut", input.Cut)); base.UIC_Initialize(); input.allowedWidth = allowedWidth(); InputManager.BindMouse(() => { input.selected = hovering; if (!hovering) return; float xDist = InputManager.GetMousePos().X - input.BoundBox.Left; string offset = input.offsetText; int maxBelow = offset.Length; string cur = ""; for (int i = 0; i < offset.Length; i++) { cur += offset[i]; float xWidth = input.tdI.font.MeasureString(cur).X; if (xWidth < xDist) { maxBelow = i + 1; } if (xDist < xWidth && i == 0) { maxBelow = 0; break; } if (xWidth >= xDist) break; } int pos = maxBelow; pos += input.offset; input.cursorPos = pos; input.selectionStart = pos; input.selectionEnd = -1; if (hovering) dragging = true; }, MouseButton.Left); InputManager.BindMouse(() => { dragging = false; }, MouseButton.Left, false); InputManager.BindMouse(() => { if (dragging) { float xDist = InputManager.GetMousePos().X - input.BoundBox.Left; string offset = input.offsetText; int maxBelow = offset.Length; string cur = ""; for (int i = 0; i < offset.Length; i++) { cur += offset[i]; float xWidth = input.tdI.font.MeasureString(cur).X; if (xWidth < xDist) { maxBelow = i + 1; } if (xDist < xWidth && i == 0) { maxBelow = 0; break; } if(xWidth >= xDist) break; } if (xDist < 0) { input.offset += -1; if (input.offset < 0) input.offset = 0; } if (xDist > input.BoundBox.Width) { input.offset += 1; if (input.offset > input.input.Length - offset.Length) input.offset = input.input.Length - offset.Length; } int pos = maxBelow; pos += input.offset; input.selectionEnd = pos; input.cursorPos = pos; } }, MouseButton.Movement, true, true); InputManager.BindMouse(() => { input.selected = hovering; if (hovering) { contextMenu.Position = InputManager.GetMousePosV() - new Vector2(3); contextMenu.Show(); } }, MouseButton.Right); }