public ListBoxPage() : base("List Box Widget") { FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); leftToRightLayout.AnchorAll(); { { leftListBox = new ListBox(new RectangleDouble(0, 0, 200, 300)); //leftListBox.BackgroundColor = RGBA_Bytes.Red; leftListBox.Name = "LeftListBox"; leftListBox.VAnchor = UI.VAnchor.ParentTop; //leftListBox.DebugShowBounds = true; leftListBox.Margin = new BorderDouble(15); leftToRightLayout.AddChild(leftListBox); for (int i = 0; i < 1; i++) { leftListBox.AddChild(new ListBoxTextItem("hand" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl")); } } if (true) { ListBox rightListBox = new ListBox(new RectangleDouble(0, 0, 200, 300)); rightListBox.VAnchor = UI.VAnchor.ParentTop; rightListBox.Margin = new BorderDouble(15); leftToRightLayout.AddChild(rightListBox); for (int i = 0; i < 30; i++) { switch (i % 3) { case 0: rightListBox.AddChild(new ListBoxTextItem("ListBoxTextItem" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl")); break; case 1: rightListBox.AddChild(new Button("Button" + i.ToString() + ".stl")); break; case 2: rightListBox.AddChild(new RadioButton("RadioButton" + i.ToString() + ".stl")); break; } } } } AddChild(leftToRightLayout); }
public void ScrollPositionStartsCorrect() { GuiWidget contents = new GuiWidget(300, 300); contents.DoubleBuffer = true; ListBox container = new ListBox(new RectangleDouble(0, 0, 200, 300)); //container.BackgroundColor = RGBA_Bytes.Red; container.Name = "containerListBox"; container.VAnchor = UI.VAnchor.ParentTop; container.Margin = new BorderDouble(15); contents.AddChild(container); container.AddChild(new ListBoxTextItem("hand.stl", "c:\\development\\hand.stl")); contents.OnDraw(contents.NewGraphics2D()); Assert.IsTrue(container.TopLeftOffset.y == 0); }
public void SingleItemVisibleTest() { { ListBox containerListBox = new ListBox(new RectangleDouble(0, 0, 100, 100)); ListBoxTextItem itemToAddToList = new ListBoxTextItem("test Item", "test data for item"); itemToAddToList.Name = "list item"; containerListBox.AddChild(itemToAddToList); containerListBox.DoubleBuffer = true; containerListBox.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); containerListBox.OnDraw(containerListBox.BackBuffer.NewGraphics2D()); ImageBuffer textImage = new ImageBuffer(80, 16, 32, new BlenderBGRA()); textImage.NewGraphics2D().Clear(RGBA_Bytes.White); textImage.NewGraphics2D().DrawString("test Item", 1, 1); OutputImage(containerListBox.BackBuffer, "test.tga"); OutputImage(textImage, "control.tga"); double maxError = 20000000; Vector2 bestPosition; double leastSquares; containerListBox.BackBuffer.FindLeastSquaresMatch(textImage, out bestPosition, out leastSquares, maxError); Assert.IsTrue(leastSquares < maxError, "The list box need to be showing the item we added to it."); } { GuiWidget container = new GuiWidget(202, 302); container.DoubleBuffer = true; container.NewGraphics2D().Clear(RGBA_Bytes.White); FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); leftToRightLayout.AnchorAll(); { { ListBox listBox = new ListBox(new RectangleDouble(0, 0, 200, 300)); //listBox.BackgroundColor = RGBA_Bytes.Red; listBox.Name = "listBox"; listBox.VAnchor = UI.VAnchor.ParentTop; listBox.ScrollArea.Margin = new BorderDouble(15); leftToRightLayout.AddChild(listBox); for (int i = 0; i < 1; i++) { ListBoxTextItem newItem = new ListBoxTextItem("hand" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl"); newItem.Name = "ListBoxItem" + i.ToString(); listBox.AddChild(newItem); } } } container.AddChild(leftToRightLayout); container.OnDraw(container.NewGraphics2D()); ImageBuffer textImage = new ImageBuffer(80, 16, 32, new BlenderBGRA()); textImage.NewGraphics2D().Clear(RGBA_Bytes.White); textImage.NewGraphics2D().DrawString("hand0.stl", 1, 1); OutputImage(container.BackBuffer, "control.tga"); OutputImage(textImage, "test.tga"); double maxError = 1000000; Vector2 bestPosition; double leastSquares; container.BackBuffer.FindLeastSquaresMatch(textImage, out bestPosition, out leastSquares, maxError); Assert.IsTrue(leastSquares < maxError, "The list box need to be showing the item we added to it."); } }