本文整理汇总了C#中ListBox.OnDraw方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.OnDraw方法的具体用法?C# ListBox.OnDraw怎么用?C# ListBox.OnDraw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox.OnDraw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingleItemVisibleTest
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.");
}
}