public static bool TryGetDashArray(SvgStyleableElement element, double strokeWidth, out DoubleCollection dashArray) { dashArray = null; string dashArrayText = element.GetPropertyValue("stroke-dasharray"); if (string.IsNullOrWhiteSpace(dashArrayText)) { return(false); } if (dashArrayText.Equals(CssConstants.ValNone, StringComparison.OrdinalIgnoreCase)) { return(false); } else { SvgNumberList list = new SvgNumberList(dashArrayText); uint len = list.NumberOfItems; dashArray = new DoubleCollection((int)len); for (uint i = 0; i < len; i++) { //divide by strokeWidth to take care of the difference between Svg and WPF dashArray.Add(list.GetItem(i).Value / strokeWidth); } return(true); } }
private float[] GetDashArray(float strokeWidth) { string dashArray = _element.GetPropertyValue("stroke-dasharray"); if (dashArray.Length == 0 || dashArray == "none") { return(null); } else { SvgNumberList list = new SvgNumberList(dashArray); uint len = list.NumberOfItems; float[] fDashArray = new float[len]; for (uint i = 0; i < len; i++) { //divide by strokeWidth to take care of the difference between Svg and GDI+ fDashArray[i] = (float)(list.GetItem(i).Value / strokeWidth); } if (len % 2 == 1) { //odd number of values, duplicate float[] tmpArray = new float[len * 2]; fDashArray.CopyTo(tmpArray, 0); fDashArray.CopyTo(tmpArray, (int)len); fDashArray = tmpArray; } return(fDashArray); } }
private DoubleCollection GetDashArray(double strokeWidth) { string dashArrayText = _element.GetPropertyValue("stroke-dasharray"); if (String.IsNullOrEmpty(dashArrayText)) { return(null); } if (dashArrayText == "none") { return(null); } else { SvgNumberList list = new SvgNumberList(dashArrayText); uint len = list.NumberOfItems; //float[] fDashArray = new float[len]; DoubleCollection dashArray = new DoubleCollection((int)len); for (uint i = 0; i < len; i++) { //divide by strokeWidth to take care of the difference between Svg and WPF dashArray.Add(list.GetItem(i).Value / strokeWidth); } return(dashArray); } }
public static bool TryGetDashArray(SvgStyleableElement element, double strokeWidth, out DoubleCollection dashArray) { dashArray = null; string dashArrayText = element.GetPropertyValue("stroke-dasharray"); if (String.IsNullOrEmpty(dashArrayText)) { return(false); } if (dashArrayText == "none") { return(false); } else { SvgNumberList list = new SvgNumberList(dashArrayText); uint len = list.NumberOfItems; dashArray = new DoubleCollection((int)len); for (uint i = 0; i < len; i++) { //divide by strokeWidth to take care of the difference between Svg and WPF dashArray.Add(list.GetItem(i).Value / strokeWidth); } return(true); } }
private float[] GetDashArray(float strokeWidth) { string dashArray = _element.GetPropertyValue("stroke-dasharray"); if (string.IsNullOrWhiteSpace(dashArray) || dashArray.Equals(CssConstants.ValNone, StringComparison.OrdinalIgnoreCase)) { return(null); } SvgNumberList list = new SvgNumberList(dashArray); uint len = list.NumberOfItems; float[] fDashArray = new float[len]; for (uint i = 0; i < len; i++) { // divide by strokeWidth to take care of the difference between Svg and GDI+ fDashArray[i] = (float)(list.GetItem(i).Value / strokeWidth); } if (len % 2 == 1) { // odd number of values, duplicate float[] tmpArray = new float[len * 2]; fDashArray.CopyTo(tmpArray, 0); fDashArray.CopyTo(tmpArray, (int)len); fDashArray = tmpArray; } return(fDashArray); }
private DoubleCollection GetDashArray(double strokeWidth) { string dashArrayText = _element.GetPropertyValue("stroke-dasharray"); if (string.IsNullOrWhiteSpace(dashArrayText)) { return(null); } if (dashArrayText.Equals("none", StringComparison.OrdinalIgnoreCase) || dashArrayText.Equals("null", StringComparison.OrdinalIgnoreCase)) { // NOTE: Rule changed in Second Edition of Test Suite 1.1 //string dashArrayAttr = _element.GetAttribute("stroke-dasharray"); //if (string.IsNullOrWhiteSpace(dashArrayAttr) || // dashArrayAttr.Equals("none", StringComparison.OrdinalIgnoreCase) // || dashArrayAttr.Equals("null", StringComparison.OrdinalIgnoreCase)) //{ // return null; //} //dashArrayText = dashArrayAttr; return(null); } SvgNumberList list = new SvgNumberList(dashArrayText); uint len = list.NumberOfItems; DoubleCollection dashArray = new DoubleCollection((int)len); for (uint i = 0; i < len; i++) { //divide by strokeWidth to take care of the difference between Svg and WPF dashArray.Add(list.GetItem(i).Value / strokeWidth); } return(dashArray); }