Ejemplo n.º 1
0
 /// <summary>
 /// Parses the give CanvasStrokeStyle data string and converts it to CanvasStrokeStyle
 /// </summary>
 /// <param name="styleData">CanvasStrokeStyle data in string format</param>
 /// <returns></returns>
 public static CanvasStrokeStyle CreateStrokeStyle(string styleData)
 {
     using (new CultureShield("en-US"))
     {
         return(CanvasStrokeStyleParser.Parse(styleData));
     }
 }
        /// <summary>
        /// Gets the Stroke Element Attributes from the Match
        /// </summary>
        /// <param name="match">Match object</param>
        protected override void GetAttributes(Match match)
        {
            // Stroke Width
            var group = match.Groups["StrokeWidth"];

            Single.TryParse(group.Value, out _width);
            // Sanitize by taking the absolute value
            _width = Math.Abs(_width);

            _widthValidationCount = RegexFactory.ValidationRegex.Replace(group.Value, String.Empty).Length;

            // Stroke Brush
            group = match.Groups["CanvasBrush"];
            if (group.Success)
            {
                _brush = CanvasBrushParser.Parse(group.Value);
            }

            // If the ICanvasBrushElement was not created, then the ICanvasStroke cannot be created
            if (_brush == null)
            {
                throw new NullReferenceException($"Unable to create a valid ICanvasBrush for the " +
                                                 $"ICanvasStroke with the following Brush data - '{group.Value}'");
            }

            // Stroke Style
            _style = CanvasStrokeStyleParser.Parse(match);
        }
 /// <summary>
 /// Parses the give CanvasStrokeStyle data string and converts it to CanvasStrokeStyle
 /// </summary>
 /// <param name="styleData">CanvasStrokeStyle data in string format</param>
 /// <returns></returns>
 public static CanvasStrokeStyle CreateStrokeStyle(string styleData)
 {
     return(CanvasStrokeStyleParser.Parse(styleData));
 }