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


C# CSSNode类代码示例

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


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


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