1 | using System;
|
---|
2 | using System.IO;
|
---|
3 | using System.Xml;
|
---|
4 | using System.Text;
|
---|
5 | using System.Reflection;
|
---|
6 | using System.Collections.Generic;
|
---|
7 |
|
---|
8 | using System.Windows;
|
---|
9 | using System.Windows.Media;
|
---|
10 |
|
---|
11 | using SharpVectors.Xml;
|
---|
12 | using SharpVectors.Dom.Svg;
|
---|
13 | using SharpVectors.Dom.Events;
|
---|
14 | using SharpVectors.Dom.Stylesheets;
|
---|
15 |
|
---|
16 | namespace SharpVectors.Renderers.Utils
|
---|
17 | {
|
---|
18 | public class WpfSvgWindow : SvgWindow
|
---|
19 | {
|
---|
20 | #region Private fields
|
---|
21 |
|
---|
22 | private XmlReaderSettings _settings;
|
---|
23 |
|
---|
24 | #endregion
|
---|
25 |
|
---|
26 | #region Contructors and Destructor
|
---|
27 |
|
---|
28 | public WpfSvgWindow(long innerWidth, long innerHeight, ISvgRenderer renderer)
|
---|
29 | : base(innerWidth, innerHeight, renderer)
|
---|
30 | {
|
---|
31 | }
|
---|
32 |
|
---|
33 | public WpfSvgWindow(SvgWindow parentWindow, long innerWidth, long innerHeight)
|
---|
34 | : base(parentWindow, innerWidth, innerHeight)
|
---|
35 | {
|
---|
36 | }
|
---|
37 |
|
---|
38 | #endregion
|
---|
39 |
|
---|
40 | #region ISvgWindow Members
|
---|
41 |
|
---|
42 | public XmlReaderSettings CustomSettings
|
---|
43 | {
|
---|
44 | get
|
---|
45 | {
|
---|
46 | return _settings;
|
---|
47 | }
|
---|
48 | set
|
---|
49 | {
|
---|
50 | _settings = value;
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | public override long InnerWidth
|
---|
55 | {
|
---|
56 | get
|
---|
57 | {
|
---|
58 | return base.InnerWidth;
|
---|
59 | }
|
---|
60 | set
|
---|
61 | {
|
---|
62 | base.InnerWidth = value;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | public override long InnerHeight
|
---|
67 | {
|
---|
68 | get
|
---|
69 | {
|
---|
70 | return base.InnerHeight;
|
---|
71 | }
|
---|
72 | set
|
---|
73 | {
|
---|
74 | base.InnerHeight = value;
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | public override string Source
|
---|
79 | {
|
---|
80 | get
|
---|
81 | {
|
---|
82 | SvgDocument document = (SvgDocument)this.Document;
|
---|
83 | return (document != null) ? document.Url : String.Empty;
|
---|
84 | }
|
---|
85 | set
|
---|
86 | {
|
---|
87 | Uri uri = new Uri(new Uri(
|
---|
88 | Assembly.GetExecutingAssembly().Location), value);
|
---|
89 |
|
---|
90 | this.LoadDocument(uri);
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | public override DirectoryInfo WorkingDir
|
---|
95 | {
|
---|
96 | get
|
---|
97 | {
|
---|
98 | return WpfApplicationContext.ExecutableDirectory;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | public void LoadDocument(Uri documentUri)
|
---|
103 | {
|
---|
104 | if (documentUri == null || !documentUri.IsAbsoluteUri)
|
---|
105 | {
|
---|
106 | return;
|
---|
107 | }
|
---|
108 |
|
---|
109 | SvgDocument document = new SvgDocument(this);
|
---|
110 | if (_settings != null)
|
---|
111 | {
|
---|
112 | document.CustomSettings = _settings;
|
---|
113 | }
|
---|
114 | document.Load(documentUri.AbsoluteUri);
|
---|
115 |
|
---|
116 | this.Document = document;
|
---|
117 | }
|
---|
118 |
|
---|
119 | public void LoadDocument(string documentSource)
|
---|
120 | {
|
---|
121 | if (String.IsNullOrEmpty(documentSource))
|
---|
122 | {
|
---|
123 | return;
|
---|
124 | }
|
---|
125 |
|
---|
126 | Uri uri = new Uri(new Uri(
|
---|
127 | Assembly.GetExecutingAssembly().Location),
|
---|
128 | documentSource);
|
---|
129 |
|
---|
130 | this.LoadDocument(uri);
|
---|
131 | }
|
---|
132 |
|
---|
133 | public void LoadDocument(Stream documentStream)
|
---|
134 | {
|
---|
135 | if (documentStream == null)
|
---|
136 | {
|
---|
137 | return;
|
---|
138 | }
|
---|
139 |
|
---|
140 | SvgDocument document = new SvgDocument(this);
|
---|
141 | if (_settings != null)
|
---|
142 | {
|
---|
143 | document.CustomSettings = _settings;
|
---|
144 | }
|
---|
145 | document.Load(documentStream);
|
---|
146 |
|
---|
147 | this.Document = document;
|
---|
148 | }
|
---|
149 |
|
---|
150 | public void LoadDocument(TextReader textReader)
|
---|
151 | {
|
---|
152 | if (textReader == null)
|
---|
153 | {
|
---|
154 | return;
|
---|
155 | }
|
---|
156 |
|
---|
157 | SvgDocument document = new SvgDocument(this);
|
---|
158 | if (_settings != null)
|
---|
159 | {
|
---|
160 | document.CustomSettings = _settings;
|
---|
161 | }
|
---|
162 | document.Load(textReader);
|
---|
163 |
|
---|
164 | this.Document = document;
|
---|
165 | }
|
---|
166 |
|
---|
167 | public void LoadDocument(XmlReader xmlReader)
|
---|
168 | {
|
---|
169 | if (xmlReader == null)
|
---|
170 | {
|
---|
171 | return;
|
---|
172 | }
|
---|
173 |
|
---|
174 | SvgDocument document = new SvgDocument(this);
|
---|
175 | if (_settings != null)
|
---|
176 | {
|
---|
177 | document.CustomSettings = _settings;
|
---|
178 | }
|
---|
179 | document.Load(xmlReader);
|
---|
180 |
|
---|
181 | this.Document = document;
|
---|
182 | }
|
---|
183 |
|
---|
184 | public override void Alert(string message)
|
---|
185 | {
|
---|
186 | if (String.IsNullOrEmpty(message))
|
---|
187 | {
|
---|
188 | return;
|
---|
189 | }
|
---|
190 |
|
---|
191 | MessageBox.Show(message);
|
---|
192 | }
|
---|
193 |
|
---|
194 | public override SvgWindow CreateOwnedWindow(long innerWidth, long innerHeight)
|
---|
195 | {
|
---|
196 | return new WpfSvgWindow(this, innerWidth, innerHeight);
|
---|
197 | }
|
---|
198 |
|
---|
199 | #endregion
|
---|
200 | }
|
---|
201 | }
|
---|