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