• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CSSNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testInvalidatesCacheWhenChildAdded

        public void testInvalidatesCacheWhenChildAdded()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            CSSNode c0c1 = new CSSNode();
            CSSNode c1c0 = new CSSNode();
            c0c1.Width = 200;
            c0c1.Height = 200;
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            c0c0.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.addChildAt(c0c1, 1);

            root.calculateLayout();
            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c0c1.HasNewLayout);

            Assert.IsTrue(c0c0.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);

            Assert.IsFalse(c1c0.HasNewLayout);
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:30,代码来源:LayoutCachingTest.cs


示例2: TestChildren

        public void TestChildren()
        {
            CSSNode parent = new CSSNode();
            foreach (CSSNode node in parent) {
                Assert.Fail(node.ToString());
            }

            CSSNode child0 = new CSSNode();
            Assert.AreEqual(-1, parent.IndexOf(child0));
            parent.Insert(0, child0);
            foreach (CSSNode node in parent) {
                Assert.AreEqual(0, parent.IndexOf(node));
            }

            CSSNode child1 = new CSSNode();
            parent.Insert(1, child1);
            int index = 0;
            foreach (CSSNode node in parent) {
                Assert.AreEqual(index++, parent.IndexOf(node));
            }

            parent.RemoveAt(0);
            Assert.AreEqual(-1, parent.IndexOf(child0));
            Assert.AreEqual(0, parent.IndexOf(child1));

            parent.Clear();
            Assert.AreEqual(0, parent.Count);

            parent.Clear();
            Assert.AreEqual(0, parent.Count);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:31,代码来源:CSSNodeTest.cs


示例3: boundAxis

        private static float boundAxis(CSSNode node, int axis, float value)
        {
            float min = CSSConstants.Undefined;
            float max = CSSConstants.Undefined;

            if (axis == CSS_FLEX_DIRECTION_COLUMN || axis == CSS_FLEX_DIRECTION_COLUMN_REVERSE)
            {
                min = node.style.minHeight;
                max = node.style.maxHeight;
            }
            else if (axis == CSS_FLEX_DIRECTION_ROW || axis == CSS_FLEX_DIRECTION_ROW_REVERSE)
            {
                min = node.style.minWidth;
                max = node.style.maxWidth;
            }

            float boundValue = value;

            if (!float.IsNaN(max) && max >= 0.0 && boundValue > max)
            {
                boundValue = max;
            }
            if (!float.IsNaN(min) && min >= 0.0 && boundValue < min)
            {
                boundValue = min;
            }

            return boundValue;
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:29,代码来源:LayoutEngine.cs


示例4: markLayoutAppliedForTree

 private void markLayoutAppliedForTree(CSSNode root)
 {
     root.MarkLayoutSeen();
     for (int i = 0; i < root.getChildCount(); i++)
     {
         markLayoutAppliedForTree(root.getChildAt(i));
     }
 }
开发者ID:tryroach,项目名称:css-layout,代码行数:8,代码来源:LayoutCachingTest.cs


示例5: testCannotAddChildToMultipleParents

        public void testCannotAddChildToMultipleParents()
        {
            CSSNode parent1 = new CSSNode();
            CSSNode parent2 = new CSSNode();
            CSSNode child = new CSSNode();

            parent1.addChildAt(child, 0);
            parent2.addChildAt(child, 0);
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:9,代码来源:CSSNodeTest.cs


示例6: assertTreeHasNewLayout

        private void assertTreeHasNewLayout(bool expectedHasNewLayout, CSSNode root)
        {
            Assert.AreEqual(expectedHasNewLayout, root.HasNewLayout);

            for (int i = 0; i < root.getChildCount(); i++)
            {
                assertTreeHasNewLayout(expectedHasNewLayout, root.getChildAt(i));
            }
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:9,代码来源:LayoutCachingTest.cs


示例7: TestCannotAddChildToMultipleParents

        public void TestCannotAddChildToMultipleParents()
        {
            CSSNode parent1 = new CSSNode();
            CSSNode parent2 = new CSSNode();
            CSSNode child = new CSSNode();

            parent1.Insert(0, child);
            parent2.Insert(0, child);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:9,代码来源:CSSNodeTest.cs


示例8: 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


示例9: areLayoutsEqual

 private static bool areLayoutsEqual(CSSNode a, CSSNode b) {
     bool doNodesHaveSameLayout =
         areFloatsEqual(a.layout.position[POSITION_LEFT], b.layout.position[POSITION_LEFT]) &&
         areFloatsEqual(a.layout.position[POSITION_TOP], b.layout.position[POSITION_TOP]) &&
         areFloatsEqual(a.layout.dimensions[DIMENSION_WIDTH], b.layout.dimensions[DIMENSION_WIDTH]) &&
         areFloatsEqual(a.layout.dimensions[DIMENSION_HEIGHT], b.layout.dimensions[DIMENSION_HEIGHT]);
     if (!doNodesHaveSameLayout) {
         return false;
     }
     for (int i = 0; i < a.getChildCount(); i++) {
         if (!areLayoutsEqual(a.getChildAt(i), b.getChildAt(i))) {
             return false;
         }
     }
     return true;
 }
开发者ID:vjeux,项目名称:css-layout,代码行数:16,代码来源:LayoutEngineTest.cs


示例10: layoutNode

        internal static void layoutNode(CSSLayoutContext layoutContext, CSSNode node, float parentMaxWidth, CSSDirection? parentDirection)
        {
            if (needsRelayout(node, parentMaxWidth))
            {
                node.lastLayout.requestedWidth = node.layout.dimensions[DIMENSION_WIDTH];
                node.lastLayout.requestedHeight = node.layout.dimensions[DIMENSION_HEIGHT];
                node.lastLayout.parentMaxWidth = parentMaxWidth;

                layoutNodeImpl(layoutContext, node, parentMaxWidth, parentDirection);
                node.lastLayout.copy(node.layout);
            }
            else
            {
                node.layout.copy(node.lastLayout);
            }

            node.markHasNewLayout();
        }
开发者ID:Grace,项目名称:css-layout,代码行数:18,代码来源:LayoutEngine.cs


示例11: TestAddChildGetParent

        public void TestAddChildGetParent()
        {
            CSSNode parent = new CSSNode();
            CSSNode child = new CSSNode();

            Assert.IsNull(child.Parent);
            Assert.AreEqual(0, parent.Count);

            parent.Insert(0, child);

            Assert.AreEqual(1, parent.Count);
            Assert.AreEqual(child, parent[0]);
            Assert.AreEqual(parent, child.Parent);

            parent.RemoveAt(0);

            Assert.IsNull(child.Parent);
            Assert.AreEqual(0, parent.Count);
        }
开发者ID:zhuyadong,项目名称:css-layout,代码行数:19,代码来源:CSSNodeTest.cs


示例12: testAddChildGetParent

        public void testAddChildGetParent()
        {
            CSSNode parent = new CSSNode();
            CSSNode child = new CSSNode();

            Assert.IsNull(child.getParent());
            Assert.AreEqual(0, parent.getChildCount());

            parent.addChildAt(child, 0);

            Assert.AreEqual(1, parent.getChildCount());
            Assert.AreEqual(child, parent.getChildAt(0));
            Assert.AreEqual(parent, child.getParent());

            parent.removeChildAt(0);

            Assert.IsNull(child.getParent());
            Assert.AreEqual(0, parent.getChildCount());
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:19,代码来源:CSSNodeTest.cs


示例13: testCachesFullTree

        public void testCachesFullTree()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);

            root.calculateLayout();
            assertTreeHasNewLayout(true, root);
            markLayoutAppliedForTree(root);

            root.calculateLayout();
            Assert.IsTrue(root.HasNewLayout);
            assertTreeHasNewLayout(false, c0);
            assertTreeHasNewLayout(false, c1);
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:19,代码来源:LayoutCachingTest.cs


示例14: 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


示例15: testInvalidateCacheWhenHeightChangesPosition

        public void testInvalidateCacheWhenHeightChangesPosition()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c1c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c1.addChildAt(c1c0, 0);

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            c0.Height = 100;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            Assert.IsTrue(c0.HasNewLayout);
            Assert.IsTrue(c1.HasNewLayout);
            Assert.IsFalse(c1c0.HasNewLayout);
        }
开发者ID:emilsjolander,项目名称:css-layout,代码行数:21,代码来源:LayoutCachingTest.cs


示例16: testDoesNotInvalidateCacheWhenPropertyIsTheSame

        public void testDoesNotInvalidateCacheWhenPropertyIsTheSame()
        {
            CSSNode root = new CSSNode();
            CSSNode c0 = new CSSNode();
            CSSNode c1 = new CSSNode();
            CSSNode c0c0 = new CSSNode();
            root.addChildAt(c0, 0);
            root.addChildAt(c1, 1);
            c0.addChildAt(c0c0, 0);
            root.Width = 200;

            root.calculateLayout();
            markLayoutAppliedForTree(root);

            root.Width = 200;
            root.calculateLayout();

            Assert.IsTrue(root.HasNewLayout);
            assertTreeHasNewLayout(false, c0);
            assertTreeHasNewLayout(false, c1);
        }
开发者ID:emilsjolander,项目名称:css-layout,代码行数:21,代码来源:LayoutCachingTest.cs


示例17: 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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharpBinderFlags类代码示例发布时间:2022-05-24
下一篇:
C# CSMTestEnvironmentFactory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap