diff options
author | Jeff Ames | 2008-05-01 14:31:30 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 14:31:30 +0000 |
commit | d51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch) | |
tree | d3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/Scripting/VectorRender | |
parent | * Looks like I had the bamboo build right in the first place - it was just th... (diff) | |
download | opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2 opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz |
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Scripting/VectorRender')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs | 736 |
1 files changed, 368 insertions, 368 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs index 386c2b5..626c60f 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -1,369 +1,369 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Net; | 33 | using System.Net; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenJPEGNet; | 36 | using OpenJPEGNet; |
37 | using OpenSim.Region.Environment.Interfaces; | 37 | using OpenSim.Region.Environment.Interfaces; |
38 | using OpenSim.Region.Environment.Scenes; | 38 | using OpenSim.Region.Environment.Scenes; |
39 | using Image=System.Drawing.Image; | 39 | using Image=System.Drawing.Image; |
40 | 40 | ||
41 | //using Cairo; | 41 | //using Cairo; |
42 | 42 | ||
43 | namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender | 43 | namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender |
44 | { | 44 | { |
45 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender | 45 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender |
46 | { | 46 | { |
47 | private string m_name = "VectorRenderModule"; | 47 | private string m_name = "VectorRenderModule"; |
48 | private Scene m_scene; | 48 | private Scene m_scene; |
49 | private IDynamicTextureManager m_textureManager; | 49 | private IDynamicTextureManager m_textureManager; |
50 | 50 | ||
51 | public VectorRenderModule() | 51 | public VectorRenderModule() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | #region IDynamicTextureRender Members | 55 | #region IDynamicTextureRender Members |
56 | 56 | ||
57 | public string GetContentType() | 57 | public string GetContentType() |
58 | { | 58 | { |
59 | return ("vector"); | 59 | return ("vector"); |
60 | } | 60 | } |
61 | 61 | ||
62 | public string GetName() | 62 | public string GetName() |
63 | { | 63 | { |
64 | return m_name; | 64 | return m_name; |
65 | } | 65 | } |
66 | 66 | ||
67 | public bool SupportsAsynchronous() | 67 | public bool SupportsAsynchronous() |
68 | { | 68 | { |
69 | return true; | 69 | return true; |
70 | } | 70 | } |
71 | 71 | ||
72 | public byte[] ConvertUrl(string url, string extraParams) | 72 | public byte[] ConvertUrl(string url, string extraParams) |
73 | { | 73 | { |
74 | return null; | 74 | return null; |
75 | } | 75 | } |
76 | 76 | ||
77 | public byte[] ConvertStream(Stream data, string extraParams) | 77 | public byte[] ConvertStream(Stream data, string extraParams) |
78 | { | 78 | { |
79 | return null; | 79 | return null; |
80 | } | 80 | } |
81 | 81 | ||
82 | public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) | 82 | public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) |
83 | { | 83 | { |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | 86 | ||
87 | public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) | 87 | public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) |
88 | { | 88 | { |
89 | Draw(bodyData, id, extraParams); | 89 | Draw(bodyData, id, extraParams); |
90 | return true; | 90 | return true; |
91 | } | 91 | } |
92 | 92 | ||
93 | #endregion | 93 | #endregion |
94 | 94 | ||
95 | #region IRegionModule Members | 95 | #region IRegionModule Members |
96 | 96 | ||
97 | public void Initialise(Scene scene, IConfigSource config) | 97 | public void Initialise(Scene scene, IConfigSource config) |
98 | { | 98 | { |
99 | if (m_scene == null) | 99 | if (m_scene == null) |
100 | { | 100 | { |
101 | m_scene = scene; | 101 | m_scene = scene; |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | public void PostInitialise() | 105 | public void PostInitialise() |
106 | { | 106 | { |
107 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | 107 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); |
108 | if (m_textureManager != null) | 108 | if (m_textureManager != null) |
109 | { | 109 | { |
110 | m_textureManager.RegisterRender(GetContentType(), this); | 110 | m_textureManager.RegisterRender(GetContentType(), this); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | public void Close() | 114 | public void Close() |
115 | { | 115 | { |
116 | } | 116 | } |
117 | 117 | ||
118 | public string Name | 118 | public string Name |
119 | { | 119 | { |
120 | get { return m_name; } | 120 | get { return m_name; } |
121 | } | 121 | } |
122 | 122 | ||
123 | public bool IsSharedModule | 123 | public bool IsSharedModule |
124 | { | 124 | { |
125 | get { return true; } | 125 | get { return true; } |
126 | } | 126 | } |
127 | 127 | ||
128 | #endregion | 128 | #endregion |
129 | 129 | ||
130 | private void Draw(string data, LLUUID id, string extraParams) | 130 | private void Draw(string data, LLUUID id, string extraParams) |
131 | { | 131 | { |
132 | // TODO: this is a brutal hack. extraParams should actually be parsed reasonably. | 132 | // TODO: this is a brutal hack. extraParams should actually be parsed reasonably. |
133 | int size = 256; | 133 | int size = 256; |
134 | try | 134 | try |
135 | { | 135 | { |
136 | size = Convert.ToInt32(extraParams); | 136 | size = Convert.ToInt32(extraParams); |
137 | } | 137 | } |
138 | catch (Exception e) | 138 | catch (Exception e) |
139 | { | 139 | { |
140 | //Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used | 140 | //Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used |
141 | Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); | 141 | Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); |
142 | } | 142 | } |
143 | 143 | ||
144 | if ((size < 128) || (size > 1024)) | 144 | if ((size < 128) || (size > 1024)) |
145 | size = 256; | 145 | size = 256; |
146 | 146 | ||
147 | Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb); | 147 | Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb); |
148 | 148 | ||
149 | Graphics graph = Graphics.FromImage(bitmap); | 149 | Graphics graph = Graphics.FromImage(bitmap); |
150 | 150 | ||
151 | extraParams = extraParams.ToLower(); | 151 | extraParams = extraParams.ToLower(); |
152 | int alpha = 255; | 152 | int alpha = 255; |
153 | if (extraParams == "setalpha") | 153 | if (extraParams == "setalpha") |
154 | { | 154 | { |
155 | alpha = 0; | 155 | alpha = 0; |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
159 | graph.FillRectangle(new SolidBrush(Color.White), 0, 0, size, size); | 159 | graph.FillRectangle(new SolidBrush(Color.White), 0, 0, size, size); |
160 | } | 160 | } |
161 | 161 | ||
162 | for (int w = 0; w < bitmap.Width; w++) | 162 | for (int w = 0; w < bitmap.Width; w++) |
163 | { | 163 | { |
164 | for (int h = 0; h < bitmap.Height; h++) | 164 | for (int h = 0; h < bitmap.Height; h++) |
165 | { | 165 | { |
166 | bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h))); | 166 | bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h))); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | GDIDraw(data, graph); | 171 | GDIDraw(data, graph); |
172 | 172 | ||
173 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); | 173 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); |
174 | m_textureManager.ReturnData(id, imageJ2000); | 174 | m_textureManager.ReturnData(id, imageJ2000); |
175 | } | 175 | } |
176 | 176 | ||
177 | /* | 177 | /* |
178 | private void CairoDraw(string data, System.Drawing.Graphics graph) | 178 | private void CairoDraw(string data, System.Drawing.Graphics graph) |
179 | { | 179 | { |
180 | using (Win32Surface draw = new Win32Surface(graph.GetHdc())) | 180 | using (Win32Surface draw = new Win32Surface(graph.GetHdc())) |
181 | { | 181 | { |
182 | Context contex = new Context(draw); | 182 | Context contex = new Context(draw); |
183 | 183 | ||
184 | contex.Antialias = Antialias.None; //fastest method but low quality | 184 | contex.Antialias = Antialias.None; //fastest method but low quality |
185 | contex.LineWidth = 7; | 185 | contex.LineWidth = 7; |
186 | char[] lineDelimiter = { ';' }; | 186 | char[] lineDelimiter = { ';' }; |
187 | char[] partsDelimiter = { ',' }; | 187 | char[] partsDelimiter = { ',' }; |
188 | string[] lines = data.Split(lineDelimiter); | 188 | string[] lines = data.Split(lineDelimiter); |
189 | 189 | ||
190 | foreach (string line in lines) | 190 | foreach (string line in lines) |
191 | { | 191 | { |
192 | string nextLine = line.Trim(); | 192 | string nextLine = line.Trim(); |
193 | 193 | ||
194 | if (nextLine.StartsWith("MoveTO")) | 194 | if (nextLine.StartsWith("MoveTO")) |
195 | { | 195 | { |
196 | float x = 0; | 196 | float x = 0; |
197 | float y = 0; | 197 | float y = 0; |
198 | GetParams(partsDelimiter, ref nextLine, ref x, ref y); | 198 | GetParams(partsDelimiter, ref nextLine, ref x, ref y); |
199 | contex.MoveTo(x, y); | 199 | contex.MoveTo(x, y); |
200 | } | 200 | } |
201 | else if (nextLine.StartsWith("LineTo")) | 201 | else if (nextLine.StartsWith("LineTo")) |
202 | { | 202 | { |
203 | float x = 0; | 203 | float x = 0; |
204 | float y = 0; | 204 | float y = 0; |
205 | GetParams(partsDelimiter, ref nextLine, ref x, ref y); | 205 | GetParams(partsDelimiter, ref nextLine, ref x, ref y); |
206 | contex.LineTo(x, y); | 206 | contex.LineTo(x, y); |
207 | contex.Stroke(); | 207 | contex.Stroke(); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | graph.ReleaseHdc(); | 211 | graph.ReleaseHdc(); |
212 | } | 212 | } |
213 | */ | 213 | */ |
214 | 214 | ||
215 | private void GDIDraw(string data, Graphics graph) | 215 | private void GDIDraw(string data, Graphics graph) |
216 | { | 216 | { |
217 | Point startPoint = new Point(0, 0); | 217 | Point startPoint = new Point(0, 0); |
218 | Point endPoint = new Point(0, 0); | 218 | Point endPoint = new Point(0, 0); |
219 | Pen drawPen = new Pen(Color.Black, 7); | 219 | Pen drawPen = new Pen(Color.Black, 7); |
220 | Font myFont = new Font("Times New Roman", 14); | 220 | Font myFont = new Font("Times New Roman", 14); |
221 | SolidBrush myBrush = new SolidBrush(Color.Black); | 221 | SolidBrush myBrush = new SolidBrush(Color.Black); |
222 | char[] lineDelimiter = {';'}; | 222 | char[] lineDelimiter = {';'}; |
223 | char[] partsDelimiter = {','}; | 223 | char[] partsDelimiter = {','}; |
224 | string[] lines = data.Split(lineDelimiter); | 224 | string[] lines = data.Split(lineDelimiter); |
225 | 225 | ||
226 | foreach (string line in lines) | 226 | foreach (string line in lines) |
227 | { | 227 | { |
228 | string nextLine = line.Trim(); | 228 | string nextLine = line.Trim(); |
229 | //replace with switch, or even better, do some proper parsing | 229 | //replace with switch, or even better, do some proper parsing |
230 | if (nextLine.StartsWith("MoveTo")) | 230 | if (nextLine.StartsWith("MoveTo")) |
231 | { | 231 | { |
232 | float x = 0; | 232 | float x = 0; |
233 | float y = 0; | 233 | float y = 0; |
234 | GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); | 234 | GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); |
235 | startPoint.X = (int) x; | 235 | startPoint.X = (int) x; |
236 | startPoint.Y = (int) y; | 236 | startPoint.Y = (int) y; |
237 | } | 237 | } |
238 | else if (nextLine.StartsWith("LineTo")) | 238 | else if (nextLine.StartsWith("LineTo")) |
239 | { | 239 | { |
240 | float x = 0; | 240 | float x = 0; |
241 | float y = 0; | 241 | float y = 0; |
242 | GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); | 242 | GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); |
243 | endPoint.X = (int) x; | 243 | endPoint.X = (int) x; |
244 | endPoint.Y = (int) y; | 244 | endPoint.Y = (int) y; |
245 | graph.DrawLine(drawPen, startPoint, endPoint); | 245 | graph.DrawLine(drawPen, startPoint, endPoint); |
246 | startPoint.X = endPoint.X; | 246 | startPoint.X = endPoint.X; |
247 | startPoint.Y = endPoint.Y; | 247 | startPoint.Y = endPoint.Y; |
248 | } | 248 | } |
249 | else if (nextLine.StartsWith("Text")) | 249 | else if (nextLine.StartsWith("Text")) |
250 | { | 250 | { |
251 | nextLine = nextLine.Remove(0, 4); | 251 | nextLine = nextLine.Remove(0, 4); |
252 | nextLine = nextLine.Trim(); | 252 | nextLine = nextLine.Trim(); |
253 | graph.DrawString(nextLine, myFont, myBrush, startPoint); | 253 | graph.DrawString(nextLine, myFont, myBrush, startPoint); |
254 | } | 254 | } |
255 | else if (nextLine.StartsWith("Image")) | 255 | else if (nextLine.StartsWith("Image")) |
256 | { | 256 | { |
257 | float x = 0; | 257 | float x = 0; |
258 | float y = 0; | 258 | float y = 0; |
259 | GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); | 259 | GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); |
260 | endPoint.X = (int) x; | 260 | endPoint.X = (int) x; |
261 | endPoint.Y = (int) y; | 261 | endPoint.Y = (int) y; |
262 | Image image = ImageHttpRequest(nextLine); | 262 | Image image = ImageHttpRequest(nextLine); |
263 | graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); | 263 | graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); |
264 | startPoint.X += endPoint.X; | 264 | startPoint.X += endPoint.X; |
265 | startPoint.Y += endPoint.Y; | 265 | startPoint.Y += endPoint.Y; |
266 | } | 266 | } |
267 | else if (nextLine.StartsWith("Rectangle")) | 267 | else if (nextLine.StartsWith("Rectangle")) |
268 | { | 268 | { |
269 | float x = 0; | 269 | float x = 0; |
270 | float y = 0; | 270 | float y = 0; |
271 | GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y); | 271 | GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y); |
272 | endPoint.X = (int) x; | 272 | endPoint.X = (int) x; |
273 | endPoint.Y = (int) y; | 273 | endPoint.Y = (int) y; |
274 | graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); | 274 | graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); |
275 | startPoint.X += endPoint.X; | 275 | startPoint.X += endPoint.X; |
276 | startPoint.Y += endPoint.Y; | 276 | startPoint.Y += endPoint.Y; |
277 | } | 277 | } |
278 | else if (nextLine.StartsWith("FillRectangle")) | 278 | else if (nextLine.StartsWith("FillRectangle")) |
279 | { | 279 | { |
280 | float x = 0; | 280 | float x = 0; |
281 | float y = 0; | 281 | float y = 0; |
282 | GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y); | 282 | GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y); |
283 | endPoint.X = (int) x; | 283 | endPoint.X = (int) x; |
284 | endPoint.Y = (int) y; | 284 | endPoint.Y = (int) y; |
285 | graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); | 285 | graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); |
286 | startPoint.X += endPoint.X; | 286 | startPoint.X += endPoint.X; |
287 | startPoint.Y += endPoint.Y; | 287 | startPoint.Y += endPoint.Y; |
288 | } | 288 | } |
289 | else if (nextLine.StartsWith("Ellipse")) | 289 | else if (nextLine.StartsWith("Ellipse")) |
290 | { | 290 | { |
291 | float x = 0; | 291 | float x = 0; |
292 | float y = 0; | 292 | float y = 0; |
293 | GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); | 293 | GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); |
294 | endPoint.X = (int) x; | 294 | endPoint.X = (int) x; |
295 | endPoint.Y = (int) y; | 295 | endPoint.Y = (int) y; |
296 | graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); | 296 | graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); |
297 | startPoint.X += endPoint.X; | 297 | startPoint.X += endPoint.X; |
298 | startPoint.Y += endPoint.Y; | 298 | startPoint.Y += endPoint.Y; |
299 | } | 299 | } |
300 | else if (nextLine.StartsWith("FontSize")) | 300 | else if (nextLine.StartsWith("FontSize")) |
301 | { | 301 | { |
302 | nextLine = nextLine.Remove(0, 8); | 302 | nextLine = nextLine.Remove(0, 8); |
303 | nextLine = nextLine.Trim(); | 303 | nextLine = nextLine.Trim(); |
304 | float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); | 304 | float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); |
305 | myFont = new Font("Times New Roman", size); | 305 | myFont = new Font("Times New Roman", size); |
306 | } | 306 | } |
307 | else if (nextLine.StartsWith("PenSize")) | 307 | else if (nextLine.StartsWith("PenSize")) |
308 | { | 308 | { |
309 | nextLine = nextLine.Remove(0, 8); | 309 | nextLine = nextLine.Remove(0, 8); |
310 | nextLine = nextLine.Trim(); | 310 | nextLine = nextLine.Trim(); |
311 | float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); | 311 | float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); |
312 | drawPen.Width = size; | 312 | drawPen.Width = size; |
313 | } | 313 | } |
314 | else if (nextLine.StartsWith("PenColour")) | 314 | else if (nextLine.StartsWith("PenColour")) |
315 | { | 315 | { |
316 | nextLine = nextLine.Remove(0, 9); | 316 | nextLine = nextLine.Remove(0, 9); |
317 | nextLine = nextLine.Trim(); | 317 | nextLine = nextLine.Trim(); |
318 | 318 | ||
319 | Color newColour = Color.FromName(nextLine); | 319 | Color newColour = Color.FromName(nextLine); |
320 | 320 | ||
321 | myBrush.Color = newColour; | 321 | myBrush.Color = newColour; |
322 | drawPen.Color = newColour; | 322 | drawPen.Color = newColour; |
323 | } | 323 | } |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref float x, ref float y) | 327 | private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref float x, ref float y) |
328 | { | 328 | { |
329 | line = line.Remove(0, startLength); | 329 | line = line.Remove(0, startLength); |
330 | string[] parts = line.Split(partsDelimiter); | 330 | string[] parts = line.Split(partsDelimiter); |
331 | if (parts.Length == 2) | 331 | if (parts.Length == 2) |
332 | { | 332 | { |
333 | string xVal = parts[0].Trim(); | 333 | string xVal = parts[0].Trim(); |
334 | string yVal = parts[1].Trim(); | 334 | string yVal = parts[1].Trim(); |
335 | x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); | 335 | x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); |
336 | y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); | 336 | y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); |
337 | } | 337 | } |
338 | else if (parts.Length > 2) | 338 | else if (parts.Length > 2) |
339 | { | 339 | { |
340 | string xVal = parts[0].Trim(); | 340 | string xVal = parts[0].Trim(); |
341 | string yVal = parts[1].Trim(); | 341 | string yVal = parts[1].Trim(); |
342 | x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); | 342 | x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture); |
343 | y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); | 343 | y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); |
344 | 344 | ||
345 | line = ""; | 345 | line = ""; |
346 | for (int i = 2; i < parts.Length; i++) | 346 | for (int i = 2; i < parts.Length; i++) |
347 | { | 347 | { |
348 | line = line + parts[i].Trim(); | 348 | line = line + parts[i].Trim(); |
349 | line = line + " "; | 349 | line = line + " "; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | private Bitmap ImageHttpRequest(string url) | 354 | private Bitmap ImageHttpRequest(string url) |
355 | { | 355 | { |
356 | WebRequest request = HttpWebRequest.Create(url); | 356 | WebRequest request = HttpWebRequest.Create(url); |
357 | //Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. | 357 | //Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. |
358 | //Ckrinke Stream str = null; | 358 | //Ckrinke Stream str = null; |
359 | HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); | 359 | HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); |
360 | if (response.StatusCode == HttpStatusCode.OK) | 360 | if (response.StatusCode == HttpStatusCode.OK) |
361 | { | 361 | { |
362 | Bitmap image = new Bitmap(response.GetResponseStream()); | 362 | Bitmap image = new Bitmap(response.GetResponseStream()); |
363 | return image; | 363 | return image; |
364 | } | 364 | } |
365 | 365 | ||
366 | return null; | 366 | return null; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } \ No newline at end of file | 369 | } \ No newline at end of file |