1 |
787a4489
|
KangIngu
|
using System;
|
2 |
|
|
using System.Net;
|
3 |
|
|
using System.Windows;
|
4 |
|
|
using System.Windows.Controls;
|
5 |
|
|
using System.Windows.Documents;
|
6 |
|
|
using System.Windows.Ink;
|
7 |
|
|
using System.Windows.Input;
|
8 |
|
|
using System.Windows.Media;
|
9 |
|
|
using System.Windows.Media.Animation;
|
10 |
|
|
using System.Windows.Shapes;
|
11 |
|
|
using System.Collections.Generic;
|
12 |
|
|
using MarkupToPDF.Serialize.S_Control;
|
13 |
|
|
using MarkupToPDF.Serialize.Core;
|
14 |
|
|
using System.Linq;
|
15 |
|
|
using MarkupToPDF.Controls.Line;
|
16 |
|
|
using MarkupToPDF.Controls.Text;
|
17 |
|
|
using MarkupToPDF.Controls.Shape;
|
18 |
|
|
using MarkupToPDF.Controls.Etc;
|
19 |
|
|
using MarkupToPDF.Controls.Polygon;
|
20 |
|
|
//using Telerik.Windows.Controls;
|
21 |
|
|
using System.IO;
|
22 |
|
|
using System.Windows.Media.Imaging;
|
23 |
|
|
//using MarkupToPDF.Common;
|
24 |
|
|
using System.Windows.Markup;
|
25 |
|
|
//using Telerik.Windows.Controls;
|
26 |
|
|
using System.Net.Cache;
|
27 |
|
|
using System.Collections.ObjectModel;
|
28 |
|
|
using MarkupToPDF.Common;
|
29 |
53880c83
|
ljiyeon
|
using Svg2Xaml;
|
30 |
684ef11c
|
ljiyeon
|
using MarkupToPDF.Controls.Cad;
|
31 |
40d88a02
|
ljiyeon
|
using MarkupToPDF.Controls.Common;
|
32 |
ac4f1e13
|
taeseongkim
|
using System.Threading.Tasks;
|
33 |
787a4489
|
KangIngu
|
|
34 |
|
|
namespace MarkupToPDF.Controls.Parsing
|
35 |
|
|
{
|
36 |
036650a0
|
humkyung
|
public class MarkupParser
|
37 |
|
|
{
|
38 |
|
|
///강인구 추가(2017.11.02)
|
39 |
|
|
///DATA_TYPE추가로 인한 클래스 변수 추가
|
40 |
|
|
public class MarkupReturn
|
41 |
|
|
{
|
42 |
|
|
public string ConvertData { get; set; }
|
43 |
|
|
public int DATA_TYPE { get; set; }
|
44 |
|
|
public string CommentID { get; set; }
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
public static MarkupReturn MarkupToString(CommentUserInfo Control, string UserId)
|
48 |
|
|
{
|
49 |
|
|
MarkupReturn Data = new MarkupReturn();
|
50 |
|
|
Data.ConvertData = "";
|
51 |
8cf823d0
|
djkim
|
Data.DATA_TYPE = (int)Control.ControlType;
|
52 |
036650a0
|
humkyung
|
Data.CommentID = Control.CommentID;
|
53 |
|
|
if (Data.CommentID == null)
|
54 |
|
|
{
|
55 |
|
|
Data.CommentID = shortGuid();
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
Data.ConvertData = Control.Serialize();
|
59 |
|
|
|
60 |
|
|
return Data;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
661b7416
|
humkyung
|
/// <summary>
|
64 |
|
|
/// create a commentuserinfo from given string
|
65 |
|
|
/// </summary>
|
66 |
|
|
/// <param name="str"></param>
|
67 |
|
|
/// <returns></returns>
|
68 |
24c5e56c
|
taeseongkim
|
public static CommentUserInfo FromString(string item, SolidColorBrush brush, string sProjectNo)
|
69 |
661b7416
|
humkyung
|
{
|
70 |
|
|
CommentUserInfo instance = null;
|
71 |
5529d2a2
|
humkyung
|
var unkown = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); //복호화작업
|
72 |
661b7416
|
humkyung
|
switch (unkown.Name)
|
73 |
|
|
{
|
74 |
|
|
#region Shape
|
75 |
|
|
#region Rectangle
|
76 |
|
|
case "RectangleControl":
|
77 |
|
|
instance = RectangleControl.FromString(item, brush, sProjectNo);
|
78 |
|
|
break;
|
79 |
|
|
#endregion
|
80 |
|
|
#region Triangle
|
81 |
|
|
case "TriControl":
|
82 |
|
|
instance = TriControl.FromString(item, brush, sProjectNo);
|
83 |
|
|
break;
|
84 |
|
|
#endregion
|
85 |
|
|
#region Cicle
|
86 |
|
|
case "CircleControl":
|
87 |
|
|
instance = CircleControl.FromString(item, brush, sProjectNo);
|
88 |
|
|
break;
|
89 |
|
|
#endregion
|
90 |
|
|
#region RectCloud
|
91 |
|
|
case "RectCloudControl":
|
92 |
|
|
instance = RectCloudControl.FromString(item, brush, sProjectNo);
|
93 |
|
|
break;
|
94 |
|
|
#endregion
|
95 |
|
|
#endregion
|
96 |
|
|
|
97 |
|
|
#region Polygon
|
98 |
|
|
#region Poly
|
99 |
|
|
case "PolygonControl":
|
100 |
|
|
instance = PolygonControl.FromString(item, brush, sProjectNo);
|
101 |
|
|
break;
|
102 |
|
|
#endregion
|
103 |
|
|
#region InkControl
|
104 |
|
|
case "InkControl":
|
105 |
|
|
instance = InkControl.FromString(item, brush, sProjectNo);
|
106 |
|
|
break;
|
107 |
|
|
#endregion
|
108 |
|
|
#region Cloud
|
109 |
|
|
case "CloudControl":
|
110 |
|
|
instance = CloudControl.FromString(item, brush, sProjectNo);
|
111 |
|
|
break;
|
112 |
|
|
#endregion
|
113 |
|
|
#endregion
|
114 |
|
|
|
115 |
|
|
#region Line
|
116 |
|
|
#region Line
|
117 |
|
|
case "LineControl":
|
118 |
|
|
instance = LineControl.FromString(item, brush, sProjectNo);
|
119 |
|
|
break;
|
120 |
|
|
#endregion
|
121 |
|
|
#region Arrow_Multi
|
122 |
|
|
case "ArrowControl_Multi":
|
123 |
|
|
instance = ArrowControl_Multi.FromString(item, brush, sProjectNo);
|
124 |
|
|
break;
|
125 |
|
|
#endregion
|
126 |
|
|
#region Arc
|
127 |
|
|
case "ArcControl":
|
128 |
|
|
instance = ArcControl.FromString(item, brush, sProjectNo);
|
129 |
|
|
break;
|
130 |
|
|
#endregion
|
131 |
|
|
#region ArrowArc
|
132 |
|
|
case "ArrowArcControl":
|
133 |
|
|
instance = ArrowArcControl.FromString(item, brush, sProjectNo);
|
134 |
|
|
break;
|
135 |
|
|
#endregion
|
136 |
|
|
#endregion
|
137 |
|
|
#region Text
|
138 |
|
|
case "TextControl":
|
139 |
|
|
instance = TextControl.FromString(item, brush, sProjectNo);
|
140 |
|
|
break;
|
141 |
|
|
#endregion
|
142 |
|
|
|
143 |
|
|
#region ArrowText
|
144 |
|
|
case "ArrowTextControl":
|
145 |
|
|
instance = ArrowTextControl.FromString(item, brush, sProjectNo);
|
146 |
|
|
break;
|
147 |
|
|
#endregion
|
148 |
|
|
|
149 |
|
|
#region ETC
|
150 |
|
|
#region Ink
|
151 |
|
|
case "InkPresenter":
|
152 |
|
|
using (S_PensilControl s = JsonSerializerHelper.JsonDeserialize<S_PensilControl>(item))
|
153 |
|
|
{
|
154 |
|
|
|
155 |
|
|
}
|
156 |
|
|
break;
|
157 |
|
|
#endregion
|
158 |
|
|
#region Date
|
159 |
|
|
case "DateControl":
|
160 |
|
|
instance = DateControl.FromString(item, brush, sProjectNo);
|
161 |
|
|
break;
|
162 |
|
|
#endregion
|
163 |
|
|
#region Image
|
164 |
|
|
case "ImgControl":
|
165 |
|
|
instance = ImgControl.FromString(item, brush, sProjectNo);
|
166 |
|
|
break;
|
167 |
|
|
#endregion
|
168 |
|
|
#region Sign
|
169 |
|
|
case "SignControl":
|
170 |
|
|
instance = SignControl.FromString(item, brush, sProjectNo);
|
171 |
|
|
break;
|
172 |
|
|
#endregion
|
173 |
|
|
#region Symbol
|
174 |
|
|
case "SymControl":
|
175 |
|
|
instance = SymControl.FromString(item, brush, sProjectNo);
|
176 |
|
|
break;
|
177 |
|
|
#endregion
|
178 |
|
|
|
179 |
|
|
#region SymbolN
|
180 |
|
|
case "SymControlN":
|
181 |
|
|
instance = SymControlN.FromString(item, brush, sProjectNo);
|
182 |
|
|
break;
|
183 |
|
|
#endregion
|
184 |
|
|
#endregion
|
185 |
|
|
|
186 |
|
|
#region Cad
|
187 |
|
|
case "InsideWhiteControl":
|
188 |
|
|
instance = InsideWhiteControl.FromString(item, brush, sProjectNo);
|
189 |
|
|
break;
|
190 |
|
|
case "OverlapWhiteControl":
|
191 |
|
|
instance = OverlapWhiteControl.FromString(item, brush, sProjectNo);
|
192 |
|
|
break;
|
193 |
|
|
case "ClipWhiteControl":
|
194 |
|
|
instance = ClipWhiteControl.FromString(item, brush, sProjectNo);
|
195 |
|
|
break;
|
196 |
|
|
case "CoordinateControl":
|
197 |
|
|
instance = CoordinateControl.FromString(item, brush, sProjectNo);
|
198 |
|
|
break;
|
199 |
|
|
#endregion
|
200 |
|
|
default:
|
201 |
|
|
break;
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
return instance;
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
/// <summary>
|
208 |
|
|
/// 데이터베이스의 마크업데이터를 컨트롤로 변환한다.
|
209 |
|
|
/// </summary>
|
210 |
|
|
/// <param name="MarkupString"></param>
|
211 |
24c5e56c
|
taeseongkim
|
public static async Task<bool> ParseAsync(string sProjectNo, string MarkupString, Canvas Layer, string DisplayColor, string ToolTipMessage, System.Threading.CancellationToken cts)
|
212 |
661b7416
|
humkyung
|
{
|
213 |
e1c892f7
|
taeseongkim
|
bool result = false;
|
214 |
|
|
|
215 |
661b7416
|
humkyung
|
if (MarkupString != "False")
|
216 |
|
|
{
|
217 |
|
|
SolidColorBrush _SetColor = new SolidColorBrush(Common.ValueConverter.StringToColorConverter.Parse(DisplayColor));
|
218 |
787a4489
|
KangIngu
|
//SolidColorBrush _SetColor = new SolidColorBrush(Colors.Red);
|
219 |
661b7416
|
humkyung
|
string[] delimiterChars = { "|DZ|" };
|
220 |
|
|
string[] delimiterChars2 = { "|" };
|
221 |
5529d2a2
|
humkyung
|
string[] tokens = MarkupString.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
|
222 |
661b7416
|
humkyung
|
|
223 |
5529d2a2
|
humkyung
|
foreach (var token in tokens)
|
224 |
661b7416
|
humkyung
|
{
|
225 |
24c5e56c
|
taeseongkim
|
var item = await JsonSerializerHelper.UnCompressStringAsync(token,cts); //언패킹작업
|
226 |
|
|
CommentUserInfo control = MarkupParser.FromString(item, _SetColor, sProjectNo);
|
227 |
|
|
|
228 |
661b7416
|
humkyung
|
if (control != null)
|
229 |
|
|
{
|
230 |
5529d2a2
|
humkyung
|
Layer.Children.Add(control);
|
231 |
661b7416
|
humkyung
|
control.ApplyTemplate();
|
232 |
|
|
control.SetValue(ToolTipService.ToolTipProperty, ToolTipMessage);
|
233 |
|
|
|
234 |
|
|
if (control is ArrowTextControl)
|
235 |
|
|
{
|
236 |
|
|
ArrowTextControl _instance = control as ArrowTextControl;
|
237 |
|
|
if (_instance.UnderLine == TextDecorations.Underline)
|
238 |
|
|
{
|
239 |
|
|
_instance.Base_TextBox.TextDecorations = _instance.UnderLine;
|
240 |
|
|
}
|
241 |
|
|
_instance.Base_TextBox.IsHitTestVisible = false;
|
242 |
|
|
}
|
243 |
|
|
else if (control is TextControl)
|
244 |
|
|
{
|
245 |
|
|
TextControl text = control as TextControl;
|
246 |
|
|
text.Base_TextBlock.TextDecorations = text.UnderLine;
|
247 |
|
|
text.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
|
248 |
|
|
text.Base_TextBox.Visibility = Visibility.Collapsed;
|
249 |
|
|
text.Base_TextBlock.Visibility = Visibility.Visible;
|
250 |
|
|
}
|
251 |
|
|
else if (control is SymControlN)
|
252 |
|
|
{
|
253 |
|
|
SymControlN _instance = control as SymControlN;
|
254 |
|
|
|
255 |
cd988cd8
|
djkim
|
var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStamp(_instance.PathXathData);
|
256 |
|
|
|
257 |
661b7416
|
humkyung
|
System.IO.MemoryStream stream = new System.IO.MemoryStream();
|
258 |
|
|
System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
|
259 |
|
|
writer.Write(xamlData);
|
260 |
|
|
writer.Flush();
|
261 |
|
|
stream.Position = 0;
|
262 |
|
|
|
263 |
|
|
object obj = XamlReader.Load(stream);
|
264 |
|
|
_instance.Base_ViewBox.Child = obj as UIElement;
|
265 |
|
|
_instance.SetViewBox();
|
266 |
|
|
}
|
267 |
e1c892f7
|
taeseongkim
|
|
268 |
|
|
result = true;
|
269 |
661b7416
|
humkyung
|
}
|
270 |
|
|
}
|
271 |
|
|
}
|
272 |
e1c892f7
|
taeseongkim
|
|
273 |
|
|
return result;
|
274 |
787a4489
|
KangIngu
|
}
|
275 |
b200de5a
|
KangIngu
|
|
276 |
787a4489
|
KangIngu
|
/// <summary>
|
277 |
|
|
/// 데이터베이스의 마크업데이터를 컨트롤로 변환한다.
|
278 |
|
|
/// </summary>
|
279 |
|
|
/// <param name="MarkupString"></param>
|
280 |
24c5e56c
|
taeseongkim
|
public static async Task<Control> ParseExAsync(System.Threading.CancellationToken? cts,string sProjectNo, string MarkupString, ObservableCollection<CommentUserInfo> baseLayer, string DisplayColor, string ToolTipMessage, string markupInfoID = null, string commentId = null)
|
281 |
787a4489
|
KangIngu
|
{
|
282 |
5529d2a2
|
humkyung
|
Control res = null;
|
283 |
|
|
|
284 |
787a4489
|
KangIngu
|
if (MarkupString != "False")
|
285 |
|
|
{
|
286 |
|
|
SolidColorBrush _SetColor = new SolidColorBrush(Common.ValueConverter.StringToColorConverter.Parse(DisplayColor));
|
287 |
|
|
string[] delimiterChars = { "|DZ|" };
|
288 |
|
|
string[] delimiterChars2 = { "|" };
|
289 |
|
|
string[] data = MarkupString.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
|
290 |
|
|
|
291 |
|
|
foreach (var dataPease in data)
|
292 |
|
|
{
|
293 |
24c5e56c
|
taeseongkim
|
string item = "";
|
294 |
|
|
|
295 |
|
|
if (cts == null)
|
296 |
|
|
{
|
297 |
|
|
item = await JsonSerializerHelper.UnCompressStringAsync(dataPease, null); //언패킹작업
|
298 |
|
|
}
|
299 |
|
|
else
|
300 |
|
|
{
|
301 |
|
|
if(cts.Value.IsCancellationRequested)
|
302 |
|
|
{
|
303 |
|
|
return null;
|
304 |
|
|
}
|
305 |
|
|
|
306 |
|
|
item = await JsonSerializerHelper.UnCompressStringAsync(dataPease, cts); //언패킹작업
|
307 |
|
|
}
|
308 |
366f00c2
|
taeseongkim
|
|
309 |
24c5e56c
|
taeseongkim
|
CommentUserInfo control = MarkupParser.FromString(item, _SetColor, sProjectNo);
|
310 |
366f00c2
|
taeseongkim
|
|
311 |
5529d2a2
|
humkyung
|
res = control as Control;
|
312 |
|
|
if (control != null)
|
313 |
787a4489
|
KangIngu
|
{
|
314 |
5529d2a2
|
humkyung
|
if (!string.IsNullOrEmpty(commentId)) control.CommentID = commentId;
|
315 |
|
|
if (!string.IsNullOrEmpty(markupInfoID)) control.MarkupInfoID = markupInfoID;
|
316 |
c00d0547
|
humkyung
|
if (baseLayer != null)
|
317 |
5529d2a2
|
humkyung
|
{
|
318 |
c00d0547
|
humkyung
|
baseLayer.Add(control);
|
319 |
|
|
control.ApplyTemplate();
|
320 |
|
|
|
321 |
|
|
if (control is ArrowTextControl)
|
322 |
684ef11c
|
ljiyeon
|
{
|
323 |
c00d0547
|
humkyung
|
ArrowTextControl _instance = control as ArrowTextControl;
|
324 |
|
|
if (_instance.UnderLine == TextDecorations.Underline)
|
325 |
|
|
{
|
326 |
|
|
_instance.Base_TextBox.TextDecorations = _instance.UnderLine;
|
327 |
|
|
}
|
328 |
|
|
_instance.Base_TextBox.IsHitTestVisible = false;
|
329 |
684ef11c
|
ljiyeon
|
}
|
330 |
c00d0547
|
humkyung
|
else if (control is TextControl)
|
331 |
|
|
{
|
332 |
|
|
TextControl text = control as TextControl;
|
333 |
|
|
text.Base_TextBlock.TextDecorations = text.UnderLine;
|
334 |
|
|
text.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
|
335 |
|
|
text.Base_TextBox.Visibility = Visibility.Collapsed;
|
336 |
|
|
text.Base_TextBlock.Visibility = Visibility.Visible;
|
337 |
|
|
}
|
338 |
|
|
else if (control is SymControlN)
|
339 |
|
|
{
|
340 |
|
|
SymControlN _instance = control as SymControlN;
|
341 |
787a4489
|
KangIngu
|
|
342 |
cd988cd8
|
djkim
|
var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStamp(_instance.PathXathData);
|
343 |
|
|
|
344 |
c00d0547
|
humkyung
|
System.IO.MemoryStream stream = new System.IO.MemoryStream();
|
345 |
|
|
System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
|
346 |
58b52175
|
ljiyeon
|
xamlData = xamlData.Replace("#FFFF0000", DisplayColor);
|
347 |
c00d0547
|
humkyung
|
writer.Write(xamlData);
|
348 |
|
|
writer.Flush();
|
349 |
|
|
stream.Position = 0;
|
350 |
661b7416
|
humkyung
|
|
351 |
c00d0547
|
humkyung
|
object obj = XamlReader.Load(stream);
|
352 |
|
|
_instance.Base_ViewBox.Child = obj as UIElement;
|
353 |
|
|
_instance.SetViewBox();
|
354 |
|
|
}
|
355 |
5529d2a2
|
humkyung
|
}
|
356 |
661b7416
|
humkyung
|
}
|
357 |
|
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
5529d2a2
|
humkyung
|
return res;
|
361 |
661b7416
|
humkyung
|
}
|
362 |
|
|
|
363 |
24c5e56c
|
taeseongkim
|
public static async Task<S_BaseControl> GetBaseControlAsync(string MarkupString, System.Threading.CancellationToken cts)
|
364 |
661b7416
|
humkyung
|
{
|
365 |
24c5e56c
|
taeseongkim
|
var item = await JsonSerializerHelper.UnCompressStringAsync(MarkupString,cts); //언패킹작업
|
366 |
661b7416
|
humkyung
|
var unknownData = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); //복호화작업
|
367 |
|
|
return unknownData;
|
368 |
|
|
}
|
369 |
787a4489
|
KangIngu
|
|
370 |
ac4f1e13
|
taeseongkim
|
public static async Task<string> GetMemoAsync(string MarkupString)
|
371 |
5529d2a2
|
humkyung
|
{
|
372 |
24c5e56c
|
taeseongkim
|
var item = await JsonSerializerHelper.UnCompressStringAsync(MarkupString,null); //언패킹작업
|
373 |
5529d2a2
|
humkyung
|
var unknownData = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); //복호화작업
|
374 |
|
|
return unknownData.Memo;
|
375 |
|
|
}
|
376 |
684ef11c
|
ljiyeon
|
|
377 |
5529d2a2
|
humkyung
|
//GUID생성(최민수 사원 수정)
|
378 |
|
|
private static string shortGuid()
|
379 |
|
|
{
|
380 |
|
|
byte[] bytes = new byte[16];
|
381 |
|
|
using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
|
382 |
|
|
{
|
383 |
|
|
provider.GetBytes(bytes);
|
384 |
|
|
}
|
385 |
661b7416
|
humkyung
|
|
386 |
5529d2a2
|
humkyung
|
var guid = new Guid(bytes);
|
387 |
787a4489
|
KangIngu
|
|
388 |
5529d2a2
|
humkyung
|
return Convert.ToBase64String(guid.ToByteArray())
|
389 |
|
|
.Substring(0, 10)
|
390 |
|
|
.Replace("/", "")
|
391 |
|
|
.Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
|
392 |
787a4489
|
KangIngu
|
}
|
393 |
|
|
}
|
394 |
5529d2a2
|
humkyung
|
} |