Пример #1
0
        public override double GetFloatValue(CssPrimitiveType unitType)
        {
            double ret = double.NaN;

            switch (unitType)
            {
            case CssPrimitiveType.Number:
                if (PrimitiveType == CssPrimitiveType.Number)
                {
                    ret = _floatValue;
                }
                else if (PrimitiveType == CssPrimitiveType.Percentage)
                {
                    ret = _floatValue / 100 * 255D;
                }
                break;

            case CssPrimitiveType.Percentage:
                if (PrimitiveType == CssPrimitiveType.Percentage)
                {
                    ret = _floatValue;
                }
                else if (PrimitiveType == CssPrimitiveType.Number)
                {
                    ret = _floatValue * 255D;
                }
                break;
            }
            if (double.IsNaN(ret))
            {
                throw new DomException(DomExceptionType.InvalidAccessErr);
            }
            return(ret);
        }
 /// <summary>
 /// Only for internal use
 /// </summary>
 protected CssPrimitiveValue()
     : base()
 {
     _primitiveType = CssPrimitiveType.Unknown;
     _cssValueType  = CssValueType.PrimitiveValue;
     floatValue     = Double.NaN;
 }
 /// <summary>
 /// Only for internal use
 /// </summary>
 protected CssPrimitiveValue()
     : base()
 {
     _primitiveType = CssPrimitiveType.Unknown;
     _cssValueType  = CssValueType.PrimitiveValue;
     floatValue     = Double.NaN;
 }
 public override double GetFloatValue(CssPrimitiveType unitType)
 {
     double ret = Double.NaN;
     switch(unitType)
     {
         case CssPrimitiveType.Number:
             if(PrimitiveType == CssPrimitiveType.Number) ret = floatValue;
             else if(PrimitiveType == CssPrimitiveType.Percentage)
             {
                 ret = floatValue / 100 * 255D;
             }
             break;
         case CssPrimitiveType.Percentage:
             if(PrimitiveType == CssPrimitiveType.Percentage) ret = floatValue;
             else if(PrimitiveType == CssPrimitiveType.Number)
             {
                 ret = floatValue * 255D;
             }
             break;
     }
     if(Double.IsNaN(ret))
     {
         throw new DomException(DomExceptionType.InvalidAccessErr);
     }
     else
     {
         return ret;
     }
 }
 public override double GetFloatValue(CssPrimitiveType unitType)
 {
     double ret = Double.NaN;
     switch(unitType)
     {
         case CssPrimitiveType.Number:
         case CssPrimitiveType.Deg:
             ret = _getDegAngle();
             break;
         case CssPrimitiveType.Rad:
             ret = _getDegAngle() * Math.PI / 180;
             break;
         case CssPrimitiveType.Grad:
             ret = _getDegAngle() * 100 / 90;
             break;
     }
     if(Double.IsNaN(ret))
     {
         throw new DomException(DomExceptionType.InvalidAccessErr);
     }
     else
     {
         return ret;
     }
 }
Пример #6
0
        public override double GetFloatValue(CssPrimitiveType unitType)
        {
            double ret = double.NaN;

            switch (unitType)
            {
            case CssPrimitiveType.Number:
            case CssPrimitiveType.Deg:
                ret = GetDegAngle();
                break;

            case CssPrimitiveType.Rad:
                ret = GetDegAngle() * Math.PI / 180;
                break;

            case CssPrimitiveType.Grad:
                ret = GetDegAngle() * 100 / 90;
                break;
            }

            if (double.IsNaN(ret))
            {
                throw new DomException(DomExceptionType.InvalidAccessErr);
            }
            return(ret);
        }
Пример #7
0
        /// <summary>
        /// A method to set the float value with a specified unit. If the property attached with this
        /// value can not accept the specified unit or the float value, the value will be unchanged
        /// and a <see cref="DomException"/> will be raised.
        /// </summary>
        /// <param name="unitType">A unit code as defined above. The unit code can only be a float
        /// unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN,
        /// CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).</param>
        /// <param name="floatValue">The new float value.</param>
        /// <exception cref="DomException">
        /// <c>INVALID_ACCESS_ERR:</c> Raised if the CSS value doesn't contain a float value.</exception>
        /// <exception cref="DomException">
        /// <c>NO_MODIFICATION_ALLOWED_ERR:</c> Raised if this property is readonly.</exception>
        public virtual void SetFloatValue(CssPrimitiveType unitType, double floatValue)
        {
            if (this.ReadOnly)
            {
                throw new DomException(DomExceptionType.NoModificationAllowedErr);
            }

            _primitiveType = unitType;
            SetFloatValue(floatValue);
        }
        public override double GetFloatValue(CssPrimitiveType unitType)
        {
            double ret;

            if (PrimitiveType == CssPrimitiveType.Percentage)
            {
                if (unitType == CssPrimitiveType.Percentage)
                {
                    return(floatValue);
                }
                else
                {
                    throw new NotImplementedException("Can't get absolute values from percentages");
                }
            }
            else
            {
                switch (unitType)
                {
                case CssPrimitiveType.Cm:
                    ret = _getInLength() * CmPerIn;
                    break;

                case CssPrimitiveType.Mm:
                    ret = _getInLength() * CmPerIn * 10;
                    break;

                case CssPrimitiveType.In:
                    ret = _getInLength();
                    break;

                case CssPrimitiveType.Pc:
                    ret = _getInLength() * 6;
                    break;

                case CssPrimitiveType.Pt:
                    ret = _getInLength() * 72;
                    break;

                case CssPrimitiveType.Ems:
                    ret = _getPxLength() / _getFontSize();
                    break;

                case CssPrimitiveType.Exs:
                    ret = _getPxLength() / (_getFontSize() * 0.5);
                    break;

                default:
                    ret = _getPxLength();
                    break;
                }
            }
            return(ret);
        }
Пример #9
0
 public override double GetFloatValue(CssPrimitiveType unitType)
 {
     double ret = Double.NaN;
     switch(PrimitiveType)
     {
         case CssPrimitiveType.Number:
         case CssPrimitiveType.Px:
         case CssPrimitiveType.Cm:
         case CssPrimitiveType.Mm:
         case CssPrimitiveType.In:
         case CssPrimitiveType.Pt:
         case CssPrimitiveType.Pc:
             if(unitType == CssPrimitiveType.Px) ret = _getPxLength();
             else if(unitType == CssPrimitiveType.Number) ret = _getPxLength();
             else if(unitType == CssPrimitiveType.In) ret = _getInLength();
             else if(unitType == CssPrimitiveType.Cm) ret = _getInLength() * CmPerIn;
             else if(unitType == CssPrimitiveType.Mm) ret = _getInLength() * CmPerIn * 10;
             else if(unitType == CssPrimitiveType.Pt) ret = _getInLength() * 72;
             else if(unitType == CssPrimitiveType.Pc) ret = _getInLength() * 6;
             break;
         case CssPrimitiveType.Percentage:
             if(unitType == CssPrimitiveType.Percentage) ret = floatValue;
             break;
         case CssPrimitiveType.Ems:
             if(unitType == CssPrimitiveType.Ems) ret = floatValue;
             break;
         case CssPrimitiveType.Exs:
             if(unitType == CssPrimitiveType.Exs) ret = floatValue;
             break;
     }
     if(Double.IsNaN(ret))
     {
         throw new DomException(DomExceptionType.InvalidAccessErr);
     }
     else
     {
         return ret;
     }
 }
Пример #10
0
 /// <summary>
 /// A method to set the float value with a specified unit. If the property attached with this value can not accept the specified unit or the float value, the value will be unchanged and a DOMException will be raised.
 /// </summary>
 /// <param name="unitType">A unit code as defined above. The unit code can only be a float unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).</param>
 /// <param name="floatValue">The new float value.</param>
 /// <exception cref="DomException">INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float value.</exception>
 /// <exception cref="DomException">NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.</exception>
 public virtual void SetFloatValue(CssPrimitiveType unitType, double floatValue)
 {
     if (this.ReadOnly)
     {
         throw new DomException(DomExceptionType.NoModificationAllowedErr);
     }
     else
     {
         _primitiveType = unitType;
         SetFloatValue(floatValue);
     }
 }
Пример #11
0
        /// <summary>
        /// Constructor called by CssValue.GetCssValue()
        /// </summary>
        /// <param name="match">A Regex that matches a CssPrimitiveValue</param>
        /// <param name="readOnly">Specifiec if this instance is read-only</param>
        private CssPrimitiveValue(Match match, bool readOnly)
            : this(match.Value, readOnly)
        {
            if (match.Groups["func"].Success)
            {
                switch (match.Groups["funcname"].Value)
                {
                case "rect":
                    _primitiveType = CssPrimitiveType.Rect;
                    _rectValue     = new CssRect(match.Groups["funcvalue"].Value, ReadOnly);
                    break;

                case "attr":
                    _primitiveType = CssPrimitiveType.Attr;
                    _stringValue   = match.Groups["funcvalue"].Value;
                    break;

                case "url":
                    _stringValue   = match.Groups["funcvalue"].Value;
                    _primitiveType = CssPrimitiveType.Uri;
                    break;

                case "counter":
                    throw new NotImplementedException("Counters are not implemented");
                    //_primitiveType = CssPrimitiveType.CSS_COUNTER;
                }
            }
            else if (match.Groups["freqTimeNumber"].Success)
            {
                _floatValue = float.Parse(match.Groups["numberValue2"].Value, CssNumber.Format);

                switch (match.Groups["unit2"].Value)
                {
                case "Hz":
                    _primitiveType = CssPrimitiveType.Hz;
                    break;

                case "kHz":
                    _primitiveType = CssPrimitiveType.KHz;
                    break;

                case "in":
                    _primitiveType = CssPrimitiveType.In;
                    break;

                case "s":
                    _primitiveType = CssPrimitiveType.S;
                    break;

                case "ms":
                    _primitiveType = CssPrimitiveType.Ms;
                    break;

                case "%":
                    _primitiveType = CssPrimitiveType.Percentage;
                    break;

                default:
                    _primitiveType = CssPrimitiveType.Number;
                    break;
                }
            }
            else if (match.Groups["string"].Success)
            {
                _stringValue   = match.Groups["stringvalue"].Value;
                _primitiveType = CssPrimitiveType.String;
            }
            else if (match.Groups["colorIdent"].Success)
            {
                string val = match.Value;
                _stringValue   = match.Value;
                _primitiveType = CssPrimitiveType.Ident;
            }
            else
            {
                _primitiveType = CssPrimitiveType.Unknown;
            }
        }
Пример #12
0
 protected void SetPrimitiveType(CssPrimitiveType type)
 {
     _primitiveType = type;
 }
Пример #13
0
        /// <summary>
        /// This method is used to get a float value in a specified unit. If this CSS value doesn't
        /// contain a float value or can't be converted into the specified unit, a <see cref="DomException"/> is raised
        /// </summary>
        /// <param name="unitType">A unit code to get the float value. The unit code can only be a
        /// float unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM,
        /// CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).</param>
        /// <returns>The float value in the specified unit.</returns>
        /// <exception cref="DomException">
        /// <c>INVALID_ACCESS_ERR:</c> Raised if the CSS value doesn't contain a float value.
        /// </exception>
        public virtual double GetFloatValue(CssPrimitiveType unitType)
        {
            if (double.IsNaN(_floatValue))
            {
                throw new DomException(DomExceptionType.InvalidAccessErr);
            }
            double ret = double.NaN;

            switch (this.PrimitiveType)
            {
            case CssPrimitiveType.Percentage:
                if (unitType == CssPrimitiveType.Percentage)
                {
                    ret = _floatValue;
                }
                break;

            case CssPrimitiveType.Ms:
                if (unitType == CssPrimitiveType.Ms)
                {
                    ret = _floatValue;
                }
                else if (unitType == CssPrimitiveType.S)
                {
                    ret = _floatValue / 1000;
                }
                break;

            case CssPrimitiveType.S:
                if (unitType == CssPrimitiveType.Ms)
                {
                    ret = _floatValue * 1000;
                }
                else if (unitType == CssPrimitiveType.S)
                {
                    ret = _floatValue;
                }
                break;

            case CssPrimitiveType.Hz:
                if (unitType == CssPrimitiveType.Hz)
                {
                    ret = _floatValue;
                }
                else if (unitType == CssPrimitiveType.KHz)
                {
                    ret = _floatValue / 1000;
                }
                break;

            case CssPrimitiveType.KHz:
                if (unitType == CssPrimitiveType.Hz)
                {
                    ret = _floatValue * 1000;
                }
                else if (unitType == CssPrimitiveType.KHz)
                {
                    ret = _floatValue;
                }
                break;

            case CssPrimitiveType.Dimension:
                if (unitType == CssPrimitiveType.Dimension)
                {
                    ret = _floatValue;
                }
                break;
            }
            if (double.IsNaN(ret))
            {
                throw new DomException(DomExceptionType.InvalidAccessErr);
            }
            return(ret);
        }
Пример #14
0
 /// <summary>
 /// A method to set the string value with the specified unit. If the property attached to this
 /// value can't accept the specified unit or the string value, the value will be unchanged and
 /// a <see cref="DomException"/> will be raised.
 /// </summary>
 /// <param name="stringType">A string code as defined above. The string code can only
 /// be a string unit type (i.e. CSS_STRING, CSS_URI, CSS_IDENT, and CSS_ATTR).</param>
 /// <param name="stringValue">The new string value</param>
 /// <exception cref="DomException">
 /// <c>INVALID_ACCESS_ERR:</c> Raised if the CSS value doesn't contain a string value.</exception>
 /// <exception cref="DomException">
 /// <c>NO_MODIFICATION_ALLOWED_ERR:</c> Raised if this property is readonly.</exception>
 public virtual void SetStringValue(CssPrimitiveType stringType, string stringValue)
 {
     throw new NotImplementedException("SetStringValue");
 }
Пример #15
0
 protected CssPrimitiveValue(string cssText, bool readOnly)
     : base(CssValueType.PrimitiveValue, cssText, readOnly)
 {
     _primitiveType = CssPrimitiveType.Unknown;
     _floatValue    = double.NaN;
 }
 public override double GetFloatValue(CssPrimitiveType unitType)
 {
     double ret;
     if(PrimitiveType == CssPrimitiveType.Percentage)
     {
         if(unitType  == CssPrimitiveType.Percentage)
         {
             return floatValue;
         }
         else
         {
             throw new NotImplementedException("Can't get absolute values from percentages");
         }
     }
     else
     {
         switch(unitType)
         {
             case CssPrimitiveType.Cm:
                 ret = _getInLength() * CmPerIn;
                 break;
             case CssPrimitiveType.Mm:
                 ret = _getInLength() * CmPerIn * 10;
                 break;
             case CssPrimitiveType.In:
                 ret = _getInLength();
                 break;
             case CssPrimitiveType.Pc:
                 ret = _getInLength() * 6;
                 break;
             case CssPrimitiveType.Pt:
                 ret = _getInLength() * 72;
                 break;
             case CssPrimitiveType.Ems:
                 ret = _getPxLength() / _getFontSize();
                 break;
             case CssPrimitiveType.Exs:
                 ret = _getPxLength() / (_getFontSize() * 0.5);
                 break;
             default:
                 ret = _getPxLength();
                 break;
         }
     }
     return ret;
 }
Пример #17
0
 public override double GetFloatValue(CssPrimitiveType unitType)
 {
     return _cssValue.GetFloatValue(unitType);
 }
Пример #18
0
        /// <summary>
        /// Constructor called by CssValue.GetCssValue()
        /// </summary>
        /// <param name="match">A Regex that matches a CssPrimitiveValue</param>
        /// <param name="readOnly">Specifiec if this instance is read-only</param>
        private CssPrimitiveValue(Match match, bool readOnly)
            : this(match.Value, readOnly)
        {
            if (match.Groups["func"].Success)
            {
                switch (match.Groups["funcname"].Value)
                {
                    case "rect":
                        _primitiveType = CssPrimitiveType.Rect;
                        rectValue = new CssRect(match.Groups["funcvalue"].Value, ReadOnly);
                        break;
                    case "attr":
                        _primitiveType = CssPrimitiveType.Attr;
                        stringValue = match.Groups["funcvalue"].Value;
                        break;
                    case "url":
                        stringValue = match.Groups["funcvalue"].Value;
                        _primitiveType = CssPrimitiveType.Uri;
                        break;
                    case "counter":
                        throw new NotImplementedException("Counters are not implemented");
                    //_primitiveType = CssPrimitiveType.CSS_COUNTER;
                }
            }
            else if (match.Groups["freqTimeNumber"].Success)
            {
                floatValue = Single.Parse(match.Groups["numberValue2"].Value, CssNumber.Format);

                switch (match.Groups["unit2"].Value)
                {
                    case "Hz":
                        _primitiveType = CssPrimitiveType.Hz;
                        break;
                    case "kHz":
                        _primitiveType = CssPrimitiveType.KHz;
                        break;
                    case "in":
                        _primitiveType = CssPrimitiveType.In;
                        break;
                    case "s":
                        _primitiveType = CssPrimitiveType.S;
                        break;
                    case "ms":
                        _primitiveType = CssPrimitiveType.Ms;
                        break;
                    case "%":
                        _primitiveType = CssPrimitiveType.Percentage;
                        break;
                    default:
                        _primitiveType = CssPrimitiveType.Number;
                        break;
                }
            }
            else if (match.Groups["string"].Success)
            {
                stringValue = match.Groups["stringvalue"].Value;
                _primitiveType = CssPrimitiveType.String;
            }
            else if (match.Groups["colorIdent"].Success)
            {
                string val = match.Value;
                stringValue = match.Value;
                _primitiveType = CssPrimitiveType.Ident;
            }
            else
            {
                _primitiveType = CssPrimitiveType.Unknown;
            }
        }
Пример #19
0
 protected void SetPrimitiveType(CssPrimitiveType type)
 {
     _primitiveType = type;
 }
Пример #20
0
 protected CssPrimitiveValue(string cssText, bool readOnly)
     : base(CssValueType.PrimitiveValue, cssText, readOnly)
 {
     _primitiveType = CssPrimitiveType.Unknown;
     floatValue     = Double.NaN;
 }
Пример #21
0
 protected void _setType(CssPrimitiveType type)
 {
     _primitiveType = type;
 }
 public override double GetFloatValue(CssPrimitiveType unitType)
 {
     return(_cssValue.GetFloatValue(unitType));
 }
Пример #23
0
 /// <summary>
 /// This method is used to get a float value in a specified unit. If this CSS value doesn't contain a float value or can't be converted into the specified unit, a DOMException is raised
 /// </summary>
 /// <param name="unitType">A unit code to get the float value. The unit code can only be a float unit type (i.e. CSS_NUMBER, CSS_PERCENTAGE, CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ, CSS_KHZ, CSS_DIMENSION).</param>
 /// <returns>The float value in the specified unit.</returns>
 /// <exception cref="DomException">INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float value.</exception>
 public virtual double GetFloatValue(CssPrimitiveType unitType)
 {
     if (Double.IsNaN(floatValue))
     {
         throw new DomException(DomExceptionType.InvalidAccessErr);
     }
     else
     {
         double ret = Double.NaN;
         switch (PrimitiveType)
         {
             case CssPrimitiveType.Percentage:
                 if (unitType == CssPrimitiveType.Percentage) ret = floatValue;
                 break;
             case CssPrimitiveType.Ms:
                 if (unitType == CssPrimitiveType.Ms) ret = floatValue;
                 else if (unitType == CssPrimitiveType.S) ret = floatValue / 1000;
                 break;
             case CssPrimitiveType.S:
                 if (unitType == CssPrimitiveType.Ms) ret = floatValue * 1000;
                 else if (unitType == CssPrimitiveType.S) ret = floatValue;
                 break;
             case CssPrimitiveType.Hz:
                 if (unitType == CssPrimitiveType.Hz) ret = floatValue;
                 else if (unitType == CssPrimitiveType.KHz) ret = floatValue / 1000;
                 break;
             case CssPrimitiveType.KHz:
                 if (unitType == CssPrimitiveType.Hz) ret = floatValue * 1000;
                 else if (unitType == CssPrimitiveType.KHz) ret = floatValue;
                 break;
             case CssPrimitiveType.Dimension:
                 if (unitType == CssPrimitiveType.Dimension) ret = floatValue;
                 break;
         }
         if (Double.IsNaN(ret))
         {
             throw new DomException(DomExceptionType.InvalidAccessErr);
         }
         else
         {
             return ret;
         }
     }
 }
Пример #24
0
 protected void _setType(CssPrimitiveType type)
 {
     _primitiveType = type;
 }
Пример #25
0
        public override double GetFloatValue(CssPrimitiveType unitType)
        {
            double ret = double.NaN;

            switch (PrimitiveType)
            {
            case CssPrimitiveType.Number:
            case CssPrimitiveType.Px:
            case CssPrimitiveType.Cm:
            case CssPrimitiveType.Mm:
            case CssPrimitiveType.In:
            case CssPrimitiveType.Pt:
            case CssPrimitiveType.Pc:
                if (unitType == CssPrimitiveType.Px)
                {
                    ret = _getPxLength();
                }
                else if (unitType == CssPrimitiveType.Number)
                {
                    ret = _getPxLength();
                }
                else if (unitType == CssPrimitiveType.In)
                {
                    ret = _getInLength();
                }
                else if (unitType == CssPrimitiveType.Cm)
                {
                    ret = _getInLength() * CmPerIn;
                }
                else if (unitType == CssPrimitiveType.Mm)
                {
                    ret = _getInLength() * CmPerIn * 10;
                }
                else if (unitType == CssPrimitiveType.Pt)
                {
                    ret = _getInLength() * 72;
                }
                else if (unitType == CssPrimitiveType.Pc)
                {
                    ret = _getInLength() * 6;
                }
                break;

            case CssPrimitiveType.Percentage:
                if (unitType == CssPrimitiveType.Percentage)
                {
                    ret = floatValue;
                }
                break;

            case CssPrimitiveType.Ems:
                if (unitType == CssPrimitiveType.Ems)
                {
                    ret = floatValue;
                }
                break;

            case CssPrimitiveType.Exs:
                if (unitType == CssPrimitiveType.Exs)
                {
                    ret = floatValue;
                }
                break;
            }
            if (double.IsNaN(ret))
            {
                throw new DomException(DomExceptionType.InvalidAccessErr);
            }
            return(ret);
        }
        public override double GetFloatValue(CssPrimitiveType unitType)
        {
            double ret = double.NaN;

            switch (this.PrimitiveType)
            {
            case CssPrimitiveType.Number:
            case CssPrimitiveType.Px:
            case CssPrimitiveType.Cm:
            case CssPrimitiveType.Mm:
            case CssPrimitiveType.In:
            case CssPrimitiveType.Pt:
            case CssPrimitiveType.Pc:
                switch (unitType)
                {
                case CssPrimitiveType.Px:
                    ret = GetPxLength();
                    break;

                case CssPrimitiveType.Number:
                    ret = GetPxLength();
                    break;

                case CssPrimitiveType.In:
                    ret = GetInchLength();
                    break;

                case CssPrimitiveType.Cm:
                    ret = GetInchLength() * CmPerIn;
                    break;

                case CssPrimitiveType.Mm:
                    ret = GetInchLength() * CmPerIn * 10;
                    break;

                case CssPrimitiveType.Pt:
                    ret = GetInchLength() * 72;
                    break;

                case CssPrimitiveType.Pc:
                    ret = GetInchLength() * 6;
                    break;
                }
                break;

            case CssPrimitiveType.Percentage:
                if (unitType == CssPrimitiveType.Percentage)
                {
                    ret = _floatValue;
                }
                break;

            case CssPrimitiveType.Ems:
                if (unitType == CssPrimitiveType.Ems)
                {
                    ret = _floatValue;
                }
                break;

            case CssPrimitiveType.Exs:
                if (unitType == CssPrimitiveType.Exs)
                {
                    ret = _floatValue;
                }
                break;
            }
            if (double.IsNaN(ret))
            {
                throw new DomException(DomExceptionType.InvalidAccessErr);
            }
            return(ret);
        }
Пример #27
0
 /// <summary>
 /// A method to set the string value with the specified unit. If the property attached to this value can't accept the specified unit or the string value, the value will be unchanged and a DOMException will be raised.
 /// </summary>
 /// <param name="stringType">A string code as defined above. The string code can only be a string unit type (i.e. CSS_STRING, CSS_URI, CSS_IDENT, and CSS_ATTR).</param>
 /// <param name="stringValue">The new string value</param>
 /// <exception cref="DomException">INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value.</exception>
 /// <exception cref="DomException">NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.</exception>
 public virtual void SetStringValue(CssPrimitiveType stringType, string stringValue)
 {
     throw new NotImplementedException("SetStringValue");
 }