/// <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 given Brush data string and converts it to ICanvasBrush /// </summary> /// <param name="resourceCreator">ICanvasResourceCreator</param> /// <param name="brushData">Brush data in string format</param> /// <returns>ICanvasBrush</returns> public static ICanvasBrush CreateBrush(ICanvasResourceCreator resourceCreator, string brushData) { using (new CultureShield("en-US")) { return(CanvasBrushParser.Parse(resourceCreator, brushData)); } }
/// <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"]; float.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) {
/// <summary> /// Parses the given Brush data string and converts it to ICanvasBrush /// </summary> /// <param name="resourceCreator">ICanvasResourceCreator</param> /// <param name="brushData">Brush data in string format</param> /// <returns>ICanvasBrush</returns> public static ICanvasBrush CreateBrush(ICanvasResourceCreator resourceCreator, string brushData) { return(CanvasBrushParser.Parse(resourceCreator, brushData)); }