Example #1
0
        /// <summary>
        /// Creates a style sheet for the shopping cart table
        /// </summary>
        /// <returns></returns>
        NStyleSheet CreateShoppingCartStyleSheet()
        {
            NStyleSheet styleSheet = new NStyleSheet();

            NRule rule = new NRule();

            for (int i = 0; i < 3; i++)
            {
                NSelectorBuilder sb = rule.GetSelectorBuilder();
                sb.Start();

                sb.Type(NTableCell.NTableCellSchema);

                // in case of the first or last row selector -> must not be last cell
                if (i == 0 || i == 2)
                {
                    sb.StartInvertedConditions();
                    sb.LastChild();
                    sb.EndInvertedConditions();
                }

                // descendant of table row
                sb.DescendantOf();
                sb.Type(NTableRow.NTableRowSchema);

                switch (i)
                {
                case 0:
                    // descendant of first row
                    sb.FirstChild();
                    break;

                case 1:
                    // middle cells
                    sb.StartInvertedConditions();
                    sb.FirstChild();
                    sb.LastChild();
                    sb.EndInvertedConditions();
                    break;

                case 2:
                    // descendant of last row
                    sb.LastChild();
                    break;
                }

                // descendant of table
                sb.DescendantOf();
                sb.Type(NTable.NTableSchema);
                sb.ValueEquals(NTable.TagProperty, "ShoppingCart");

                sb.End();
            }

            rule.Declarations.Add(new NValueDeclaration <NMargins>(NTableCell.BorderThicknessProperty, new NMargins(1)));
            rule.Declarations.Add(new NValueDeclaration <NBorder>(NTableCell.BorderProperty, NBorder.CreateFilledBorder(NColor.Black)));

            styleSheet.Add(rule);

            return(styleSheet);
        }