Пример #1
0
        public void ChangeBackgroundColor(Color backgroundColor)
        {
            if (elem == null)
            {
                return;
            }
            BoxSpec boxSpec = elem.Spec;

            if (boxSpec.BackgroundColor == backgroundColor)
            {
                return;
            }


            var existingRuleSet = elem.ElementRuleSet;

            if (existingRuleSet == null)
            {
                //create new one
                elem.ElementRuleSet   = existingRuleSet = new CssRuleSet();
                elem.IsStyleEvaluated = false;
            }

            //-------------------------------------
            existingRuleSet.RemoveCssProperty(WellknownCssPropertyName.BackgroundColor);
            existingRuleSet.AddCssCodeProperty(
                new CssPropertyDeclaration(
                    WellknownCssPropertyName.BackgroundColor,
                    new CssCodeColor(CssColorConv.ConvertToCssColor(backgroundColor))));

            elem.SkipPrincipalBoxEvalulation = false;

            CssBox cssbox = HtmlElement.InternalGetPrincipalBox(elem);

            if (cssbox != null)
            {
#if DEBUG
                cssbox.dbugMark1++;
#endif

                CssBox.InvalidateComputeValue(cssbox);
            }

            HtmlElement.InvokeNotifyChangeOnIdleState(
                elem,
                ElementChangeKind.Spec);

            InvalidateCssBox(cssbox);
        }