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


C# CSSNode.CalculateLayout方法代码示例

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


在下文中一共展示了CSSNode.CalculateLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_border_center_child

        public void Test_border_center_child()
        {
            CSSNode root = new CSSNode();
            root.JustifyContent = CSSJustify.Center;
            root.AlignItems = CSSAlign.Center;
            root.SetBorder(CSSEdge.Start, 10);
            root.SetBorder(CSSEdge.End, 20);
            root.SetBorder(CSSEdge.Bottom, 20);
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleWidth = 10;
            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(40, root_child0.LayoutX);
            Assert.AreEqual(35, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(50, root_child0.LayoutX);
            Assert.AreEqual(35, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:41,代码来源:CSSLayoutBorderTest.cs

示例2: Test_absolute_layout_start_top_end_bottom

        public void Test_absolute_layout_start_top_end_bottom()
        {
            CSSNode root = new CSSNode();
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.PositionType = CSSPositionType.Absolute;
            root_child0.SetPosition(CSSEdge.Start, 10);
            root_child0.SetPosition(CSSEdge.Top, 10);
            root_child0.SetPosition(CSSEdge.End, 10);
            root_child0.SetPosition(CSSEdge.Bottom, 10);
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(10, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(80, root_child0.LayoutWidth);
            Assert.AreEqual(80, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(10, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(80, root_child0.LayoutWidth);
            Assert.AreEqual(80, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:39,代码来源:CSSLayoutAbsolutePositionTest.cs

示例3: Test_flex_basis_flex_grow_column

        public void Test_flex_basis_flex_grow_column()
        {
            CSSNode root = new CSSNode();
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.FlexGrow = 1;
            root_child0.FlexBasis = 50;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();
            root_child1.FlexGrow = 1;
            root.Insert(1, root_child1);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(75, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(75, root_child1.LayoutY);
            Assert.AreEqual(100, root_child1.LayoutWidth);
            Assert.AreEqual(25, root_child1.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(75, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(75, root_child1.LayoutY);
            Assert.AreEqual(100, root_child1.LayoutWidth);
            Assert.AreEqual(25, root_child1.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:50,代码来源:CSSLayoutFlexTest.cs

示例4: Test_align_self_center

        public void Test_align_self_center()
        {
            CSSNode root = new CSSNode();
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.AlignSelf = CSSAlign.Center;
            root_child0.StyleWidth = 10;
            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(45, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(45, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:37,代码来源:CSSLayoutAlignSelfTest.cs

示例5: Test_align_items_min_max

        public void Test_align_items_min_max()
        {
            CSSNode root = new CSSNode();
            root.AlignItems = CSSAlign.Center;
            root.StyleMinWidth = 100;
            root.StyleMaxWidth = 200;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleWidth = 60;
            root_child0.StyleHeight = 60;
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(20, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(60, root_child0.LayoutWidth);
            Assert.AreEqual(60, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(20, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(60, root_child0.LayoutWidth);
            Assert.AreEqual(60, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:38,代码来源:CSSLayoutMinMaxDimensionTest.cs

示例6: Test_margin_and_flex_column

        public void Test_margin_and_flex_column()
        {
            CSSNode root = new CSSNode();
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.FlexGrow = 1;
            root_child0.SetMargin(CSSEdge.Top, 10);
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(90, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(90, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:36,代码来源:CSSLayoutMarginTest.cs

示例7: Test_wrap_column

        public void Test_wrap_column()
        {
            CSSNode root = new CSSNode();
            root.Wrap = CSSWrap.Wrap;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleWidth = 30;
            root_child0.StyleHeight = 30;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();
            root_child1.StyleWidth = 30;
            root_child1.StyleHeight = 30;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();
            root_child2.StyleWidth = 30;
            root_child2.StyleHeight = 30;
            root.Insert(2, root_child2);

            CSSNode root_child3 = new CSSNode();
            root_child3.StyleWidth = 30;
            root_child3.StyleHeight = 30;
            root.Insert(3, root_child3);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(60, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(30, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(30, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(30, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(60, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(30, root_child3.LayoutX);
            Assert.AreEqual(0, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(60, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(30, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(30, root_child0.LayoutHeight);

            Assert.AreEqual(30, root_child1.LayoutX);
            Assert.AreEqual(30, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(30, root_child1.LayoutHeight);

            Assert.AreEqual(30, root_child2.LayoutX);
            Assert.AreEqual(60, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(0, root_child3.LayoutX);
            Assert.AreEqual(0, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:81,代码来源:CSSLayoutFlexWrapTest.cs

示例8: TestPrint

 public void TestPrint()
 {
     CSSNode parent = new CSSNode();
     parent.StyleWidth = 100;
     parent.StyleHeight = 120;
     CSSNode child0 = new CSSNode();
     child0.StyleWidth = 30;
     child0.StyleHeight = 40;
     CSSNode child1 = new CSSNode();
     child1.StyleWidth = 35;
     child1.StyleHeight = 45;
     parent.Insert(0, child0);
     parent.Insert(0, child1);
     parent.CalculateLayout();
     Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n  {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n  {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
 }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:16,代码来源:CSSNodeTest.cs

示例9: Test_wrap_row_align_items_flex_end

        public void Test_wrap_row_align_items_flex_end()
        {
            CSSNode root = new CSSNode();
            root.FlexDirection = CSSFlexDirection.Row;
            root.AlignItems = CSSAlign.FlexEnd;
            root.Wrap = CSSWrap.Wrap;
            root.StyleWidth = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleWidth = 30;
            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();
            root_child1.StyleWidth = 30;
            root_child1.StyleHeight = 20;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();
            root_child2.StyleWidth = 30;
            root_child2.StyleHeight = 30;
            root.Insert(2, root_child2);

            CSSNode root_child3 = new CSSNode();
            root_child3.StyleWidth = 30;
            root_child3.StyleHeight = 30;
            root.Insert(3, root_child3);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(60, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(20, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(30, root_child1.LayoutX);
            Assert.AreEqual(10, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(20, root_child1.LayoutHeight);

            Assert.AreEqual(60, root_child2.LayoutX);
            Assert.AreEqual(0, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(0, root_child3.LayoutX);
            Assert.AreEqual(30, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(60, root.LayoutHeight);

            Assert.AreEqual(70, root_child0.LayoutX);
            Assert.AreEqual(20, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(40, root_child1.LayoutX);
            Assert.AreEqual(10, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(20, root_child1.LayoutHeight);

            Assert.AreEqual(10, root_child2.LayoutX);
            Assert.AreEqual(0, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(70, root_child3.LayoutX);
            Assert.AreEqual(30, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:83,代码来源:CSSLayoutFlexWrapTest.cs

示例10: Test_max_width

        public void Test_max_width()
        {
            CSSNode root = new CSSNode();
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleMaxWidth = 50;
            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(50, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:36,代码来源:CSSLayoutMinMaxDimensionTest.cs

示例11: Test_min_width

        public void Test_min_width()
        {
            CSSNode root = new CSSNode();
            root.FlexDirection = CSSFlexDirection.Row;
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.FlexGrow = 1;
            root_child0.StyleMinWidth = 60;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();
            root_child1.FlexGrow = 1;
            root.Insert(1, root_child1);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(80, root_child0.LayoutWidth);
            Assert.AreEqual(100, root_child0.LayoutHeight);

            Assert.AreEqual(80, root_child1.LayoutX);
            Assert.AreEqual(0, root_child1.LayoutY);
            Assert.AreEqual(20, root_child1.LayoutWidth);
            Assert.AreEqual(100, root_child1.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(20, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(80, root_child0.LayoutWidth);
            Assert.AreEqual(100, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(0, root_child1.LayoutY);
            Assert.AreEqual(20, root_child1.LayoutWidth);
            Assert.AreEqual(100, root_child1.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:51,代码来源:CSSLayoutMinMaxDimensionTest.cs

示例12: Test_flex_basis_flex_shrink_row

        public void Test_flex_basis_flex_shrink_row()
        {
            CSSNode root = new CSSNode();
            root.FlexDirection = CSSFlexDirection.Row;
            root.StyleWidth = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();
            root_child0.FlexShrink = 1;
            root_child0.FlexBasis = 100;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();
            root_child1.FlexBasis = 50;
            root.Insert(1, root_child1);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(100, root_child0.LayoutHeight);

            Assert.AreEqual(50, root_child1.LayoutX);
            Assert.AreEqual(0, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(100, root_child1.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(50, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(100, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(0, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(100, root_child1.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:51,代码来源:CSSLayoutFlexTest.cs

示例13: Test_border_container_match_child

        public void Test_border_container_match_child()
        {
            CSSNode root = new CSSNode();
            root.SetBorder(CSSEdge.Left, 10);
            root.SetBorder(CSSEdge.Top, 10);
            root.SetBorder(CSSEdge.Right, 10);
            root.SetBorder(CSSEdge.Bottom, 10);

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleWidth = 10;
            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(30, root.LayoutWidth);
            Assert.AreEqual(30, root.LayoutHeight);

            Assert.AreEqual(10, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(30, root.LayoutWidth);
            Assert.AreEqual(30, root.LayoutHeight);

            Assert.AreEqual(10, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:38,代码来源:CSSLayoutBorderTest.cs

示例14: Test_flex_shrink_to_zero

        public void Test_flex_shrink_to_zero()
        {
            CSSNode root = new CSSNode();
            root.StyleHeight = 75;

            CSSNode root_child0 = new CSSNode();
            root_child0.StyleWidth = 50;
            root_child0.StyleHeight = 50;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();
            root_child1.FlexShrink = 1;
            root_child1.StyleWidth = 50;
            root_child1.StyleHeight = 50;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();
            root_child2.StyleWidth = 50;
            root_child2.StyleHeight = 50;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(50, root.LayoutWidth);
            Assert.AreEqual(75, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(50, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(50, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(0, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(50, root_child2.LayoutY);
            Assert.AreEqual(50, root_child2.LayoutWidth);
            Assert.AreEqual(50, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(50, root.LayoutWidth);
            Assert.AreEqual(75, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(50, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(50, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(0, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(50, root_child2.LayoutY);
            Assert.AreEqual(50, root_child2.LayoutWidth);
            Assert.AreEqual(50, root_child2.LayoutHeight);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:66,代码来源:CSSLayoutFlexTest.cs

示例15: test

 private static void test(String message, CSSNode style, CSSNode expectedLayout)
 {
     style.CalculateLayout();
     assertLayoutsEqual(message, style, expectedLayout);
 }
开发者ID:emilsjolander,项目名称:css-layout,代码行数:5,代码来源:LayoutEngineTest.cs


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