public new void ReadContent(XmlElement xmlElement, SvgReader svgReader) { base.ReadContent(xmlElement, svgReader); _text = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgText) { _text = svgNode as SvgText; } } if (_text != null) { break; } } if (_text != null) { ReadText(_text); } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoText); } }
public void Deserialize(Stream stream, ICanvas canvas) { try { using (var packageStorage = BaseArchive.CreateArchive(stream)) { var xmlDoc = new XmlDocument(); using (var outStream = packageStorage.GetReadStream(_canvasFileName)) xmlDoc.Load(outStream); var svgReader = new SvgReader(new TypeResolver(), new VoAttributeReader()); var svgDoc = svgReader.CreateSvgNodeFromXml(xmlDoc.DocumentElement) as SvgDocument; svgReader.Read(svgDoc, xmlDoc.DocumentElement); var svgConverter = new SvgConverter(packageStorage); svgConverter.FromSvg(canvas, svgDoc); using (var cmykProfileStream = packageStorage.GetReadStream(Path.Combine(_iccFolder, _cmykProfileFileName))) canvas.CmykColorProfile = new ColorProfile(cmykProfileStream); using (var grayscaleProfileStream = packageStorage.GetReadStream(Path.Combine(_iccFolder, _grayscaleProfileFileName))) canvas.GrayscaleColorProfile = new ColorProfile(grayscaleProfileStream); using (var rgbProfileStream = packageStorage.GetReadStream(Path.Combine(_iccFolder, _rgbProfileFileName))) canvas.RgbColorProfile = new ColorProfile(rgbProfileStream); } } catch (Exception ex) { Configuration.Logger.Error(Exceptions.CanNotDeserializeCanvas, ex); throw new SerializationException(Exceptions.CanNotDeserializeCanvas, ex); } }
public void ReadContent(XmlElement xmlElement, SvgReader svgReader) { _background = null; _border = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null && childElement.Name != "clipPath") { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgVoContent) { Content = svgNode as SvgVoContent; } else if (svgNode is SvgPath) { var path = svgNode as SvgPath; if (path.ID.Contains("_background")) { _background = path; } else if (path.ID.Contains("_border")) { _border = path; } } else if (svgNode is SvgRect) { var rect = svgNode as SvgRect; if (rect.ID.Contains("_background")) { _background = RectToPath(rect); } else if (rect.ID.Contains("_border")) { _border = RectToPath(rect); } } } if (_background != null && _border != null && Content != null) { break; } } if (_background != null && _border != null) { Path = _border.Path; Fill = _background.Fill; Stroke = _border.Stroke; StrokeWidth = _border.StrokeWidth; } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoPlaceholder); } }
public new void ReadContent(XmlElement xmlElement, SvgReader svgReader) { base.ReadContent(xmlElement, svgReader); // To deserialize CurvedText we need to read path def from text tag (the last element) if (xmlElement.LastChild != null && xmlElement.LastChild.Name == "text") { xmlElement = xmlElement.LastChild as XmlElement; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgDefs) { childElement = childElement.FirstChild as XmlElement; svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgPath) { Path = Path.FromSvgPath(svgNode as SvgPath); break; } } } } } if (Path == null || Path.IsEmpty) { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoCurvedText); } }
public void ReadContent(XmlElement xmlElement, SvgReader svgReader) { _line1 = null; _line2 = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgLine) { if (_line1 == null) { _line1 = svgNode as SvgLine; } else { _line2 = svgNode as SvgLine; } } } if (_line1 != null && _line2 != null) { break; } } if (_line1 != null && _line2 != null) { X1 = _line1.X1; Y1 = _line1.Y1; X2 = _line1.X2; Y2 = _line1.Y2; StrokeWidth = _line1.StrokeWidth; Stroke = _line1.Stroke; AltStroke = _line2.Stroke; DashWidth = _line1.StrokeDashArray[0]; AltDashWidth = _line1.StrokeDashArray[1]; } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoDashLine); } }
public void ReadContent(XmlElement xmlElement, SvgReader svgReader) { _rect = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); if (svgNode is SvgRect) { svgReader.Read(svgNode, childElement); _rect = svgNode as SvgRect; } else if (childElement.Name == "svg") { Svg = childElement.OuterXml; } } if (_rect != null && Svg != null) { break; } } if (_rect != null && Svg != null) { X = _rect.X; Y = _rect.Y; Width = _rect.Width; Height = _rect.Height; Fill = _rect.Fill; Stroke = _rect.Stroke; StrokeWidth = _rect.StrokeWidth; } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoSvg); } }
public void ReadContent(XmlElement xmlElement, SvgReader svgReader) { _verticalPath = null; _horizontalPath = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgPath) { var path = svgNode as SvgPath; if (path.ID.Contains("_vertical")) { _verticalPath = path; } else if (path.ID.Contains("_horizontal")) { _horizontalPath = path; } } } if (_verticalPath != null && _horizontalPath != null) { break; } } if (_verticalPath != null && _horizontalPath != null) { StrokeWidth = _verticalPath.StrokeWidth; } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoContent); } }
public void ReadContent(XmlElement xmlElement, SvgReader svgReader) { Transform = SvgAttribute.ParseTransformAttribute(xmlElement.GetAttribute("transform")); _rect = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgRect) { _rect = svgNode as SvgRect; } } if (_rect != null) { break; } } if (_rect != null) { X = _rect.X + _rect.StrokeWidth / 2; Y = _rect.Y + _rect.StrokeWidth / 2; Width = _rect.Width - _rect.StrokeWidth; Height = _rect.Height - _rect.StrokeWidth; Fill = _rect.Fill; Stroke = _rect.Stroke; StrokeWidth = _rect.StrokeWidth; } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoContent); } }
public new void ReadContent(XmlElement xmlElement, SvgReader svgReader) { base.ReadContent(xmlElement, svgReader); _image = null; foreach (var node in xmlElement.ChildNodes) { var childElement = node as XmlElement; if (childElement != null) { var svgNode = svgReader.CreateSvgNodeFromXml(childElement); svgReader.Read(svgNode, childElement); if (svgNode is SvgImage) { _image = svgNode as SvgImage; } } if (_image != null) { break; } } if (_image != null) { Src = _image.Src; X = _image.X; Y = _image.Y; Width = _image.Width; Height = _image.Height; } else { throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoImage); } }