Esempio n. 1
0
        public void ChangeFontColor(Color newcolor)
        {
            //change prop
            //then need to evaluate
            if (elem == null)
            {
                return;
            }
            BoxSpec boxSpec = elem.Spec;

            if (boxSpec.ActualColor == newcolor)
            {
                return;
            }

            HtmlElement.InvokeNotifyChangeOnIdleState(
                elem,
                ElementChangeKind.Spec);
            //-------------------------------------
            var existingRuleSet = elem.ElementRuleSet;

            if (existingRuleSet == null)
            {
                //create new one
                elem.ElementRuleSet   = existingRuleSet = new CssRuleSet();
                elem.IsStyleEvaluated = true;
            }
            existingRuleSet.AddCssCodeProperty(
                new CssPropertyDeclaration(
                    WellknownCssPropertyName.Color,
                    new CssCodeColor(
                        CssColorConv.ConvertToCssColor(newcolor))));
            HtmlElement.InvokeNotifyChangeOnIdleState(elem, ElementChangeKind.Spec);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 internal static Color AsColor(WebDom.CssCodeValueExpression value)
 {
     return(CssColorConv.ConvertToActualColor(UserMapUtil.AsColor(value)));
 }