Пример #1
0
 public void CalculateDimensionsTest()
 {
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     DropDownList target = new DropDownList(position, font); // TODO: Initialize to an appropriate value
     target.CalculateDimensions();
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
Пример #2
0
 public void BoundBoxTest()
 {
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     DropDownList target = new DropDownList(position, font); // TODO: Initialize to an appropriate value
     Rectangle actual;
     actual = target.BoundBox;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #3
0
        public ComboBox(Vector2 position, SpriteFont font, params string[] items)
        {
            Position = position;
            drop = new DropDownList(position + new Vector2((-width - 15), height / 2), font);
            label = new TextDrawer(font, "", position, Color.White, TextAlign.Center);
            drop.Hide();
            foreach (string item in items)
            {
                drop.AddItem(new Structs.DropDownItem(item, () => { updateSelected(); }));
            }
            if (items.Length > 0)
                selectedIndex = -1;

            base.UIC_Initialize();
        }
Пример #4
0
 public void DropDownListConstructorTest()
 {
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     SpriteFont font = null; // TODO: Initialize to an appropriate value
     DropDownList target = new DropDownList(position, font);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Пример #5
0
        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);
        }