예제 #1
0
        private double CalcPatternUnit(SvgLength length, SvgLengthDirection dir, Rect bounds)
        {
            if (_patternElement.PatternUnits.AnimVal.Equals(SvgUnitType.UserSpaceOnUse))
            {
                return length.Value;
            }
            else
            {
                double calcValue = length.ValueInSpecifiedUnits;
                if (dir == SvgLengthDirection.Horizontal)
                {
                    calcValue *= bounds.Width;
                }
                else
                {
                    calcValue *= bounds.Height;
                }
                if (length.UnitType == SvgLengthType.Percentage)
                {
                    calcValue /= 100F;
                }

                return calcValue;
            }
        }
예제 #2
0
        private double CalcPatternUnit(SvgLength length, SvgLengthDirection dir, Rect bounds)
        {
            if (_patternElement.PatternUnits.AnimVal.Equals(SvgUnitType.UserSpaceOnUse))
            {
                return(length.Value);
            }
            else
            {
                double calcValue = length.ValueInSpecifiedUnits;
                if (dir == SvgLengthDirection.Horizontal)
                {
                    calcValue *= bounds.Width;
                }
                else
                {
                    calcValue *= bounds.Height;
                }
                if (length.UnitType == SvgLengthType.Percentage)
                {
                    calcValue /= 100F;
                }

                return(calcValue);
            }
        }
        private float calcPatternUnit(SvgLength length, SvgLengthDirection dir, RectangleF bounds)
        {
            int patternUnits = _patternElement.PatternUnits.AnimVal;

            if (patternUnits == (int)SvgUnitType.UserSpaceOnUse)
            {
                return((float)length.Value);
            }
            else
            {
                float calcValue = (float)length.ValueInSpecifiedUnits;
                if (dir == SvgLengthDirection.Horizontal)
                {
                    calcValue *= bounds.Width;
                }
                else
                {
                    calcValue *= bounds.Height;
                }
                if (length.UnitType == SvgLengthType.Percentage)
                {
                    calcValue /= 100F;
                }
                return(calcValue);
            }
        }
예제 #4
0
        private double getViewportProp(string propertyName, string inValue, double calcParentVP,
                                       double defaultValue, SvgLengthDirection dir)
        {
            double ret;

            inValue = inValue.Trim();

            if (inValue.Length > 0)
            {
                if (inValue.EndsWith("%", StringComparison.OrdinalIgnoreCase))
                {
                    double perc = SvgNumber.ParseNumber(inValue.Substring(0, inValue.Length - 1)) / 100;
                    ret = calcParentVP * perc;
                }
                else
                {
                    ret = new SvgLength(this, propertyName, dir, inValue, string.Empty).Value;
                }
            }
            else
            {
                ret = defaultValue;
            }

            return(ret);
        }
예제 #5
0
        public SvgLengthList(string propertyName, string listString, SvgElement ownerElement, SvgLengthDirection direction)
        {
            this.propertyName = propertyName;
            this.ownerElement = ownerElement;
            this.direction = direction;

            this.FromString(listString);
        }
예제 #6
0
        public SvgLengthList(string propertyName, string listString, SvgElement ownerElement, SvgLengthDirection direction)
        {
            this.propertyName = propertyName;
            this.ownerElement = ownerElement;
            this.direction    = direction;

            this.FromString(listString);
        }
예제 #7
0
파일: SvgLength.cs 프로젝트: naver/protonow
        /// <summary>
        /// Creates a SvgLength value
        /// </summary>
        /// <param name="baseVal">String to be parsed into a length</param>
        /// <param name="ownerElement">The associated element</param>
        /// <param name="direction">Direction of the length, used for percentages</param>
        public SvgLength(string propertyName, string baseVal, SvgElement ownerElement, SvgLengthDirection direction)
        {
            this.ownerElement = ownerElement;
            this.direction    = direction;

            baseVal = SvgNumber.ScientificToDec(baseVal);

            this.cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
        }
예제 #8
0
 public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthDirection direction, string baseVal, string defaultValue) :
     this(ownerElement, propertyName, SvgLengthSource.String, direction, defaultValue)
 {
     if (baseVal == null || baseVal.Length == 0)
     {
         baseVal = defaultValue;
     }
     baseVal   = SvgNumber.ScientificToDec(baseVal);
     cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
 }
예제 #9
0
 public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthDirection direction, string baseVal, string defaultValue)
     : this(ownerElement, propertyName, SvgLengthSource.String, direction, defaultValue)
 {
     if(baseVal == null || baseVal.Length == 0)
     {
         baseVal = defaultValue;
     }
     baseVal = SvgNumber.ScientificToDec(baseVal);
     cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
 }
예제 #10
0
        public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthSource source, SvgLengthDirection direction, string defaultValue)
        {
            this.ownerElement = ownerElement;
            this.propertyName = propertyName;
            this.direction = direction;
            this.defaultValue = defaultValue;
            this.source = source;

            if(this.source == SvgLengthSource.Xml || this.source == SvgLengthSource.Css)
            {
                getCssXmlValue();
            }
        }
예제 #11
0
파일: SvgLength.cs 프로젝트: naver/protonow
        public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthSource source,
                         SvgLengthDirection direction, string defaultValue)
        {
            this.ownerElement = ownerElement;
            this.propertyName = propertyName;
            this.direction    = direction;
            this.defaultValue = defaultValue;
            this.source       = source;

            if (this.source == SvgLengthSource.Xml || this.source == SvgLengthSource.Css)
            {
                GetCssXmlValue();
            }
        }
예제 #12
0
        public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthSource source,
                         SvgLengthDirection direction, string defaultValue)
        {
            _ownerElement = ownerElement;
            _propertyName = propertyName;
            _direction    = direction;
            _defaultValue = defaultValue;
            _source       = source;

            if (_source == SvgLengthSource.Xml || _source == SvgLengthSource.Css)
            {
                GetCssXmlValue();
            }
        }
예제 #13
0
파일: SvgLength.cs 프로젝트: naver/protonow
        public SvgLength(string propertyName, SvgStyleableElement ownerElement, SvgLengthDirection direction, string defaultValue)
        {
            this.ownerElement = ownerElement;
            this.direction    = direction;

            string baseVal = ownerElement.GetPropertyValue(propertyName);

            if (baseVal == null || baseVal == "")
            {
                baseVal = defaultValue;
            }

            baseVal = SvgNumber.ScientificToDec(baseVal);

            this.cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
        }
예제 #14
0
        public SvgLength(string propertyName, string baseVal, string defaultValue,
                         SvgElement ownerElement, SvgLengthDirection direction)
        {
            _ownerElement = ownerElement;
            _direction    = direction;

            if (baseVal == null || baseVal.Length == 0)
            {
                baseVal = defaultValue;
            }

            baseVal = SvgNumber.ScientificToDec(baseVal);

            _cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false),
                                                        propertyName, ownerElement);
        }
예제 #15
0
        public SvgLength(string propertyName, SvgStyleableElement ownerElement, SvgLengthDirection direction, string defaultValue)
        {
            _ownerElement = ownerElement;
            _direction    = direction;

            string baseVal = ownerElement.GetPropertyValue(propertyName);

            if (string.IsNullOrWhiteSpace(baseVal))
            {
                baseVal = defaultValue;
            }

            baseVal = SvgNumber.ScientificToDec(baseVal);

            _cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
        }
예제 #16
0
        protected double CalcLengthUnit(SvgLength length, SvgLengthDirection dir, Rect bounds)
        {
            double calcValue = length.ValueInSpecifiedUnits;

            if (dir == SvgLengthDirection.Horizontal)
            {
                calcValue *= bounds.Width;
            }
            else
            {
                calcValue *= bounds.Height;
            }
            if (length.UnitType == SvgLengthType.Percentage)
            {
                calcValue /= 100F;
            }

            return(calcValue);
        }
예제 #17
0
        public static float parseToFloat(string str, SvgElement ownerElement, SvgLengthDirection direction)
        {
            float  single1 = 0f;
            string text1   = str.Trim();

            if (text1 == "")
            {
                return(0f);
            }
            Regex regex1 = new Regex(@"^\-{0,1}[0-9\.]+$");

            if (regex1.IsMatch(text1))
            {
                return(ItopVector.Core.Func.Number.ParseFloatStr(text1));
            }
            regex1 = new Regex(@"^(\-{0,1}[0-9\.]+)\s*([a-z\%]+)$");
            Match match1 = regex1.Match(text1);

            if (match1.Success)
            {
                single1 = ItopVector.Core.Func.Number.ParseFloatStr(match1.Groups[1].Value);
                string text2 = match1.Groups[2].Value;
                short  num1  = -1;
                if (text2 == "%")
                {
                    num1 = 2;
                }
                else if (text2 == "em")
                {
                    num1 = 3;
                }
                else if (text2 == "ex")
                {
                    num1 = 4;
                }
                else if (text2 == "px")
                {
                    num1 = 5;
                }
                else if (text2 == "cm")
                {
                    num1 = 6;
                }
                else if (text2 == "mm")
                {
                    num1 = 7;
                }
                else if (text2 == "in")
                {
                    num1 = 8;
                }
                else if (text2 == "pt")
                {
                    num1 = 9;
                }
                else if (text2 == "pc")
                {
                    num1 = 10;
                }
                if (num1 == 0)
                {
                    single1 = 0f;
                    goto Label_02CF;
                }
                if (num1 == 1)
                {
                    single1 = single1;
                    goto Label_02CF;
                }
                if (num1 == 2)
                {
                    if ((ownerElement is IGradientBrush) || (ownerElement is GradientStop))
                    {
                        single1 *= 0.01f;
                        goto Label_02CF;
                    }
                    if (ownerElement != null)
                    {
                        ISvgElement element1;
                        if (ownerElement.ViewportElement != null)
                        {
                            element1 = ownerElement.ViewportElement;
                        }
                        else
                        {
                            element1 = ownerElement;
                        }
                        float single2 = element1.ViewPort.Width;
                        float single3 = element1.ViewPort.Height;
                        if (direction == SvgLengthDirection.Horizontal)
                        {
                            single1 = (single1 * single2) / 100f;
                            goto Label_02CF;
                        }
                        if (direction == SvgLengthDirection.Vertical)
                        {
                            single1 = (single1 * single3) / 100f;
                            goto Label_02CF;
                        }
                        single1 = (Convert.ToSingle((double)(Math.Sqrt((double)((single2 * single2) + (single3 * single3))) / Math.Sqrt(2))) * single1) / 100f;
                        goto Label_02CF;
                    }
                    single1 /= 100f;
                    goto Label_02CF;
                }
                if (num1 == 3)
                {
                    single1 *= 10f;
                }
                else
                {
                    if (num1 == 4)
                    {
                        single1 *= 5f;
                        goto Label_02CF;
                    }
                    if (num1 == 5)
                    {
                        single1 = single1;
                        goto Label_02CF;
                    }
                    if (num1 == 6)
                    {
                        single1 *= 35.43307f;
                        goto Label_02CF;
                    }
                    if (num1 == 7)
                    {
                        single1 *= 3.543307f;
                        goto Label_02CF;
                    }
                    if (num1 == 8)
                    {
                        single1 *= 90f;
                        goto Label_02CF;
                    }
                    if (num1 == 9)
                    {
                        single1 *= 1.25f;
                    }
                    else if (num1 == 10)
                    {
                        single1 *= 15f;
                    }
                    else
                    {
                        single1 = 0f;
                        throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidnumberformat") + text1);
                    }
                }
                return(single1);
            }
            single1 = 0f;
            throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidnumberformat") + text1);
Label_02CF:
            return(single1);
        }
예제 #18
0
 public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthDirection direction, string baseVal)
     : this(ownerElement, propertyName, direction, baseVal, String.Empty)
 {
 }
예제 #19
0
 /// <summary>
 /// Used for attributes of basic type 'length' which can be animated.
 /// </summary>
 /// <param name="ownerElement">The elements that contains the length</param>
 /// <param name="direction">The direction of the length, 0=x-axis, 1=y-axis, 2=no special axis</param>
 /// <param name="defaultValue">String to parse for the value</param>
 public SvgAnimatedLength(SvgElement ownerElement, string propertyName,
                          SvgLengthDirection direction, string defaultValue)
 {
     _baseVal = new SvgLength(ownerElement, propertyName, SvgLengthSource.Xml, direction, defaultValue);
     _animVal = _baseVal;
 }
 public SvgAnimatedLength(SvgElement ownerElement, string propertyName,
                          SvgLengthDirection direction, string strValue, string defaultValue)
 {
     baseVal = new SvgLength(ownerElement, propertyName, direction,
                             strValue, defaultValue);
 }
예제 #21
0
 public SvgAnimatedLengthList(string propertyName, string str, SvgElement ownerElement, SvgLengthDirection direction)
 {
     baseVal = new SvgLengthList(propertyName, str, ownerElement, direction);
     animVal = baseVal;
 }
예제 #22
0
 public static float parseToFloat(string str, SvgElement ownerElement, SvgLengthDirection direction)
 {
     float single1 = 0f;
     string text1 = str.Trim();
     if (text1 == "")
     {
         return 0f;
     }
     Regex regex1 = new Regex(@"^\-{0,1}[0-9\.]+$");
     if (regex1.IsMatch(text1))
     {
         return ItopVector.Core.Func.Number.ParseFloatStr(text1);
     }
     regex1 = new Regex(@"^(\-{0,1}[0-9\.]+)\s*([a-z\%]+)$");
     Match match1 = regex1.Match(text1);
     if (match1.Success)
     {
         single1 = ItopVector.Core.Func.Number.ParseFloatStr(match1.Groups[1].Value);
         string text2 = match1.Groups[2].Value;
         short num1 = -1;
         if (text2 == "%")
         {
             num1 = 2;
         }
         else if (text2 == "em")
         {
             num1 = 3;
         }
         else if (text2 == "ex")
         {
             num1 = 4;
         }
         else if (text2 == "px")
         {
             num1 = 5;
         }
         else if (text2 == "cm")
         {
             num1 = 6;
         }
         else if (text2 == "mm")
         {
             num1 = 7;
         }
         else if (text2 == "in")
         {
             num1 = 8;
         }
         else if (text2 == "pt")
         {
             num1 = 9;
         }
         else if (text2 == "pc")
         {
             num1 = 10;
         }
         if (num1 == 0)
         {
             single1 = 0f;
             goto Label_02CF;
         }
         if (num1 == 1)
         {
             single1 = single1;
             goto Label_02CF;
         }
         if (num1 == 2)
         {
             if ((ownerElement is IGradientBrush) || (ownerElement is GradientStop))
             {
                 single1 *= 0.01f;
                 goto Label_02CF;
             }
             if (ownerElement != null)
             {
                 ISvgElement element1;
                 if (ownerElement.ViewportElement != null)
                 {
                     element1 = ownerElement.ViewportElement;
                 }
                 else
                 {
                     element1 = ownerElement;
                 }
                 float single2 = element1.ViewPort.Width;
                 float single3 = element1.ViewPort.Height;
                 if (direction == SvgLengthDirection.Horizontal)
                 {
                     single1 = (single1 * single2) / 100f;
                     goto Label_02CF;
                 }
                 if (direction == SvgLengthDirection.Vertical)
                 {
                     single1 = (single1 * single3) / 100f;
                     goto Label_02CF;
                 }
                 single1 = (Convert.ToSingle((double) (Math.Sqrt((double) ((single2 * single2) + (single3 * single3))) / Math.Sqrt(2))) * single1) / 100f;
                 goto Label_02CF;
             }
             single1 /= 100f;
             goto Label_02CF;
         }
         if (num1 == 3)
         {
             single1 *= 10f;
         }
         else
         {
             if (num1 == 4)
             {
                 single1 *= 5f;
                 goto Label_02CF;
             }
             if (num1 == 5)
             {
                 single1 = single1;
                 goto Label_02CF;
             }
             if (num1 == 6)
             {
                 single1 *= 35.43307f;
                 goto Label_02CF;
             }
             if (num1 == 7)
             {
                 single1 *= 3.543307f;
                 goto Label_02CF;
             }
             if (num1 == 8)
             {
                 single1 *= 90f;
                 goto Label_02CF;
             }
             if (num1 == 9)
             {
                 single1 *= 1.25f;
             }
             else if (num1 == 10)
             {
                 single1 *= 15f;
             }
             else
             {
                 single1 = 0f;
                 throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidnumberformat") + text1);
             }
         }
         return single1;
     }
     single1 = 0f;
     throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidnumberformat") + text1);
     Label_02CF:
     return single1;
 }
 public SvgAnimatedLengthList(string propertyName, string str, SvgElement ownerElement, SvgLengthDirection direction)
 {
     baseVal = new SvgLengthList(propertyName, str, ownerElement, direction);
     animVal = baseVal;
 }
예제 #24
0
 public SvgAnimatedLength(SvgElement ownerElement, string propertyName, 
     SvgLengthDirection direction, string strValue, string defaultValue)
 {
     baseVal = new SvgLength(ownerElement, propertyName, direction,
         strValue, defaultValue);
 }
예제 #25
0
 public SvgLengthElementContext(SvgElement element, SvgLengthDirection dir)
 {
     _element = element ?? throw new ArgumentNullException(nameof(element));
     _dir     = dir;
 }
예제 #26
0
        public SvgLength(string propertyName, SvgStyleableElement ownerElement, SvgLengthDirection direction, string defaultValue)
        {
            this.ownerElement = ownerElement;
            this.direction = direction;

            string baseVal = ownerElement.GetPropertyValue(propertyName);
            if (baseVal == null || baseVal == "")
            {
                baseVal = defaultValue;
            }

            baseVal = SvgNumber.ScientificToDec(baseVal);

            this.cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
        }
예제 #27
0
        private double getViewportProp(string propertyName, string inValue, double calcParentVP, 
            double defaultValue, SvgLengthDirection dir)
        {
            double ret;
            inValue = inValue.Trim();

            if (inValue.Length > 0)
            {
                if (inValue.EndsWith("%"))
                {
                    double perc = SvgNumber.ParseNumber(inValue.Substring(0, inValue.Length - 1)) / 100;
                    ret = calcParentVP * perc;
                }
                else
                {
                    ret = new SvgLength(this, propertyName, dir, inValue, String.Empty).Value;
                }
            }
            else ret = defaultValue;

            return ret;
        }
예제 #28
0
 public SvgLength(SvgElement ownerElement, string propertyName, SvgLengthDirection direction, string baseVal)
     : this(ownerElement, propertyName, direction, baseVal, string.Empty)
 {
 }
예제 #29
0
 internal SvgLength(string value, SvgElement element, SvgLengthDirection direction)
     : this(value, new SvgLengthElementContext(element, direction))
 {
 }
예제 #30
0
        public SvgLength(string propertyName, string baseVal, string defaultValue, SvgElement ownerElement, SvgLengthDirection direction)
        {
            this.ownerElement = ownerElement;
            this.direction = direction;

            if (baseVal == null || baseVal.Length == 0)
            {
                baseVal = defaultValue;
            }

            baseVal = SvgNumber.ScientificToDec(baseVal);

            this.cssLength = new CssAbsPrimitiveLengthValue(new CssPrimitiveLengthValue(baseVal, false), propertyName, ownerElement);
        }