当前位置: 首页>>代码示例>>C#>>正文


C# ListBox.AddChild方法代码示例

本文整理汇总了C#中ListBox.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.AddChild方法的具体用法?C# ListBox.AddChild怎么用?C# ListBox.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListBox的用法示例。


在下文中一共展示了ListBox.AddChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:68,代码来源:ListBoxTests.cs

示例2: ScrollPositionStartsCorrect

        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);
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:18,代码来源:ListBoxTests.cs


注:本文中的ListBox.AddChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。