/// <summary>
        /// 获取值
        /// </summary>
        /// <param name="v">SVGDouble</param>
        /// <param name="max">最大值</param>
        /// <returns>真实值</returns>
        public static double GetValue(this SVGDouble v, double max = 100d)
        {
            if (v == null)
            {
                return(0d);
            }

            double result = 0d;

            if (!string.IsNullOrWhiteSpace(v.Unit) && v.Unit.Equals("%"))
            {
                result = v.Value / 100d * max;
            }
            else
            {
                result = v.Value;
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 获取基础几何图形
        /// </summary>
        /// <returns>基础几何图形</returns>
        protected override Geometry GetBaseGeometry()
        {
            double width  = this.GetAttributeValue <SVGDouble>("width", false, SVGDouble.Zero).GetValue(this.SVG.Width);
            double height = this.GetAttributeValue <SVGDouble>("height", false, SVGDouble.Zero).GetValue(this.SVG.Height);

            if (width <= 0 || height <= 0)
            {
                return(null);
            }

            double    x  = this.GetAttributeValue <SVGDouble>("x", false, SVGDouble.Zero).GetValue(this.SVG.Width);
            double    y  = this.GetAttributeValue <SVGDouble>("y", false, SVGDouble.Zero).GetValue(this.SVG.Height);
            SVGDouble rx = this.GetAttributeValue <SVGDouble>("rx");
            SVGDouble ry = this.GetAttributeValue <SVGDouble>("ry");

            RectangleGeometry geometry = new RectangleGeometry();

            geometry.Rect = new System.Windows.Rect(x, y, width, height);
            if (rx != null && ry != null)
            {
                geometry.RadiusX = rx.GetValue(width);
                geometry.RadiusY = ry.GetValue(height);
            }
            else if (rx != null && ry == null)
            {
                geometry.RadiusX = rx.GetValue(width);
                geometry.RadiusY = geometry.RadiusX;
            }
            else if (rx == null && ry != null)
            {
                geometry.RadiusX = ry.GetValue(height);
                geometry.RadiusY = geometry.RadiusX;
            }

            return(geometry);
        }