From 7f9eb19a7dfa557c6179aa71334b58502e15ff7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=BA=A2=E5=B8=BD?= <761716178@qq.com> Date: Thu, 18 Jan 2024 22:09:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3SVG=E9=80=8F=E6=98=8E?= =?UTF-8?q?=E5=BA=A6=E5=92=8C=E6=B8=90=E5=8F=98=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF/Controls/Picture.cs | 4 + CPF/Controls/View.cs | 5 + CPF/Controls/Window.cs | 10 +- CPF/Svg/PaintServer.cs | 16 +- CPF/Svg/PathShape.cs | 448 ++++++++++++++++++++-------------------- CPF/Svg/SVG.cs | 27 ++- CPF/Svg/Shapes.cs | 68 +++--- CPF/Svg/SvgFill.cs | 8 +- 8 files changed, 318 insertions(+), 268 deletions(-) diff --git a/CPF/Controls/Picture.cs b/CPF/Controls/Picture.cs index 9b10a67..d9cf09c 100644 --- a/CPF/Controls/Picture.cs +++ b/CPF/Controls/Picture.cs @@ -217,6 +217,10 @@ namespace CPF.Controls { Invoke(() => { + if (!s.Equals(Source)) + { + return; + } SetImage(a); needDisposeImg = false; if (a == null) diff --git a/CPF/Controls/View.cs b/CPF/Controls/View.cs index f5b4662..4a4b0c7 100644 --- a/CPF/Controls/View.cs +++ b/CPF/Controls/View.cs @@ -2512,6 +2512,11 @@ namespace CPF.Controls { views.TryRemove(this, out _); base.Dispose(disposing); + if (viewImpl != null) + { + viewImpl.Dispose(); + //viewImpl = null; + } } } /// diff --git a/CPF/Controls/Window.cs b/CPF/Controls/Window.cs index 683ab32..e7d80da 100644 --- a/CPF/Controls/Window.cs +++ b/CPF/Controls/Window.cs @@ -529,11 +529,11 @@ namespace CPF.Controls RaiseEvent(e, nameof(Closed)); } - protected override void Dispose(bool disposing) - { - windowImpl.Dispose(); - base.Dispose(disposing); - } + //protected override void Dispose(bool disposing) + //{ + // windowImpl.Dispose(); + // base.Dispose(disposing); + //} } public class ClosingEventArgs : EventArgs diff --git a/CPF/Svg/PaintServer.cs b/CPF/Svg/PaintServer.cs index 7b01dff..401eb6a 100644 --- a/CPF/Svg/PaintServer.cs +++ b/CPF/Svg/PaintServer.cs @@ -147,8 +147,8 @@ namespace CPF.Svg public override ViewFill GetBrush(double opacity) { - byte a = (byte)(255 * opacity / 100); Color c = Color; + byte a = (byte)(c.A * opacity / 100); Color newcol = Color.FromArgb(a, c.R, c.G, c.B); if (sb == null || sb.IsDisposed) { @@ -158,7 +158,7 @@ namespace CPF.Svg return sb; } } - abstract class GradientColor : PaintServer + internal abstract class GradientColor : PaintServer { // http://www.w3.org/TR/SVG11/pservers.html#LinearGradients List m_stops = new List(); @@ -244,7 +244,11 @@ namespace CPF.Svg { LinearGradientFill b = new LinearGradientFill(); foreach (GradientStop stop in Stops) - b.GradientStops.Add(stop); + { + var c = stop.Color; + byte a = (byte)(c.A * opacity / 100); + b.GradientStops.Add(new GradientStop(Color.FromArgb(a, c.R, c.G, c.B), stop.Position)); + } //b.MappingMode = BrushMappingMode.RelativeToBoundingBox; b.StartPoint = "0, 0"; @@ -336,7 +340,11 @@ namespace CPF.Svg { RadialGradientFill b = new RadialGradientFill(); foreach (GradientStop stop in Stops) - b.GradientStops.Add(stop); + { + var c = stop.Color; + byte a = (byte)(c.A * opacity / 100); + b.GradientStops.Add(new GradientStop(Color.FromArgb(a, c.R, c.G, c.B), stop.Position)); + } //b.GradientOrigin = new System.Windows.Point(0.5, 0.5); b.Center = "50%,50%"; diff --git a/CPF/Svg/PathShape.cs b/CPF/Svg/PathShape.cs index ab7afe4..aa3b7b7 100644 --- a/CPF/Svg/PathShape.cs +++ b/CPF/Svg/PathShape.cs @@ -7,240 +7,240 @@ using CPF.Drawing; namespace CPF.Svg { - class PathShape : SvgShape - { - //public class CommandSplitter - //{ - // // http://www.w3.org/TR/SVGTiny12/paths.html - // // command is from one non numeric character to the next (-.,space is part of the numeric value since it defines a point) - // string m_value; - // int m_curPos = -1; - // char[] m_commands = new char[] {'m', 'M', 'z', 'Z', 'A', 'a', 'L', 'l', 'h', 'H', 'v', 'V', 'c', 'C', 's', 'S' }; - // public CommandSplitter(string value) - // { - // m_value = value; - // } - // public string ReadNext() - // { - // int startpos = m_curPos; - // if (startpos < 0) - // startpos = 0; - // if (startpos >= m_value.Length) - // return string.Empty; - // int cmdstart = m_value.IndexOfAny(m_commands, startpos); - // int cmdend = cmdstart; - // if (cmdstart >= 0) - // cmdend = m_value.IndexOfAny(m_commands, cmdstart+1); - // if (cmdend < 0) - // { - // int len = m_value.Length - startpos; - // m_curPos = m_value.Length; - // return m_value.Substring(startpos, len).Trim(); - // } - // else - // { - // int len = cmdend - startpos; - // m_curPos = cmdend; - // return m_value.Substring(startpos, len).Trim(); - // } - // } - - // ShapeUtil.StringSplitter m_splitter = new ShapeUtil.StringSplitter(string.Empty); - // public ShapeUtil.StringSplitter SplitCommand(string command, out char cmd) - // { - // cmd = command[0]; - // m_splitter.SetString(command, 1); - // return m_splitter; - // } - //} - //public class PathElement - //{ - // public char Command { get; protected set; } - // public bool IsRelative - // { - // get - // { - // return char.IsLower(Command); - // } - // } - // protected PathElement(char command) - // { - // Command = command; - // } - //} - //public class MoveTo : PathElement - //{ - // public Point Point { get; private set; } - // public MoveTo(char command, ShapeUtil.StringSplitter value) : base(command) - // { - // Point = value.ReadNextPoint(); - // } - //} - //public class LineTo : PathElement - //{ - // public enum eType - // { - // Point, - // Horizontal, - // Vertical, - // } - // public eType PositionType { get; private set; } - // public Point[] Points { get; private set; } - // public LineTo(char command, ShapeUtil.StringSplitter value) : base(command) - // { - // if (char.ToLower(command) == 'h') - // { - // PositionType = eType.Horizontal; - // double v = value.ReadNextValue(); - // Points = new Point[] { new Point((float)v, 0) }; - // return; - // } - // if (char.ToLower(command) == 'v') - // { - // PositionType = eType.Vertical; - // double v = value.ReadNextValue(); - // Points = new Point[] { new Point(0, (float)v) }; - // return; - // } - - // PositionType = eType.Point; - // List list = new List(); - // while (value.More) - // { - // Point p = value.ReadNextPoint(); - // list.Add(p); - // } - // Points = list.ToArray(); - // } - //} + class PathShape : SvgShape + { + //public class CommandSplitter + //{ + // // http://www.w3.org/TR/SVGTiny12/paths.html + // // command is from one non numeric character to the next (-.,space is part of the numeric value since it defines a point) + // string m_value; + // int m_curPos = -1; + // char[] m_commands = new char[] {'m', 'M', 'z', 'Z', 'A', 'a', 'L', 'l', 'h', 'H', 'v', 'V', 'c', 'C', 's', 'S' }; + // public CommandSplitter(string value) + // { + // m_value = value; + // } + // public string ReadNext() + // { + // int startpos = m_curPos; + // if (startpos < 0) + // startpos = 0; + // if (startpos >= m_value.Length) + // return string.Empty; + // int cmdstart = m_value.IndexOfAny(m_commands, startpos); + // int cmdend = cmdstart; + // if (cmdstart >= 0) + // cmdend = m_value.IndexOfAny(m_commands, cmdstart+1); + // if (cmdend < 0) + // { + // int len = m_value.Length - startpos; + // m_curPos = m_value.Length; + // return m_value.Substring(startpos, len).Trim(); + // } + // else + // { + // int len = cmdend - startpos; + // m_curPos = cmdend; + // return m_value.Substring(startpos, len).Trim(); + // } + // } - //public class CurveTo : PathElement - //{ - // public Point CtrlPoint1 { get; private set; } - // public Point CtrlPoint2 { get; private set; } - // public Point Point { get; private set; } - // public CurveTo(char command, ShapeUtil.StringSplitter value) : base(command) - // { - // CtrlPoint1 = value.ReadNextPoint(); - // CtrlPoint2 = value.ReadNextPoint(); - // Point = value.ReadNextPoint(); - // } - // public CurveTo(char command, ShapeUtil.StringSplitter value, Point ctrlPoint1) : base(command) - // { - // CtrlPoint1 = ctrlPoint1; - // CtrlPoint2 = value.ReadNextPoint(); - // Point = value.ReadNextPoint(); - // } - //} - //public class EllipticalArcTo : PathElement - //{ - // public double RX { get; private set; } - // public double RY { get; private set; } - // public double AxisRotation { get; private set; } - // public double X { get; private set; } - // public double Y { get; private set; } - // public bool Clockwise { get; private set; } - // public bool LargeArc { get; private set; } - // public EllipticalArcTo(char command, ShapeUtil.StringSplitter value) : base(command) - // { - // RX = value.ReadNextValue(); - // RY = value.ReadNextValue(); - // AxisRotation = value.ReadNextValue(); - // double arcflag = value.ReadNextValue(); - // LargeArc = (arcflag > 0); - // double sweepflag = value.ReadNextValue(); - // Clockwise = (sweepflag > 0); - // X = value.ReadNextValue(); - // Y = value.ReadNextValue(); - // } - //} - //List m_elements = new List(); + // ShapeUtil.StringSplitter m_splitter = new ShapeUtil.StringSplitter(string.Empty); + // public ShapeUtil.StringSplitter SplitCommand(string command, out char cmd) + // { + // cmd = command[0]; + // m_splitter.SetString(command, 1); + // return m_splitter; + // } + //} + //public class PathElement + //{ + // public char Command { get; protected set; } + // public bool IsRelative + // { + // get + // { + // return char.IsLower(Command); + // } + // } + // protected PathElement(char command) + // { + // Command = command; + // } + //} + //public class MoveTo : PathElement + //{ + // public Point Point { get; private set; } + // public MoveTo(char command, ShapeUtil.StringSplitter value) : base(command) + // { + // Point = value.ReadNextPoint(); + // } + //} + //public class LineTo : PathElement + //{ + // public enum eType + // { + // Point, + // Horizontal, + // Vertical, + // } + // public eType PositionType { get; private set; } + // public Point[] Points { get; private set; } + // public LineTo(char command, ShapeUtil.StringSplitter value) : base(command) + // { + // if (char.ToLower(command) == 'h') + // { + // PositionType = eType.Horizontal; + // double v = value.ReadNextValue(); + // Points = new Point[] { new Point((float)v, 0) }; + // return; + // } + // if (char.ToLower(command) == 'v') + // { + // PositionType = eType.Vertical; + // double v = value.ReadNextValue(); + // Points = new Point[] { new Point(0, (float)v) }; + // return; + // } - //public IList Elements - //{ - // get - // { - // return m_elements.AsReadOnly(); - // } - //} + // PositionType = eType.Point; + // List list = new List(); + // while (value.More) + // { + // Point p = value.ReadNextPoint(); + // list.Add(p); + // } + // Points = list.ToArray(); + // } + //} - public string Data { get; set; } + //public class CurveTo : PathElement + //{ + // public Point CtrlPoint1 { get; private set; } + // public Point CtrlPoint2 { get; private set; } + // public Point Point { get; private set; } + // public CurveTo(char command, ShapeUtil.StringSplitter value) : base(command) + // { + // CtrlPoint1 = value.ReadNextPoint(); + // CtrlPoint2 = value.ReadNextPoint(); + // Point = value.ReadNextPoint(); + // } + // public CurveTo(char command, ShapeUtil.StringSplitter value, Point ctrlPoint1) : base(command) + // { + // CtrlPoint1 = ctrlPoint1; + // CtrlPoint2 = value.ReadNextPoint(); + // Point = value.ReadNextPoint(); + // } + //} + //public class EllipticalArcTo : PathElement + //{ + // public double RX { get; private set; } + // public double RY { get; private set; } + // public double AxisRotation { get; private set; } + // public double X { get; private set; } + // public double Y { get; private set; } + // public bool Clockwise { get; private set; } + // public bool LargeArc { get; private set; } + // public EllipticalArcTo(char command, ShapeUtil.StringSplitter value) : base(command) + // { + // RX = value.ReadNextValue(); + // RY = value.ReadNextValue(); + // AxisRotation = value.ReadNextValue(); + // double arcflag = value.ReadNextValue(); + // LargeArc = (arcflag > 0); + // double sweepflag = value.ReadNextValue(); + // Clockwise = (sweepflag > 0); + // X = value.ReadNextValue(); + // Y = value.ReadNextValue(); + // } + //} + //List m_elements = new List(); - //public bool ClosePath { get; private set;} - // http://apike.ca/prog_svg_paths.html - public PathShape(XmlNode node) : base(node) - { - //ClosePath = false; - string path = XmlUtil.AttrValue(node, "d", string.Empty); - Data = path; - //CommandSplitter cmd = new CommandSplitter(path); - //string commandstring; - //char command; - //List elements = m_elements; - //while (true) - //{ - // commandstring = cmd.ReadNext(); - // if (commandstring.Length == 0) - // break; - // ShapeUtil.StringSplitter split = cmd.SplitCommand(commandstring, out command); - // if (command == 'm' || command == 'M') - // { - // elements.Add(new MoveTo(command, split)); - // if (split.More) - // elements.Add(new LineTo(command, split)); - // continue; - // } - // if (command == 'l' || command == 'L' || command == 'H' || command == 'h' || command == 'V' || command == 'v') - // { - // elements.Add(new LineTo(command, split)); - // continue; - // } - // if (command == 'c' || command == 'C') - // { - // while (split.More) - // elements.Add(new CurveTo(command, split)); - // continue; - // } - // if (command == 's' || command == 'S') - // { - // while (split.More) - // { - // CurveTo lastshape = elements[elements.Count - 1] as CurveTo; - // System.Diagnostics.Debug.Assert(lastshape != null); - // elements.Add(new CurveTo(command, split, lastshape.CtrlPoint2)); - // } - // continue; - // } - // if (command == 'a' || command == 'A') - // { - // elements.Add(new EllipticalArcTo(command, split)); - // while (split.More) - // elements.Add(new EllipticalArcTo(command, split)); - // continue; - // } - // if (command == 'z' || command == 'Z') - // { - // ClosePath = true; - // continue; - // } + //public IList Elements + //{ + // get + // { + // return m_elements.AsReadOnly(); + // } + //} - // // extended format moveto or lineto can contain multiple points which should be translated into lineto - // PathElement lastitem = elements[elements.Count-1]; - // if (lastitem is MoveTo || lastitem is LineTo || lastitem is CurveTo) - // { - // //Point p = Point.Parse(s); - // //elements.Add(new LineTo(p)); - // continue; - // } + public string Data { get; set; } + + //public bool ClosePath { get; private set;} + // http://apike.ca/prog_svg_paths.html + public PathShape(XmlNode node, SvgShape parent) : base(node, parent) + { + //ClosePath = false; + string path = XmlUtil.AttrValue(node, "d", string.Empty); + Data = path; + //CommandSplitter cmd = new CommandSplitter(path); + //string commandstring; + //char command; + //List elements = m_elements; + //while (true) + //{ + // commandstring = cmd.ReadNext(); + // if (commandstring.Length == 0) + // break; + // ShapeUtil.StringSplitter split = cmd.SplitCommand(commandstring, out command); + // if (command == 'm' || command == 'M') + // { + // elements.Add(new MoveTo(command, split)); + // if (split.More) + // elements.Add(new LineTo(command, split)); + // continue; + // } + // if (command == 'l' || command == 'L' || command == 'H' || command == 'h' || command == 'V' || command == 'v') + // { + // elements.Add(new LineTo(command, split)); + // continue; + // } + // if (command == 'c' || command == 'C') + // { + // while (split.More) + // elements.Add(new CurveTo(command, split)); + // continue; + // } + // if (command == 's' || command == 'S') + // { + // while (split.More) + // { + // CurveTo lastshape = elements[elements.Count - 1] as CurveTo; + // System.Diagnostics.Debug.Assert(lastshape != null); + // elements.Add(new CurveTo(command, split, lastshape.CtrlPoint2)); + // } + // continue; + // } + // if (command == 'a' || command == 'A') + // { + // elements.Add(new EllipticalArcTo(command, split)); + // while (split.More) + // elements.Add(new EllipticalArcTo(command, split)); + // continue; + // } + // if (command == 'z' || command == 'Z') + // { + // ClosePath = true; + // continue; + // } + + // // extended format moveto or lineto can contain multiple points which should be translated into lineto + // PathElement lastitem = elements[elements.Count-1]; + // if (lastitem is MoveTo || lastitem is LineTo || lastitem is CurveTo) + // { + // //Point p = Point.Parse(s); + // //elements.Add(new LineTo(p)); + // continue; + // } - // System.Diagnostics.Debug.Assert(false, string.Format("type '{0}' not supported", commandstring)); - //} - } + // System.Diagnostics.Debug.Assert(false, string.Format("type '{0}' not supported", commandstring)); + //} + } public override PathGeometry CreateGeometry() { - return Data; + return Data; } } } diff --git a/CPF/Svg/SVG.cs b/CPF/Svg/SVG.cs index 0b3b56f..3a628be 100644 --- a/CPF/Svg/SVG.cs +++ b/CPF/Svg/SVG.cs @@ -206,7 +206,10 @@ namespace CPF.Svg var fill = Fill; foreach (var item in m_elements) { - item.GetFill().FillBrush = fill; + if (item.GetFill().Color == null) + { + item.GetFill().FillBrush = fill; + } } } @@ -245,7 +248,10 @@ namespace CPF.Svg var fill = newValue as ViewFill; foreach (var item in m_elements) { - item.GetFill().FillBrush = fill; + if (item.GetFill().Color == null) + { + item.GetFill().FillBrush = fill; + } } } @@ -505,9 +511,22 @@ namespace CPF.Svg } if (item.Fill != null && item.Fill.FillBrush != null) { - using (var brush = item.Fill.FillBrush.CreateBrush(item.Geometry.GetBounds(), Root.RenderScaling)) + if (item.Fill.Color is GradientColor svgFill) { - dc.FillPath(brush, item.Geometry); + using (var brush = item.Fill.FillBrush.CreateBrush(svgFill.GradientUnits == SVGTags.sGradientUserSpace ? new Rect(0, 0, naturalSize.Width, naturalSize.Height) : item.Geometry.GetBounds(), Root.RenderScaling)) + { + dc.FillPath(brush, item.Geometry); + } + } + else + { + if (item.Fill.Color != null) + { + using (var brush = item.Fill.FillBrush.CreateBrush(item.Geometry.GetBounds(), Root.RenderScaling)) + { + dc.FillPath(brush, item.Geometry); + } + } } } } diff --git a/CPF/Svg/Shapes.cs b/CPF/Svg/Shapes.cs index 48dcf92..dcaf241 100644 --- a/CPF/Svg/Shapes.cs +++ b/CPF/Svg/Shapes.cs @@ -63,8 +63,8 @@ namespace CPF.Svg public float Opacity { get; set; } = 1; public virtual Transform Transform { get; private set; } - public SvgShape Parent { get; set; } - public SvgShape(XmlNode node) : this(node, null) { } + public SvgShape Parent { get; private set; } + //public SvgShape(XmlNode node) : this(node, null) { } public SvgShape(XmlNode node, SvgShape parent) : base(node) { Parent = parent; @@ -83,6 +83,18 @@ namespace CPF.Svg m_stroke.Opacity *= Opacity; } } + if (parent != null && parent.Opacity != 1) + { + if (m_fill != null) + { + m_fill.Opacity *= parent.Opacity; + m_fill.FillBrush = null; + } + if (m_stroke != null) + { + m_stroke.Opacity *= parent.Opacity; + } + } } } public SvgShape(List attrs, SvgShape parent) : base(null) @@ -308,7 +320,7 @@ namespace CPF.Svg public float Height { get; set; } public float RX { get; set; } public float RY { get; set; } - public RectangleShape(XmlNode node) : base(node) + public RectangleShape(XmlNode node, SvgShape parent) : base(node, parent) { X = (float)XmlUtil.AttrValue(node, "x", 0); Y = (float)XmlUtil.AttrValue(node, "y", 0); @@ -399,7 +411,7 @@ namespace CPF.Svg public float CX { get; set; } public float CY { get; set; } public float R { get; set; } - public CircleShape(XmlNode node) : base(node) + public CircleShape(XmlNode node, SvgShape parent) : base(node, parent) { CX = (float)XmlUtil.AttrValue(node, "cx", 0); CY = (float)XmlUtil.AttrValue(node, "cy", 0); @@ -456,7 +468,7 @@ namespace CPF.Svg public float CY { get; set; } public float RX { get; set; } public float RY { get; set; } - public EllipseShape(XmlNode node) : base(node) + public EllipseShape(XmlNode node, SvgShape parent) : base(node, parent) { CX = (float)XmlUtil.AttrValue(node, "cx", 0); CY = (float)XmlUtil.AttrValue(node, "cy", 0); @@ -510,7 +522,7 @@ namespace CPF.Svg { public Point P1 { get; private set; } public Point P2 { get; private set; } - public LineShape(XmlNode node) : base(node) + public LineShape(XmlNode node, SvgShape parent) : base(node, parent) { double x1 = XmlUtil.AttrValue(node, "x1", 0); double y1 = XmlUtil.AttrValue(node, "y1", 0); @@ -532,7 +544,7 @@ namespace CPF.Svg class PolylineShape : SvgShape { public Point[] Points { get; private set; } - public PolylineShape(XmlNode node) : base(node) + public PolylineShape(XmlNode node, SvgShape parent) : base(node, parent) { string points = XmlUtil.AttrValue(node, SVGTags.sPoints, string.Empty); ShapeUtil.StringSplitter split = new ShapeUtil.StringSplitter(points); @@ -562,7 +574,7 @@ namespace CPF.Svg class PolygonShape : SvgShape { public Point[] Points { get; private set; } - public PolygonShape(XmlNode node) : base(node) + public PolygonShape(XmlNode node, SvgShape parent) : base(node, parent) { string points = XmlUtil.AttrValue(node, SVGTags.sPoints, string.Empty); ShapeUtil.StringSplitter split = new ShapeUtil.StringSplitter(points); @@ -595,7 +607,7 @@ namespace CPF.Svg public double X { get; set; } public double Y { get; set; } public string hRef { get; set; } - public UseShape(XmlNode node) : base(node) + public UseShape(XmlNode node, SvgShape parent) : base(node, parent) { X = XmlUtil.AttrValue(node, "x", 0); Y = XmlUtil.AttrValue(node, "y", 0); @@ -646,21 +658,21 @@ namespace CPF.Svg get { return m_elements; } } - SvgShape AddChild(SvgShape shape) + //SvgShape AddChild(SvgShape shape) + //{ + // m_elements.Add(shape); + // shape.Parent = this; + // return shape; + //} + public Group(XmlNode node, SvgShape parent) : base(node, parent) { - m_elements.Add(shape); - shape.Parent = this; - return shape; - } - public Group(XmlNode node, SvgShape parent) : base(node) - { - // parent on group must be set before children are added - this.Parent = parent; + //// parent on group must be set before children are added + //this.Parent = parent; foreach (XmlNode childnode in node.ChildNodes) { SvgShape shape = AddToList(m_elements, childnode, this); - if (shape != null) - shape.Parent = this; + //if (shape != null) + // shape.Parent = this; } //if (Id.Length > 0) // svg.AddShape(Id, this); @@ -671,37 +683,37 @@ namespace CPF.Svg return null; if (childnode.Name == SVGTags.sShapeRect) { - list.Add(new RectangleShape(childnode)); + list.Add(new RectangleShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapeCircle) { - list.Add(new CircleShape(childnode)); + list.Add(new CircleShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapeEllipse) { - list.Add(new EllipseShape(childnode)); + list.Add(new EllipseShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapeLine) { - list.Add(new LineShape(childnode)); + list.Add(new LineShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapePolyline) { - list.Add(new PolylineShape(childnode)); + list.Add(new PolylineShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapePolygon) { - list.Add(new PolygonShape(childnode)); + list.Add(new PolygonShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapePath) { - list.Add(new PathShape(childnode)); + list.Add(new PathShape(childnode, parent)); return list[list.Count - 1]; } if (childnode.Name == SVGTags.sShapeGroup) @@ -726,7 +738,7 @@ namespace CPF.Svg } if (childnode.Name == SVGTags.sShapeUse) { - list.Add(new UseShape(childnode)); + list.Add(new UseShape(childnode, parent)); return list[list.Count - 1]; } //if (childnode.Name == SVGTags.sShapeImage) diff --git a/CPF/Svg/SvgFill.cs b/CPF/Svg/SvgFill.cs index 30aa05f..0a8fba7 100644 --- a/CPF/Svg/SvgFill.cs +++ b/CPF/Svg/SvgFill.cs @@ -25,11 +25,13 @@ namespace CPF.Svg get { - if (Color != null) - return Color.GetBrush(Opacity); if (fillBrush != null) return fillBrush; - return null; + if (Color != null) + { + return Color.GetBrush(Opacity); + } + return fillBrush; } set