File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 33using System . Xml ;
44using System . Linq ;
55using System . Collections . Generic ;
6+ using SVGImage . SVG . Utils ;
67
78using System . Windows ;
89using System . Windows . Media ;
Original file line number Diff line number Diff line change @@ -125,6 +125,11 @@ public Stroke Stroke
125125 }
126126
127127 protected virtual Fill DefaultFill ( )
128+ {
129+ return null ;
130+ }
131+
132+ protected virtual Fill GetParentFill ( )
128133 {
129134 var parent = this . Parent ;
130135 while ( parent != null )
@@ -141,7 +146,7 @@ protected virtual Fill DefaultFill()
141146
142147 public Fill Fill
143148 {
144- get => m_fill ?? DefaultFill ( ) ;
149+ get => m_fill ?? GetParentFill ( ) ?? DefaultFill ( ) ;
145150 set => m_fill = value ;
146151 }
147152
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Windows . Media ;
3+ using System . Windows . Markup ;
4+ using System . IO ;
5+ using System . Xml ;
6+
7+ namespace SVGImage . SVG . Utils
8+ {
9+ internal static class DrawingGroupSerializer
10+ {
11+ public static string SerializeToXaml ( DrawingGroup drawingGroup )
12+ {
13+ if ( drawingGroup is null )
14+ {
15+ throw new ArgumentNullException ( nameof ( drawingGroup ) ) ;
16+ }
17+
18+ // Freezing can help ensure serialization works without exceptions
19+ if ( drawingGroup . CanFreeze && ! drawingGroup . IsFrozen )
20+ {
21+ drawingGroup . Freeze ( ) ;
22+ }
23+
24+ var settings = new XmlWriterSettings
25+ {
26+ Indent = true ,
27+ IndentChars = " " ,
28+ OmitXmlDeclaration = true
29+ } ;
30+
31+ using ( var stringWriter = new StringWriter ( ) )
32+ using ( var xmlWriter = XmlWriter . Create ( stringWriter , settings ) )
33+ {
34+ XamlWriter . Save ( drawingGroup , xmlWriter ) ;
35+ return stringWriter . ToString ( ) ;
36+ }
37+ }
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments