Beispiel #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);
        }
Beispiel #2
0
        private NStyleSheet CreateCustomStyleSheet(NUITheme theme)
        {
            NStyleSheet styleSheet = new NStyleSheet();

            #region Category headers

            NRule            rule = new NRule();
            NSelectorBuilder sb   = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NExampleCategoryHeader.NExampleCategoryHeaderSchema);
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NFont>(FontProperty, new NFont(NFontDescriptor.DefaultSansFamilyName,
                                                                                        CategoryHeaderFontSize, ENFontStyle.Bold)));
            rule.Declarations.Add(new NValueDeclaration <NFill>(TextFillProperty, new NColorFill(NColor.White)));
            rule.Declarations.Add(new NValueDeclaration <NMargins>(PaddingProperty, CategoryHeaderPadding));
            styleSheet.Add(rule);

            rule = new NRule();
            sb   = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NLabel.NLabelSchema);
            sb.ValueEquals(NMouse.IsDirectlyOverPropertyEx, true);
            sb.ChildOf();
            sb.Type(NExampleCategoryHeader.NExampleCategoryHeaderSchema);
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NFill>(TextFillProperty, new NColorFill(NColor.Wheat)));
            styleSheet.Add(rule);

            #endregion

            #region Component Image Box

            // Component image box
            rule = new NRule();
            sb   = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NComponentImageBox.NComponentImageBoxSchema);
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NMargins>(BorderThicknessProperty, new NMargins(1)));
            rule.Declarations.Add(new NValueDeclaration <NFont>(FontProperty,
                                                                new NFont(NFontDescriptor.DefaultSansFamilyName, 8.25, ENFontStyle.Bold)));
            rule.Declarations.Add(new NValueDeclaration <NCursor>(CursorProperty, new NCursor(ENPredefinedCursor.Hand)));
            styleSheet.Add(rule);

            // Component image box - mouse over
            rule = new NRule();
            sb   = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NComponentImageBox.NComponentImageBoxSchema);
            sb.ValueEquals(NMouse.IsOverPropertyEx, true);
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NBorder>(BorderProperty, NBorder.CreateFilledBorder(NColor.Gray)));
            styleSheet.Add(rule);

            #endregion

            #region Example tiles and contact labels

            // Example tiles and contact labels
            rule = new NRule();

            sb = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NExampleTile.NExampleTileSchema);
            sb.ChildOf();
            sb.Type(NTableFlowPanel.NTableFlowPanelSchema);
            sb.End();

            sb.Start();
            sb.Type(NLabel.NLabelSchema);
            sb.UserClass("ContactLabel");
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NCursor>(CursorProperty, new NCursor(ENPredefinedCursor.Hand)));
            styleSheet.Add(rule);

            // Example tiles and contact labels - mouse over
            rule = new NRule();
            sb   = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NExampleTile.NExampleTileSchema);
            sb.ValueEquals(NMouse.IsOverPropertyEx, true);
            sb.ChildOf();
            sb.Type(NTableFlowPanel.NTableFlowPanelSchema);
            sb.End();

            sb.Start();
            sb.Type(NLabel.NLabelSchema);
            sb.UserClass("ContactLabel");
            sb.ValueEquals(NMouse.IsOverPropertyEx, true);
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NFill>(TextFillProperty, new NColorFill(MouseOverColor)));
            styleSheet.Add(rule);

            #endregion

            #region Example in the autocomplete list box

            rule = new NRule();
            sb   = rule.GetSelectorBuilder();
            sb.Start();
            sb.Type(NListBoxItem.NListBoxItemSchema);
            sb.ValueEquals(NMouse.IsOverPropertyEx, true);
            sb.ChildOf();
            sb.ChildOf();
            sb.Type(NListBox.NListBoxSchema);
            sb.ChildOf();
            sb.Type(NPopupWindow.NPopupWindowSchema);
            sb.End();

            rule.Declarations.Add(new NValueDeclaration <NFill>(BackgroundFillProperty,
                                                                new NColorFill(theme.Colors.ButtonSelectedHighlight)));
            styleSheet.Add(rule);

            #endregion

            return(styleSheet);
        }