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