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 System.ComponentModel;
|
13 |
|
|
using System.Linq;
|
14 |
|
|
using MarkupToPDF.Controls.Common;
|
15 |
|
|
using MarkupToPDF.Common;
|
16 |
036650a0
|
humkyung
|
using MarkupToPDF.Serialize.Core;
|
17 |
|
|
using MarkupToPDF.Serialize.S_Control;
|
18 |
661b7416
|
humkyung
|
using System.Windows.Media.Imaging;
|
19 |
366f00c2
|
taeseongkim
|
using System.Threading.Tasks;
|
20 |
787a4489
|
KangIngu
|
|
21 |
|
|
//강인구 추가
|
22 |
|
|
namespace MarkupToPDF.Controls.Etc
|
23 |
|
|
{
|
24 |
|
|
[TemplatePart(Name = "PART_Image", Type = typeof(Image))]
|
25 |
|
|
public class SignControl : CommentUserInfo, IDisposable, INormal, INotifyPropertyChanged, IPath, IViewBox, IMarkupCommonData
|
26 |
|
|
{
|
27 |
|
|
#region 초기선언
|
28 |
a6272c57
|
humkyung
|
public string ProjectNO { get; set; }
|
29 |
|
|
|
30 |
787a4489
|
KangIngu
|
private const string PART_Image = "PART_Image";
|
31 |
|
|
public Image Base_Image = null;
|
32 |
|
|
#endregion
|
33 |
|
|
|
34 |
|
|
static SignControl()
|
35 |
|
|
{
|
36 |
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(SignControl), new FrameworkPropertyMetadata(typeof(SignControl)));
|
37 |
|
|
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
|
38 |
a6f7f9b6
|
djkim
|
//ResourceDictionary dictionary = new ResourceDictionary();
|
39 |
|
|
//dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
|
40 |
|
|
//Application.Current.Resources.MergedDictionaries.Add(dictionary);
|
41 |
|
|
//System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count);
|
42 |
787a4489
|
KangIngu
|
}
|
43 |
|
|
|
44 |
|
|
public void Dispose()
|
45 |
|
|
{
|
46 |
a6f7f9b6
|
djkim
|
//GC.Collect();
|
47 |
24c5e56c
|
taeseongkim
|
////GC.SuppressFinalize(this);
|
48 |
a6f7f9b6
|
djkim
|
this.Base_Image = null;
|
49 |
787a4489
|
KangIngu
|
}
|
50 |
|
|
#region Dependency Properties
|
51 |
|
|
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
|
52 |
|
|
"UserID", typeof(string), typeof(SignControl), new PropertyMetadata(null));
|
53 |
|
|
public static readonly DependencyProperty SignImageProperty = DependencyProperty.Register(
|
54 |
|
|
"SignImage", typeof(ImageSource), typeof(SignControl), new PropertyMetadata(null));
|
55 |
|
|
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
|
56 |
|
|
"StartPoint", typeof(Point), typeof(SignControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
57 |
|
|
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
|
58 |
|
|
"EndPoint", typeof(Point), typeof(SignControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
59 |
|
|
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
|
60 |
|
|
"PointSet", typeof(List<Point>), typeof(SignControl), new PropertyMetadata(new List<Point>()));
|
61 |
|
|
public static readonly DependencyProperty UserNubmerProperty = DependencyProperty.Register(
|
62 |
|
|
"UserNumber", typeof(string), typeof(SignControl), new PropertyMetadata(null));
|
63 |
|
|
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register(
|
64 |
|
|
"TopRightPoint", typeof(Point), typeof(SignControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
65 |
|
|
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register(
|
66 |
|
|
"LeftBottomPoint", typeof(Point), typeof(SignControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
67 |
|
|
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(SignControl),
|
68 |
|
|
new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
|
69 |
|
|
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(SignControl),
|
70 |
|
|
new PropertyMetadata((double)0, OnCenterXYChanged));
|
71 |
|
|
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(SignControl),
|
72 |
|
|
new PropertyMetadata((double)0, OnCenterXYChanged));
|
73 |
|
|
public static readonly DependencyProperty IsSelectedProperty =
|
74 |
|
|
DependencyProperty.Register("IsSelected", typeof(bool), typeof(SignControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
|
75 |
|
|
|
76 |
|
|
public static readonly DependencyProperty ControlTypeProperty =
|
77 |
|
|
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(SignControl), new FrameworkPropertyMetadata(ControlType.Sign));
|
78 |
|
|
#endregion
|
79 |
|
|
#region PropertyChanged Method
|
80 |
|
|
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
81 |
|
|
{
|
82 |
|
|
var instance = (SignControl)sender;
|
83 |
|
|
if (e.OldValue != e.NewValue && instance.Base_Image != null)
|
84 |
|
|
{
|
85 |
|
|
instance.SetValue(e.Property, e.NewValue);
|
86 |
|
|
instance.SetImage();
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
90 |
|
|
{
|
91 |
|
|
|
92 |
|
|
}
|
93 |
|
|
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
94 |
|
|
{
|
95 |
|
|
var instance = (SignControl)sender;
|
96 |
|
|
if (e.OldValue != e.NewValue && instance.Base_Image != null)
|
97 |
|
|
{
|
98 |
|
|
instance.SetValue(e.Property, e.NewValue);
|
99 |
|
|
instance.SetImage();
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
103 |
|
|
{
|
104 |
|
|
var instance = (SignControl)sender;
|
105 |
|
|
if (e.OldValue != e.NewValue && instance.Base_Image != null)
|
106 |
|
|
{
|
107 |
|
|
instance.SetValue(e.Property, e.NewValue);
|
108 |
|
|
instance.SetImage();
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
#endregion
|
112 |
|
|
#region Properties
|
113 |
|
|
public string UserID
|
114 |
|
|
{
|
115 |
|
|
get { return (string)GetValue(UserIDProperty); }
|
116 |
|
|
set
|
117 |
|
|
{
|
118 |
|
|
if (this.UserID != value)
|
119 |
|
|
{
|
120 |
|
|
SetValue(UserIDProperty, value);
|
121 |
|
|
RaisePropertyChanged("UserID");
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
|
|
}
|
125 |
eeb0a39c
|
taeseongkim
|
|
126 |
787a4489
|
KangIngu
|
public double CenterX
|
127 |
|
|
{
|
128 |
|
|
get { return (double)GetValue(CenterXProperty); }
|
129 |
|
|
set { SetValue(CenterXProperty, value); }
|
130 |
|
|
}
|
131 |
|
|
public double CenterY
|
132 |
|
|
{
|
133 |
|
|
get { return (double)GetValue(CenterYProperty); }
|
134 |
|
|
set { SetValue(CenterYProperty, value); }
|
135 |
|
|
}
|
136 |
|
|
public Point EndPoint
|
137 |
|
|
{
|
138 |
|
|
get { return (Point)GetValue(EndPointProperty); }
|
139 |
|
|
set
|
140 |
|
|
{
|
141 |
|
|
if (this.EndPoint != value)
|
142 |
|
|
{
|
143 |
|
|
SetValue(EndPointProperty, value);
|
144 |
|
|
RaisePropertyChanged("EndPoint");
|
145 |
|
|
}
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
public List<Point> PointSet
|
149 |
|
|
{
|
150 |
|
|
get { return (List<Point>)GetValue(PointSetProperty); }
|
151 |
|
|
set { SetValue(PointSetProperty, value); }
|
152 |
|
|
}
|
153 |
|
|
public Point StartPoint
|
154 |
|
|
{
|
155 |
|
|
get { return (Point)GetValue(StartPointProperty); }
|
156 |
|
|
set
|
157 |
|
|
{
|
158 |
|
|
if (this.StartPoint != value)
|
159 |
|
|
{
|
160 |
|
|
SetValue(StartPointProperty, value);
|
161 |
|
|
RaisePropertyChanged("StartPoint");
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
}
|
165 |
|
|
public string UserNumber
|
166 |
|
|
{
|
167 |
|
|
get { return (string)GetValue(UserNubmerProperty); }
|
168 |
|
|
set
|
169 |
|
|
{
|
170 |
|
|
if (this.UserNumber != value)
|
171 |
|
|
{
|
172 |
|
|
SetValue(UserNubmerProperty, value);
|
173 |
|
|
RaisePropertyChanged("UserNumber");
|
174 |
|
|
}
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
public Point TopRightPoint
|
178 |
|
|
{
|
179 |
|
|
get { return (Point)GetValue(TopRightPointProperty); }
|
180 |
|
|
set
|
181 |
|
|
{
|
182 |
|
|
SetValue(TopRightPointProperty, value);
|
183 |
|
|
RaisePropertyChanged("TopRightPoint");
|
184 |
|
|
}
|
185 |
|
|
}
|
186 |
|
|
public Point LeftBottomPoint
|
187 |
|
|
{
|
188 |
|
|
get { return (Point)GetValue(LeftBottomPointProperty); }
|
189 |
|
|
set
|
190 |
|
|
{
|
191 |
|
|
SetValue(LeftBottomPointProperty, value);
|
192 |
|
|
RaisePropertyChanged("LeftBottomPoint");
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
fa48eb85
|
taeseongkim
|
public override double CommentAngle
|
196 |
787a4489
|
KangIngu
|
{
|
197 |
|
|
get { return (double)GetValue(AngleProperty); }
|
198 |
|
|
set
|
199 |
|
|
{
|
200 |
fa48eb85
|
taeseongkim
|
if (this.CommentAngle != value)
|
201 |
787a4489
|
KangIngu
|
{
|
202 |
|
|
SetValue(AngleProperty, value);
|
203 |
|
|
}
|
204 |
|
|
}
|
205 |
|
|
}
|
206 |
|
|
public ImageSource SignImage
|
207 |
|
|
{
|
208 |
|
|
get { return (ImageSource)this.GetValue(SignImageProperty); }
|
209 |
|
|
set { this.SetValue(SignImageProperty, value); }
|
210 |
|
|
}
|
211 |
|
|
|
212 |
959b3ef2
|
humkyung
|
public override bool IsSelected
|
213 |
787a4489
|
KangIngu
|
{
|
214 |
|
|
get
|
215 |
|
|
{
|
216 |
|
|
return (bool)GetValue(IsSelectedProperty);
|
217 |
|
|
}
|
218 |
|
|
set
|
219 |
|
|
{
|
220 |
|
|
SetValue(IsSelectedProperty, value);
|
221 |
|
|
}
|
222 |
|
|
}
|
223 |
|
|
|
224 |
5529d2a2
|
humkyung
|
public override ControlType ControlType
|
225 |
787a4489
|
KangIngu
|
{
|
226 |
|
|
set
|
227 |
|
|
{
|
228 |
|
|
SetValue(ControlTypeProperty, value);
|
229 |
|
|
}
|
230 |
|
|
get
|
231 |
|
|
{
|
232 |
|
|
return (ControlType)GetValue(ControlTypeProperty);
|
233 |
|
|
}
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
#endregion
|
237 |
|
|
public override void OnApplyTemplate()
|
238 |
|
|
{
|
239 |
|
|
base.OnApplyTemplate();
|
240 |
|
|
Base_Image = GetTemplateChild(PART_Image) as Image;
|
241 |
|
|
SetImage();
|
242 |
|
|
}
|
243 |
661b7416
|
humkyung
|
|
244 |
|
|
private void SetImage()
|
245 |
787a4489
|
KangIngu
|
{
|
246 |
|
|
this.ApplyTemplate();
|
247 |
|
|
|
248 |
|
|
Point mid = MathSet.FindCentroid(new List<Point>()
|
249 |
|
|
{
|
250 |
|
|
this.StartPoint,
|
251 |
|
|
this.LeftBottomPoint,
|
252 |
|
|
this.EndPoint,
|
253 |
|
|
this.TopRightPoint,
|
254 |
|
|
});
|
255 |
|
|
|
256 |
fa48eb85
|
taeseongkim
|
double AngleData = this.CommentAngle * -1;
|
257 |
787a4489
|
KangIngu
|
|
258 |
|
|
PathFigure pathFigure = new PathFigure();
|
259 |
|
|
pathFigure.StartPoint = MathSet.RotateAbout(mid, this.StartPoint, AngleData);
|
260 |
|
|
|
261 |
|
|
LineSegment lineSegment0 = new LineSegment();
|
262 |
|
|
lineSegment0.Point = MathSet.RotateAbout(mid, this.StartPoint, AngleData);
|
263 |
|
|
pathFigure.Segments.Add(lineSegment0);
|
264 |
|
|
|
265 |
|
|
LineSegment lineSegment1 = new LineSegment();
|
266 |
|
|
lineSegment1.Point = MathSet.RotateAbout(mid, this.LeftBottomPoint, AngleData);
|
267 |
|
|
pathFigure.Segments.Add(lineSegment1);
|
268 |
|
|
|
269 |
|
|
LineSegment lineSegment2 = new LineSegment();
|
270 |
|
|
lineSegment2.Point = MathSet.RotateAbout(mid, this.EndPoint, AngleData);
|
271 |
|
|
pathFigure.Segments.Add(lineSegment2);
|
272 |
|
|
|
273 |
|
|
LineSegment lineSegment3 = new LineSegment();
|
274 |
|
|
lineSegment3.Point = MathSet.RotateAbout(mid, this.TopRightPoint, AngleData);
|
275 |
|
|
pathFigure.Segments.Add(lineSegment3);
|
276 |
|
|
|
277 |
|
|
PathGeometry pathGeometry = new PathGeometry();
|
278 |
|
|
pathGeometry.Figures = new PathFigureCollection();
|
279 |
|
|
pathFigure.IsClosed = true;
|
280 |
|
|
pathGeometry.Figures.Add(pathFigure);
|
281 |
|
|
this.Base_Image.Width = pathGeometry.Bounds.Width;
|
282 |
|
|
this.Base_Image.Height = pathGeometry.Bounds.Height;
|
283 |
|
|
this.Tag = pathGeometry;
|
284 |
|
|
|
285 |
|
|
Canvas.SetLeft(this, MathSet.RotateAbout(mid, mid, AngleData).X - this.Base_Image.Width / 2);
|
286 |
|
|
Canvas.SetTop(this, MathSet.RotateAbout(mid, mid, AngleData).Y - this.Base_Image.Height / 2);
|
287 |
|
|
}
|
288 |
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
289 |
|
|
protected void RaisePropertyChanged(string propName)
|
290 |
|
|
{
|
291 |
|
|
if (PropertyChanged != null)
|
292 |
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propName));
|
293 |
|
|
}
|
294 |
0d00f9c8
|
humkyung
|
|
295 |
|
|
public override void UpdateControl()
|
296 |
787a4489
|
KangIngu
|
{
|
297 |
|
|
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
|
298 |
|
|
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y);
|
299 |
|
|
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
|
300 |
|
|
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
|
301 |
|
|
}
|
302 |
036650a0
|
humkyung
|
|
303 |
|
|
/// <summary>
|
304 |
a6272c57
|
humkyung
|
/// call when mouse is moving while drawing control
|
305 |
|
|
/// </summary>
|
306 |
|
|
/// <author>humkyung</author>
|
307 |
|
|
/// <param name="pt"></param>
|
308 |
|
|
/// <param name="bAxisLocked"></param>
|
309 |
233ef333
|
taeseongkim
|
public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
|
310 |
a6272c57
|
humkyung
|
{
|
311 |
|
|
this.EndPoint = pt;
|
312 |
|
|
this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y);
|
313 |
|
|
this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y);
|
314 |
74abcf6f
|
taeseongkim
|
|
315 |
|
|
var _sign = Application.Current.FindResource("UserSign");
|
316 |
|
|
|
317 |
|
|
if (this.StartPoint != this.EndPoint && this.SignImage == null && _sign != null)
|
318 |
a6272c57
|
humkyung
|
{
|
319 |
74abcf6f
|
taeseongkim
|
//var _sign = GetUserSign.GetSign(this.UserNumber, this.ProjectNO);
|
320 |
366f00c2
|
taeseongkim
|
|
321 |
74abcf6f
|
taeseongkim
|
byte[] imageBytes = System.Convert.FromBase64String(_sign.ToString());
|
322 |
eeb0a39c
|
taeseongkim
|
|
323 |
a6272c57
|
humkyung
|
System.IO.MemoryStream stream = new System.IO.MemoryStream();
|
324 |
|
|
stream.Write(imageBytes, 0, imageBytes.Length);
|
325 |
|
|
stream.Position = 0;
|
326 |
|
|
System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
|
327 |
|
|
BitmapImage returnImage = new BitmapImage();
|
328 |
|
|
returnImage.BeginInit();
|
329 |
|
|
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
330 |
|
|
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
331 |
|
|
ms.Seek(0, System.IO.SeekOrigin.Begin);
|
332 |
|
|
returnImage.StreamSource = ms;
|
333 |
|
|
returnImage.EndInit();
|
334 |
|
|
stream.Close();
|
335 |
|
|
|
336 |
|
|
this.SignImage = returnImage;
|
337 |
|
|
}
|
338 |
eeb0a39c
|
taeseongkim
|
|
339 |
a6272c57
|
humkyung
|
this.PointSet = new List<Point>
|
340 |
|
|
{
|
341 |
|
|
this.StartPoint,
|
342 |
|
|
this.LeftBottomPoint,
|
343 |
|
|
this.EndPoint,
|
344 |
|
|
this.TopRightPoint,
|
345 |
|
|
};
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
/// <summary>
|
349 |
d2114d3b
|
humkyung
|
/// move control point has same location of given pt along given delta
|
350 |
|
|
/// </summary>
|
351 |
|
|
/// <author>humkyung</author>
|
352 |
|
|
/// <date>2019.06.20</date>
|
353 |
|
|
/// <param name="pt"></param>
|
354 |
|
|
/// <param name="dx"></param>
|
355 |
|
|
/// <param name="dy"></param>
|
356 |
233ef333
|
taeseongkim
|
public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
|
357 |
d2114d3b
|
humkyung
|
{
|
358 |
|
|
IPath path = (this as IPath);
|
359 |
|
|
|
360 |
|
|
Point selected = MathSet.getNearPoint(path.PointSet, pt);
|
361 |
|
|
selected.X += dx;
|
362 |
|
|
selected.Y += dy;
|
363 |
|
|
int i = 0;
|
364 |
|
|
for (i = 0; i < (this as IPath).PointSet.Count; i++)
|
365 |
|
|
{
|
366 |
|
|
if (pt.Equals((this as IPath).PointSet[i]))
|
367 |
|
|
{
|
368 |
|
|
path.PointSet[i] = selected;
|
369 |
|
|
break;
|
370 |
|
|
}
|
371 |
|
|
}
|
372 |
|
|
|
373 |
|
|
var ReverseP = (i + path.PointSet.Count() / 2) % path.PointSet.Count();
|
374 |
|
|
var PreviousP = (i + (path.PointSet.Count() - 1)) % path.PointSet.Count();
|
375 |
|
|
var NextP = (i + 1) % path.PointSet.Count();
|
376 |
|
|
|
377 |
|
|
var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]);
|
378 |
|
|
|
379 |
|
|
var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]);
|
380 |
|
|
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X,
|
381 |
|
|
path.PointSet[i].Y - path.PointSet[ReverseP].Y);
|
382 |
|
|
path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet[ReverseP].Y + PreviousV.Y * l);
|
383 |
|
|
|
384 |
|
|
var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]);
|
385 |
|
|
l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet
|
386 |
|
|
[i].Y - path.PointSet[ReverseP].Y);
|
387 |
|
|
path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l);
|
388 |
|
|
|
389 |
0d00f9c8
|
humkyung
|
this.UpdateControl();
|
390 |
d2114d3b
|
humkyung
|
}
|
391 |
|
|
|
392 |
|
|
/// <summary>
|
393 |
91efe37a
|
humkyung
|
/// return SignControl's area
|
394 |
|
|
/// </summary>
|
395 |
|
|
/// <author>humkyung</author>
|
396 |
|
|
/// <date>2019.06.13</date>
|
397 |
|
|
public override Rect ItemRect
|
398 |
|
|
{
|
399 |
|
|
get
|
400 |
|
|
{
|
401 |
|
|
double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
|
402 |
|
|
double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
|
403 |
|
|
double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
|
404 |
|
|
double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
|
405 |
|
|
|
406 |
|
|
return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
|
407 |
|
|
}
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
/// <summary>
|
411 |
036650a0
|
humkyung
|
/// Serialize this
|
412 |
|
|
/// </summary>
|
413 |
|
|
/// <param name="sUserId"></param>
|
414 |
|
|
/// <returns></returns>
|
415 |
|
|
public override string Serialize()
|
416 |
|
|
{
|
417 |
|
|
using (S_SignControl STemp = new S_SignControl())
|
418 |
|
|
{
|
419 |
fa48eb85
|
taeseongkim
|
STemp.Angle = this.CommentAngle;
|
420 |
036650a0
|
humkyung
|
STemp.EndPoint = this.EndPoint;
|
421 |
|
|
STemp.UserID = this.UserID;
|
422 |
|
|
STemp.LB = this.LeftBottomPoint;
|
423 |
|
|
STemp.Name = this.GetType().Name;
|
424 |
|
|
STemp.PointSet = this.PointSet;
|
425 |
|
|
STemp.StartPoint = this.StartPoint;
|
426 |
|
|
STemp.Opac = this.Opacity;
|
427 |
|
|
STemp.TR = this.TopRightPoint;
|
428 |
|
|
STemp.UserNumber = this.UserNumber == null ? this.UserID: this.UserNumber;
|
429 |
|
|
|
430 |
|
|
///강인구 추가(2017.11.02)
|
431 |
|
|
///Memo 추가
|
432 |
|
|
STemp.Memo = this.Memo;
|
433 |
|
|
|
434 |
|
|
return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
|
435 |
|
|
}
|
436 |
|
|
}
|
437 |
|
|
|
438 |
661b7416
|
humkyung
|
/// <summary>
|
439 |
|
|
/// create a signcontrol from given string
|
440 |
|
|
/// </summary>
|
441 |
|
|
/// <param name="str"></param>
|
442 |
|
|
/// <returns></returns>
|
443 |
|
|
public static SignControl FromString(string str, SolidColorBrush brush, string sProjectNo)
|
444 |
|
|
{
|
445 |
|
|
SignControl instance = null;
|
446 |
|
|
using (S_SignControl s = JsonSerializerHelper.JsonDeserialize<S_SignControl>(str))
|
447 |
|
|
{
|
448 |
|
|
instance = new SignControl
|
449 |
|
|
{
|
450 |
fa48eb85
|
taeseongkim
|
CommentAngle = s.Angle,
|
451 |
661b7416
|
humkyung
|
StartPoint = s.StartPoint,
|
452 |
|
|
TopRightPoint = s.TR,
|
453 |
|
|
EndPoint = s.EndPoint,
|
454 |
|
|
LeftBottomPoint = s.LB,
|
455 |
|
|
PointSet = s.PointSet,
|
456 |
|
|
Opacity = s.Opac,
|
457 |
|
|
SignImage = null,
|
458 |
|
|
UserID = s.UserID,
|
459 |
8f15cc2b
|
humkyung
|
UserNumber = s.UserNumber,
|
460 |
661b7416
|
humkyung
|
Memo = s.Memo
|
461 |
|
|
};
|
462 |
|
|
|
463 |
|
|
if (s.UserNumber != null)
|
464 |
|
|
{
|
465 |
|
|
var _sign = GetUserSign.GetSign(s.UserNumber, sProjectNo);
|
466 |
|
|
if (_sign != null)
|
467 |
|
|
{
|
468 |
|
|
byte[] imageBytes = System.Convert.FromBase64String(_sign);
|
469 |
|
|
|
470 |
|
|
BitmapImage returnImage = new BitmapImage();
|
471 |
ac4f1e13
|
taeseongkim
|
|
472 |
|
|
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
|
473 |
|
|
{
|
474 |
|
|
stream.WriteAsync(imageBytes, 0, imageBytes.Length);
|
475 |
366f00c2
|
taeseongkim
|
|
476 |
ac4f1e13
|
taeseongkim
|
stream.Position = 0;
|
477 |
|
|
System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
|
478 |
|
|
returnImage.BeginInit();
|
479 |
|
|
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
480 |
|
|
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
481 |
|
|
ms.Seek(0, System.IO.SeekOrigin.Begin);
|
482 |
|
|
returnImage.StreamSource = ms;
|
483 |
|
|
returnImage.EndInit();
|
484 |
|
|
stream.Close();
|
485 |
|
|
}
|
486 |
|
|
|
487 |
661b7416
|
humkyung
|
instance.SignImage = returnImage;
|
488 |
|
|
}
|
489 |
|
|
}
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
return instance;
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
public double LineSize
|
496 |
787a4489
|
KangIngu
|
{
|
497 |
|
|
get;
|
498 |
|
|
set;
|
499 |
|
|
}
|
500 |
|
|
public Geometry PathData
|
501 |
|
|
{
|
502 |
|
|
get;
|
503 |
|
|
set;
|
504 |
|
|
}
|
505 |
|
|
}
|
506 |
|
|
} |