Example #1
0
 public void bottomHeightTest()
 {
     NinePatch target = new NinePatch(); // TODO: Initialize to an appropriate value
     int actual;
     actual = target.bottomHeight;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #2
0
 public void DrawTest()
 {
     NinePatch target = new NinePatch(); // TODO: Initialize to an appropriate value
     SpriteBatch sb = null; // TODO: Initialize to an appropriate value
     Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value
     int contentWidth = 0; // TODO: Initialize to an appropriate value
     int contentHeight = 0; // TODO: Initialize to an appropriate value
     target.Draw(sb, position, contentWidth, contentHeight);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
Example #3
0
 public Button(Vector2 Position, string text, SpriteFont font, Action lambdaOnClick = null)
 {
     this.Position = Position;
     base.UIC_Initialize();
     this.lambdaOnClick = lambdaOnClick;
     td = new TextDrawer(font, text, Position, textColor, TextAlign.Center);
     patchNormal = YogUI.btn_normal;
     patchHover = YogUI.btn_hover;
     patchClick = YogUI.btn_hover;
 }
Example #4
0
 public void getCenterTest()
 {
     NinePatch target = new NinePatch(); // TODO: Initialize to an appropriate value
     int contentWidth = 0; // TODO: Initialize to an appropriate value
     int contentHeight = 0; // TODO: Initialize to an appropriate value
     Vector2 expected = new Vector2(); // TODO: Initialize to an appropriate value
     Vector2 actual;
     actual = target.getCenter(contentWidth, contentHeight);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #5
0
 public void NinePatchConstructorTest()
 {
     NinePatch target = new NinePatch();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Example #6
0
 public void LoadFromTextureTest()
 {
     NinePatch target = new NinePatch(); // TODO: Initialize to an appropriate value
     Texture2D texture = null; // TODO: Initialize to an appropriate value
     target.LoadFromTexture(texture);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
Example #7
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);
        }