1
|
using KCOM.Common;
|
2
|
using KCOM.Events;
|
3
|
using MarkupToPDF.Common;
|
4
|
using MarkupToPDF.Controls.Cad;
|
5
|
using MarkupToPDF.Controls.Common;
|
6
|
using MarkupToPDF.Controls.Etc;
|
7
|
using MarkupToPDF.Controls.Line;
|
8
|
using MarkupToPDF.Controls.Parsing;
|
9
|
using MarkupToPDF.Controls.Polygon;
|
10
|
using MarkupToPDF.Controls.Shape;
|
11
|
using MarkupToPDF.Controls.Text;
|
12
|
using System;
|
13
|
using System.Collections.Generic;
|
14
|
using System.Diagnostics;
|
15
|
using System.Linq;
|
16
|
using System.Text;
|
17
|
using System.Threading.Tasks;
|
18
|
using System.Windows;
|
19
|
using System.Windows.Controls;
|
20
|
using System.Windows.Controls.Primitives;
|
21
|
using System.Windows.Input;
|
22
|
using System.Windows.Media;
|
23
|
using Telerik.Windows.Controls;
|
24
|
|
25
|
namespace KCOM.Controls
|
26
|
{
|
27
|
public class MyThumb : Thumb
|
28
|
{
|
29
|
public MyThumb()
|
30
|
{
|
31
|
this.Opacity = 0.6;
|
32
|
this.MouseEnter += MyThumb_MouseEnter;
|
33
|
this.MouseLeave += MyThumb_MouseLeave;
|
34
|
}
|
35
|
|
36
|
/// <summary>
|
37
|
/// translate thumb with given delta and angle
|
38
|
/// </summary>
|
39
|
/// <param name="e"></param>
|
40
|
/// <param name="angle"></param>
|
41
|
public void Translate_old(double dx, double dy, double angle)
|
42
|
{
|
43
|
double radian = angle * Math.PI / 180;
|
44
|
double cos = Math.Cos(radian);
|
45
|
double sin = Math.Sin(radian);
|
46
|
|
47
|
double _dx = dx * cos - dy * sin;
|
48
|
double _dy = dx * sin + dy * cos;
|
49
|
|
50
|
Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx);
|
51
|
Canvas.SetTop(this, Canvas.GetTop(this) + _dy);
|
52
|
}
|
53
|
|
54
|
public void Translate(double dx, double dy, double angle)
|
55
|
{
|
56
|
var ratotePoint = MathHelper.RotatePoint(new Point(dx, dy), new Point(), angle);
|
57
|
|
58
|
Canvas.SetLeft(this, Canvas.GetLeft(this) + ratotePoint.X);
|
59
|
Canvas.SetTop(this, Canvas.GetTop(this) + ratotePoint.Y);
|
60
|
}
|
61
|
|
62
|
|
63
|
/// <summary>
|
64
|
/// </summary>
|
65
|
/// <param name="sender"></param>
|
66
|
/// <param name="e"></param>
|
67
|
private void MyThumb_MouseLeave(object sender, MouseEventArgs e)
|
68
|
{
|
69
|
this.Opacity = 0.6;
|
70
|
}
|
71
|
|
72
|
/// <summary>
|
73
|
///
|
74
|
/// </summary>
|
75
|
/// <param name="sender"></param>
|
76
|
/// <param name="e"></param>
|
77
|
private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
|
78
|
{
|
79
|
this.Opacity = 1.0;
|
80
|
}
|
81
|
}
|
82
|
|
83
|
/// <summary>
|
84
|
/// Interaction logic for AdornerFinal.xaml
|
85
|
/// </summary>
|
86
|
public class AdornerMember
|
87
|
{
|
88
|
public UIElement DrawingData { get; set; }
|
89
|
public ControlType Drawingtype { get; set; }
|
90
|
public double DrawingAngle { get; set; }
|
91
|
public List<MyThumb> ThumbList { get; set; }
|
92
|
public string Symbol_ID { get; set; }
|
93
|
public long Group_ID { get; set; }
|
94
|
|
95
|
/// <summary>
|
96
|
/// update thumb
|
97
|
/// </summary>
|
98
|
public void UpdateThumb()
|
99
|
{
|
100
|
var path = this.DrawingData as IPath;
|
101
|
for (int i = 0; i < path.PointSet.Count; ++i)
|
102
|
{
|
103
|
Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X);
|
104
|
Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
|
105
|
}
|
106
|
|
107
|
if (this.DrawingData as ArrowTextControl != null)
|
108
|
{
|
109
|
if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
|
110
|
{
|
111
|
List<Point> ps = new List<Point>();
|
112
|
|
113
|
var temp = this.DrawingData as ArrowTextControl;
|
114
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
|
115
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
|
116
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
|
117
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단
|
118
|
|
119
|
if (temp.isFixed)
|
120
|
{
|
121
|
var endP = MathSet.getNearPoint(ps, temp.MidPoint);
|
122
|
var testP = endP;
|
123
|
if (ps[0] == endP) //상단
|
124
|
{
|
125
|
testP = new Point(endP.X, endP.Y - 50);
|
126
|
}
|
127
|
else if (ps[1] == endP) //하단
|
128
|
{
|
129
|
testP = new Point(endP.X, endP.Y + 50);
|
130
|
}
|
131
|
else if (ps[2] == endP) //좌단
|
132
|
{
|
133
|
testP = new Point(endP.X - 50, endP.Y);
|
134
|
}
|
135
|
else if (ps[3] == endP) //우단
|
136
|
{
|
137
|
testP = new Point(endP.X + 50, endP.Y);
|
138
|
}
|
139
|
Canvas.SetLeft(this.ThumbList[1], testP.X);
|
140
|
Canvas.SetTop(this.ThumbList[1], testP.Y);
|
141
|
}
|
142
|
else
|
143
|
{
|
144
|
var endP = MathSet.getNearPoint(ps, temp.MidPoint);
|
145
|
var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
|
146
|
Canvas.SetLeft(this.ThumbList[1], tempP.X);
|
147
|
Canvas.SetTop(this.ThumbList[1], tempP.Y);
|
148
|
}
|
149
|
}
|
150
|
}
|
151
|
}
|
152
|
|
153
|
/// <summary>
|
154
|
/// rotate members about given position and angle
|
155
|
/// </summary>
|
156
|
/// <param name="at"></param>
|
157
|
/// <param name="angle">in degree</param>
|
158
|
public void RotateAbout(Point at, double angle)
|
159
|
{
|
160
|
for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
|
161
|
{
|
162
|
(this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
|
163
|
}
|
164
|
(this.DrawingData as CommentUserInfo).UpdateControl();
|
165
|
|
166
|
this.UpdateThumb();
|
167
|
}
|
168
|
}
|
169
|
|
170
|
public partial class AdornerFinal : UserControl
|
171
|
{
|
172
|
public TextBox editTextBox { get; set; }
|
173
|
#region 공용 인스턴스
|
174
|
public List<AdornerMember> Members { get; } = new List<AdornerMember>();
|
175
|
public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
|
176
|
|
177
|
private double angleValue;
|
178
|
|
179
|
public double AngleValue { get => angleValue;
|
180
|
set
|
181
|
{
|
182
|
if(angleValue != value)
|
183
|
{
|
184
|
angleValue = value;
|
185
|
}
|
186
|
}
|
187
|
}
|
188
|
|
189
|
|
190
|
public bool IsTextAngle = false;
|
191
|
public Rect BorderSize { get; set; }
|
192
|
public bool TextCompensation = false;
|
193
|
public bool isDragging { get; set; }
|
194
|
public Thumb DraggerThumb { get; set; }
|
195
|
public RadDropDownButton dropData;
|
196
|
public RadCalendar dropCalendar;
|
197
|
public Thumb mainDragThumb { get; set; }
|
198
|
|
199
|
private bool disposed;
|
200
|
|
201
|
public Point reSizePoint { get; set; }
|
202
|
private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
|
203
|
private Point MouseDownPoint = new Point();
|
204
|
private Point CurrentMousePoint = new Point();
|
205
|
#endregion
|
206
|
#region 생성자
|
207
|
private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
|
208
|
{
|
209
|
dropData = sender as RadDropDownButton;
|
210
|
}
|
211
|
|
212
|
private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
|
213
|
{
|
214
|
dropCalendar = sender as RadCalendar;
|
215
|
dropCalendar.SelectionChanged += (sen, ea) =>
|
216
|
{
|
217
|
dropData.IsOpen = false;
|
218
|
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
|
219
|
{
|
220
|
DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
|
221
|
data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
|
222
|
}
|
223
|
};
|
224
|
}
|
225
|
|
226
|
public AdornerFinal()
|
227
|
{
|
228
|
InitializeComponent();
|
229
|
BorderSize = new Rect();
|
230
|
_dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
|
231
|
}
|
232
|
|
233
|
~AdornerFinal()
|
234
|
{
|
235
|
this.Dispose(false);
|
236
|
}
|
237
|
|
238
|
public void Dispose()
|
239
|
{
|
240
|
this.Dispose(true);
|
241
|
GC.SuppressFinalize(this);
|
242
|
}
|
243
|
|
244
|
protected virtual void Dispose(bool disposing)
|
245
|
{
|
246
|
if (this.disposed) return;
|
247
|
if (disposing)
|
248
|
{
|
249
|
foreach (var member in this.Members)
|
250
|
{
|
251
|
if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
|
252
|
Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
|
253
|
}
|
254
|
// IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
|
255
|
}
|
256
|
// .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
|
257
|
this.disposed = true;
|
258
|
}
|
259
|
|
260
|
void DragThumb_Loaded(object sender, RoutedEventArgs e)
|
261
|
{
|
262
|
mainDragThumb = DragThumb;
|
263
|
}
|
264
|
|
265
|
public AdornerFinal(CommentUserInfo objectData) : this()
|
266
|
{
|
267
|
InitializeComponent();
|
268
|
objectData.IsHitTestVisible = false;
|
269
|
if ((objectData as ArrowTextControl) != null)
|
270
|
{
|
271
|
(objectData as ArrowTextControl).Base_TextBox.Focusable = true;
|
272
|
}
|
273
|
Canvas.SetZIndex(objectData, 84);
|
274
|
try
|
275
|
{
|
276
|
ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
|
277
|
this.ContainerContent.Children.Add(objectData);
|
278
|
}
|
279
|
catch (Exception ex)
|
280
|
{
|
281
|
|
282
|
}
|
283
|
|
284
|
SetAdornerMember(objectData as CommentUserInfo);
|
285
|
this.Focus();
|
286
|
}
|
287
|
|
288
|
public AdornerFinal(List<CommentUserInfo> objectData) : this()
|
289
|
{
|
290
|
InitializeComponent();
|
291
|
foreach (var item in objectData)
|
292
|
{
|
293
|
//item.IsHitTestVisible = false;
|
294
|
if ((item as ArrowTextControl) != null)
|
295
|
{
|
296
|
(item as ArrowTextControl).Base_TextBox.Focusable = true;
|
297
|
}
|
298
|
try
|
299
|
{
|
300
|
Canvas.SetZIndex(item, 80);
|
301
|
ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
|
302
|
this.ContainerContent.Children.Add(item);
|
303
|
}
|
304
|
catch //(Exception ex)
|
305
|
{
|
306
|
}
|
307
|
finally
|
308
|
{
|
309
|
|
310
|
}
|
311
|
}
|
312
|
this.SetAdornerMember(objectData);
|
313
|
this.Focus();
|
314
|
}
|
315
|
|
316
|
public Point Centeroid
|
317
|
{
|
318
|
get
|
319
|
{
|
320
|
List<Point> pts = new List<Point>();
|
321
|
|
322
|
#region 센터 포인트 구하기 (그룹핑)
|
323
|
foreach (var item in this.Members)
|
324
|
{
|
325
|
if (item.DrawingData.GetType().Name == "TextControl")
|
326
|
{
|
327
|
if (AngleValue == 0)
|
328
|
{
|
329
|
AngleValue = (item.DrawingData as TextControl).CommentAngle;
|
330
|
}
|
331
|
double X = Canvas.GetLeft((item.DrawingData as TextControl));
|
332
|
double Y = Canvas.GetTop((item.DrawingData as TextControl));
|
333
|
pts.Add(new Point(X, Y));
|
334
|
}
|
335
|
else
|
336
|
{
|
337
|
pts.AddRange((item.DrawingData as IPath).PointSet);
|
338
|
}
|
339
|
}
|
340
|
#endregion
|
341
|
|
342
|
return MathSet.FindCentroid(pts);
|
343
|
}
|
344
|
}
|
345
|
|
346
|
#endregion
|
347
|
#region 메서드
|
348
|
public Rect getAdornerSize()
|
349
|
{
|
350
|
return BorderSize;
|
351
|
}
|
352
|
public void addMemberControl(UIElement objectData)
|
353
|
{
|
354
|
this.ContainerContent.Children.Add(objectData);
|
355
|
SetAdornerMember(objectData as CommentUserInfo);
|
356
|
this.Focus();
|
357
|
}
|
358
|
|
359
|
private void TextControlLostFocus(object sender,RoutedEventArgs e)
|
360
|
{
|
361
|
TextCompensation = false;
|
362
|
BorderUpdate();
|
363
|
|
364
|
if (sender is TextBox)
|
365
|
{
|
366
|
if ((sender as TextBox).Text == "") //보류
|
367
|
{
|
368
|
this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
|
369
|
this.Visibility = Visibility.Collapsed;
|
370
|
}
|
371
|
}
|
372
|
}
|
373
|
|
374
|
private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
375
|
{
|
376
|
if (sender is TextControl)
|
377
|
{
|
378
|
TextCompensation = true;
|
379
|
BorderUpdate();
|
380
|
}
|
381
|
}
|
382
|
|
383
|
private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
|
384
|
{
|
385
|
BorderUpdate();
|
386
|
}
|
387
|
|
388
|
/// <summary>
|
389
|
/// UIElement를 종류에 맞게 등록시킴
|
390
|
/// </summary>
|
391
|
/// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
|
392
|
public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
|
393
|
{
|
394
|
switch (member.GetType().Name)
|
395
|
{
|
396
|
#region 컨트롤 조건
|
397
|
case "LineControl":
|
398
|
case "PolygonControl":
|
399
|
case "ArrowControl":
|
400
|
case "ArcControl":
|
401
|
case "ArrowArcControl":
|
402
|
case "ArrowControl_Multi":
|
403
|
case "RectangleControl":
|
404
|
case "TriControl":
|
405
|
case "CircleControl":
|
406
|
case "CloudControl":
|
407
|
case "RectCloudControl":
|
408
|
case "InkControl":
|
409
|
case "InsideWhiteControl":
|
410
|
case "OverlapWhiteControl":
|
411
|
case "ClipWhiteControl":
|
412
|
case "CoordinateControl":
|
413
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
414
|
break;
|
415
|
case "ArrowTextControl":
|
416
|
this.Members.Add(new AdornerMember
|
417
|
{
|
418
|
DrawingData = member,
|
419
|
Drawingtype = ControlType.ArrowTextControl,
|
420
|
ThumbList = new List<MyThumb>(),
|
421
|
Symbol_ID = member.SymbolID,
|
422
|
Group_ID = member.GroupID,
|
423
|
});
|
424
|
(member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
|
425
|
AngleValue = (member as ArrowTextControl).CommentAngle;
|
426
|
|
427
|
((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
|
428
|
|
429
|
//Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
|
430
|
//{
|
431
|
// TextCompensation = false;
|
432
|
// BorderUpdate();
|
433
|
// if ((a.Sender as TextBox).Text == "") //보류
|
434
|
// {
|
435
|
// this.ContainerContent.Children.Remove(member);
|
436
|
// this.Visibility = Visibility.Collapsed;
|
437
|
// }
|
438
|
//});
|
439
|
break;
|
440
|
case "ImgControl":
|
441
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
442
|
AngleValue = (member as ImgControl).CommentAngle;
|
443
|
break;
|
444
|
case "DateControl":
|
445
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
446
|
AngleValue = (member as DateControl).CommentAngle;
|
447
|
break;
|
448
|
case "SignControl":
|
449
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
450
|
AngleValue = (member as SignControl).CommentAngle;
|
451
|
break;
|
452
|
case "SymControl":
|
453
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
454
|
AngleValue = (member as SymControl).CommentAngle;
|
455
|
break;
|
456
|
case "SymControlN":
|
457
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
458
|
AngleValue = (member as SymControlN).CommentAngle;
|
459
|
break;
|
460
|
case "TextControl":
|
461
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
462
|
RectangleGeometry Data = new RectangleGeometry
|
463
|
{
|
464
|
Rect = new Rect()
|
465
|
{
|
466
|
X = Canvas.GetLeft((member as TextControl)),
|
467
|
Y = Canvas.GetTop((member as TextControl)),
|
468
|
Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
|
469
|
Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
|
470
|
//Width = (member as TextControl).BoxWidth / 2,
|
471
|
//Height = (member as TextControl).BoxHeight / 2,
|
472
|
}
|
473
|
};
|
474
|
Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
|
475
|
Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
|
476
|
|
477
|
|
478
|
DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
|
479
|
DragThumb.RenderTransform = new RotateTransform()
|
480
|
{
|
481
|
Angle = (member as TextControl).CommentAngle,
|
482
|
//CenterX = middle.X,
|
483
|
//CenterY = middle.Y,
|
484
|
};
|
485
|
|
486
|
AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
|
487
|
AdornerBorder.RenderTransform = new RotateTransform()
|
488
|
{
|
489
|
Angle = (member as TextControl).CommentAngle,
|
490
|
//CenterX = middle.X,
|
491
|
//CenterY = middle.Y,
|
492
|
};
|
493
|
//Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
|
494
|
//{
|
495
|
// TextCompensation = true;
|
496
|
// BorderUpdate();
|
497
|
// ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
|
498
|
//});
|
499
|
|
500
|
//Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
|
501
|
//{
|
502
|
// TextCompensation = true;
|
503
|
// BorderUpdate();
|
504
|
// ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
|
505
|
//});
|
506
|
|
507
|
((TextControl)member).PropertyChanged += TextControlPropertyChanged;
|
508
|
((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
|
509
|
|
510
|
//Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
|
511
|
//{
|
512
|
// TextCompensation = false;
|
513
|
// BorderUpdate();
|
514
|
// if ((a.Sender as TextBox).Text == "") //보류
|
515
|
// {
|
516
|
// this.ContainerContent.Children.Remove(member);
|
517
|
// this.Visibility = Visibility.Collapsed;
|
518
|
// }
|
519
|
|
520
|
// //((TextControl)member).UnEditingMode();
|
521
|
// //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
|
522
|
// //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
|
523
|
// //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
|
524
|
//});
|
525
|
break;
|
526
|
default:
|
527
|
break;
|
528
|
#endregion
|
529
|
}
|
530
|
|
531
|
if (member.GetType().Name == "TextControl")
|
532
|
{
|
533
|
TextControl content = ((TextControl)member);
|
534
|
content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
|
535
|
content.EndPoint = content.StartPoint;
|
536
|
}
|
537
|
else
|
538
|
{
|
539
|
RegistryPoint(member);
|
540
|
}
|
541
|
BorderUpdate();
|
542
|
|
543
|
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
|
544
|
}
|
545
|
|
546
|
private void ViewBoxRotate(UIElement member)
|
547
|
{
|
548
|
AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
|
549
|
DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
|
550
|
AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
|
551
|
DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
|
552
|
}
|
553
|
|
554
|
public void SetAdornerMember(List<CommentUserInfo> members)
|
555
|
{
|
556
|
foreach (var member in members)
|
557
|
{
|
558
|
switch (member.GetType().Name)
|
559
|
{
|
560
|
#region 컨트롤 조건
|
561
|
case "LineControl":
|
562
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
563
|
break;
|
564
|
case "ImgControl":
|
565
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
566
|
break;
|
567
|
case "ArrowControl":
|
568
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
569
|
break;
|
570
|
case "PolygonControl":
|
571
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
572
|
break;
|
573
|
case "ArrowTextControl":
|
574
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
575
|
(member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
|
576
|
break;
|
577
|
case "ArcControl":
|
578
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
579
|
break;
|
580
|
case "ArrowArcControl":
|
581
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
582
|
break;
|
583
|
case "DateControl":
|
584
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
585
|
break;
|
586
|
case "ArrowControl_Multi":
|
587
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
588
|
break;
|
589
|
case "RectangleControl":
|
590
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
591
|
break;
|
592
|
case "TriControl":
|
593
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
594
|
break;
|
595
|
case "CircleControl":
|
596
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
597
|
break;
|
598
|
case "CloudControl":
|
599
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
600
|
break;
|
601
|
case "RectCloudControl":
|
602
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
603
|
break;
|
604
|
case "SignControl":
|
605
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
606
|
break;
|
607
|
case "SymControl":
|
608
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
609
|
break;
|
610
|
case "SymControlN":
|
611
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
612
|
break;
|
613
|
case "InkControl":
|
614
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
615
|
break;
|
616
|
case "TextControl":
|
617
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
618
|
|
619
|
(member as TextControl).PropertyChanged += TextControlPropertyChanged;
|
620
|
(member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
|
621
|
|
622
|
//Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
|
623
|
//{
|
624
|
// BorderUpdate();
|
625
|
//});
|
626
|
//Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
|
627
|
//{
|
628
|
// BorderUpdate();
|
629
|
// try
|
630
|
// {
|
631
|
// ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
|
632
|
// }
|
633
|
// catch (Exception)
|
634
|
// {
|
635
|
|
636
|
// }
|
637
|
|
638
|
//});
|
639
|
//Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
|
640
|
//{
|
641
|
// BorderUpdate();
|
642
|
//});
|
643
|
break;
|
644
|
case "InsideWhiteControl":
|
645
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
646
|
break;
|
647
|
case "OverlapWhiteControl":
|
648
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
649
|
break;
|
650
|
case "ClipWhiteControl":
|
651
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
652
|
break;
|
653
|
case "CoordinateControl":
|
654
|
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
|
655
|
break;
|
656
|
default:
|
657
|
break;
|
658
|
#endregion
|
659
|
}
|
660
|
if (member.GetType().Name == "TextControl")
|
661
|
{
|
662
|
TextControl content = ((TextControl)member);
|
663
|
content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
|
664
|
content.EndPoint = content.StartPoint;
|
665
|
}
|
666
|
else
|
667
|
{
|
668
|
RegistryPoint(member, members.Count);
|
669
|
}
|
670
|
|
671
|
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
|
672
|
}
|
673
|
|
674
|
BorderUpdate();
|
675
|
}
|
676
|
|
677
|
|
678
|
/// <summary>
|
679
|
/// Border 를 갱신
|
680
|
/// </summary>
|
681
|
public void BorderUpdate()
|
682
|
{
|
683
|
AdornerBorder.MinWidth = 10;
|
684
|
AdornerBorder.MinHeight = 10;
|
685
|
|
686
|
double minX = double.MaxValue;
|
687
|
double minY = double.MaxValue;
|
688
|
double maxX = double.MinValue;
|
689
|
double maxY = double.MinValue;
|
690
|
|
691
|
if (this.Members.Count == 1)
|
692
|
{
|
693
|
if (this.Members.First().DrawingData.GetType().Name == "TextControl")
|
694
|
{
|
695
|
if ((this.Members.First().DrawingData as TextControl).CommentAngle != 0)
|
696
|
{
|
697
|
trRotate.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
|
698
|
trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
|
699
|
}
|
700
|
else
|
701
|
{
|
702
|
trRotate.Angle = 0;
|
703
|
trRotateThumb.Angle = 0;
|
704
|
}
|
705
|
}
|
706
|
}
|
707
|
foreach (var item in this.Members)
|
708
|
{
|
709
|
UIElement currentControl = (item as AdornerMember).DrawingData;
|
710
|
|
711
|
Point startP = (currentControl as IPath).StartPoint;
|
712
|
Point endP = (currentControl as IPath).EndPoint;
|
713
|
|
714
|
// ViewerDataModel.Instance.Angle = MathSet.returnAngle(startP, ref endP, ViewerDataModel.Instance.IsPressShift);
|
715
|
|
716
|
// 컨트롤의 angle변환시 상단 anglecontrol에 출력
|
717
|
ViewerDataModel.Instance.MarkupAngle = (currentControl as CommentUserInfo).CommentAngle;
|
718
|
|
719
|
if (item.DrawingData.GetType().Name == "TextControl")
|
720
|
{
|
721
|
double textControlWidth;
|
722
|
double textControlHeight;
|
723
|
|
724
|
if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
|
725
|
{
|
726
|
textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
|
727
|
textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
|
728
|
}
|
729
|
else
|
730
|
{
|
731
|
textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
|
732
|
textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
|
733
|
}
|
734
|
|
735
|
if ((currentControl as TextControl).EndPoint.X < minX)
|
736
|
{
|
737
|
minX = (currentControl as TextControl).EndPoint.X;
|
738
|
}
|
739
|
|
740
|
if ((currentControl as TextControl).EndPoint.Y < minY)
|
741
|
{
|
742
|
minY = (currentControl as TextControl).EndPoint.Y;
|
743
|
}
|
744
|
|
745
|
if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
|
746
|
{
|
747
|
maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
|
748
|
}
|
749
|
|
750
|
if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
|
751
|
{
|
752
|
maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
|
753
|
}
|
754
|
}
|
755
|
else if ((currentControl as IViewBox) != null)
|
756
|
{
|
757
|
IViewBox instance = currentControl as IViewBox;
|
758
|
List<Point> am = (currentControl as IPath).PointSet;
|
759
|
List<double> xSet = am.Select(p => p.X).ToList();
|
760
|
List<double> ySet = am.Select(p => p.Y).ToList();
|
761
|
if (xSet.Min() < minX) minX = xSet.Min();
|
762
|
if (ySet.Min() < minY) minY = ySet.Min();
|
763
|
if (xSet.Max() > maxX) maxX = xSet.Max();
|
764
|
if (ySet.Max() > maxY) maxY = ySet.Max();
|
765
|
}
|
766
|
else if ((currentControl as IPath).PathData == null)
|
767
|
{
|
768
|
Rect rt = new Rect
|
769
|
{
|
770
|
X = (currentControl as IPath).StartPoint.X,
|
771
|
Y = (currentControl as IPath).StartPoint.Y,
|
772
|
Width = Math.Max((currentControl as IPath).EndPoint.X, (currentControl as IPath).StartPoint.X) - Math.Min((currentControl as IPath).EndPoint.X, (currentControl as IPath).StartPoint.X),
|
773
|
Height = Math.Max((currentControl as IPath).EndPoint.Y, (currentControl as IPath).StartPoint.Y) - Math.Min((currentControl as IPath).EndPoint.Y, (currentControl as IPath).StartPoint.Y),
|
774
|
};
|
775
|
if (rt.Left < minX) minX = rt.Left;
|
776
|
if (rt.Top < minY) minY = rt.Top;
|
777
|
if (rt.Right > maxX) maxX = rt.Right;
|
778
|
if (rt.Bottom > maxY) maxY = rt.Bottom;
|
779
|
}
|
780
|
else if ((currentControl as IPath) == null)
|
781
|
{
|
782
|
Rect rt = new Rect
|
783
|
{
|
784
|
X = (currentControl as IPath).StartPoint.X,
|
785
|
Y = (currentControl as IPath).StartPoint.Y,
|
786
|
Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
|
787
|
Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
|
788
|
};
|
789
|
if (rt.Left < minX) minX = rt.Left;
|
790
|
if (rt.Top < minY) minY = rt.Top;
|
791
|
if (rt.Right > maxX) maxX = rt.Right;
|
792
|
if (rt.Bottom > maxY) maxY = rt.Bottom;
|
793
|
}
|
794
|
else if ((currentControl as CircleControl) != null)
|
795
|
{
|
796
|
List<Point> am = (currentControl as IPath).PointSet;
|
797
|
List<double> xSet = am.Select(p => p.X).ToList();
|
798
|
List<double> ySet = am.Select(p => p.Y).ToList();
|
799
|
if (xSet.Min() < minX) minX = xSet.Min();
|
800
|
if (ySet.Min() < minY) minY = ySet.Min();
|
801
|
if (xSet.Max() > maxX) maxX = xSet.Max();
|
802
|
if (ySet.Max() > maxY) maxY = ySet.Max();
|
803
|
}
|
804
|
else
|
805
|
{
|
806
|
if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
|
807
|
if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
|
808
|
if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
|
809
|
if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
|
810
|
}
|
811
|
}
|
812
|
|
813
|
Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
|
814
|
bool addWidthSize = false;
|
815
|
bool addHeightSize = false;
|
816
|
if (ac.Width <= 10)
|
817
|
{
|
818
|
ac.Width += 10;
|
819
|
addWidthSize = true;
|
820
|
}
|
821
|
if (ac.Height <= 10)
|
822
|
{
|
823
|
ac.Height += 10;
|
824
|
addHeightSize = true;
|
825
|
}
|
826
|
BorderSize = ac;
|
827
|
AdornerBorder.MinWidth = 10;
|
828
|
AdornerBorder.MinHeight = 10;
|
829
|
AdornerBorder.Width = ac.Width;
|
830
|
AdornerBorder.Height = ac.Height;
|
831
|
Canvas.SetLeft(AdornerBorder, minX);
|
832
|
Canvas.SetTop(AdornerBorder, minY);
|
833
|
|
834
|
DragThumb.Width = ac.Width;
|
835
|
DragThumb.Height = ac.Height;
|
836
|
|
837
|
DragThumb.MinWidth = 10;
|
838
|
DragThumb.MinHeight = 10;
|
839
|
if (addWidthSize)
|
840
|
{
|
841
|
Canvas.SetLeft(DragThumb, minX - 5);
|
842
|
}
|
843
|
else
|
844
|
{
|
845
|
Canvas.SetLeft(DragThumb, minX);
|
846
|
}
|
847
|
|
848
|
if (addHeightSize)
|
849
|
{
|
850
|
Canvas.SetTop(DragThumb, minY - 5);
|
851
|
}
|
852
|
else
|
853
|
{
|
854
|
Canvas.SetTop(DragThumb, minY);
|
855
|
}
|
856
|
}
|
857
|
/// <summary>
|
858
|
/// UIElement 해제
|
859
|
/// </summary>
|
860
|
public void unRegister()
|
861
|
{
|
862
|
foreach (var item in this.ContainerContent.Children)
|
863
|
{
|
864
|
if (item is MarkupToPDF.Common.CommentUserInfo)
|
865
|
{
|
866
|
(item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
|
867
|
}
|
868
|
}
|
869
|
this.ContainerContent.Children.Clear();
|
870
|
}
|
871
|
|
872
|
/// <summary>
|
873
|
/// 각 포인트들을 등록합니다.
|
874
|
/// </summary>
|
875
|
/// <param name="pointset">Drawing Point</param>
|
876
|
public void RegistryPoint(CommentUserInfo member, int cnt = 1)
|
877
|
{
|
878
|
int count = 0;
|
879
|
double Minx = 100000000;
|
880
|
double Miny = 100000000;
|
881
|
List<Point> list = (member as IPath).PointSet;
|
882
|
if (member.GetType().Name == "InkControl")
|
883
|
{
|
884
|
list.Clear();
|
885
|
list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
|
886
|
list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
|
887
|
list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
|
888
|
list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
|
889
|
}
|
890
|
ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
|
891
|
foreach (var ax in list)
|
892
|
{
|
893
|
Minx = (ax.X < Minx) ? ax.X : Minx;
|
894
|
Miny = (ax.Y < Miny) ? ax.Y : Miny;
|
895
|
}
|
896
|
for (int i = 0; i < list.Count(); i++)
|
897
|
{
|
898
|
MyThumb tm = new MyThumb
|
899
|
{
|
900
|
Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
|
901
|
};
|
902
|
|
903
|
this.Members.Last().ThumbList.Add(tm);
|
904
|
|
905
|
if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MiddlePoint))
|
906
|
{
|
907
|
tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
|
908
|
}
|
909
|
if (member.GetType().Name == "ArrowTextControl" && i == 1)
|
910
|
{
|
911
|
//if (this.Members.Count()<=1)
|
912
|
//{
|
913
|
tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
|
914
|
List<Point> ps = new List<Point>();
|
915
|
|
916
|
if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
|
917
|
{
|
918
|
var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
|
919
|
|
920
|
|
921
|
switch (Math.Abs(temp.CommentAngle).ToString())
|
922
|
{
|
923
|
case "90":
|
924
|
{
|
925
|
ps.Clear();
|
926
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
|
927
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
|
928
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
|
929
|
|
930
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간
|
931
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
|
932
|
|
933
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단
|
934
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단
|
935
|
|
936
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
|
937
|
}
|
938
|
break;
|
939
|
case "270":
|
940
|
{
|
941
|
ps.Clear();
|
942
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
|
943
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
|
944
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
|
945
|
|
946
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간
|
947
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
|
948
|
|
949
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단
|
950
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단
|
951
|
|
952
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
|
953
|
}
|
954
|
break;
|
955
|
default:
|
956
|
{
|
957
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
|
958
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
|
959
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
|
960
|
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단
|
961
|
}
|
962
|
break;
|
963
|
}
|
964
|
|
965
|
ArrowTextControl instance = (member as ArrowTextControl);
|
966
|
if (instance.isTrans)
|
967
|
{
|
968
|
//var endP = MathSet.getNearPoint(ps, temp.MidPoint);
|
969
|
//var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
|
970
|
//list[count] = tempP;
|
971
|
list[count] = temp.MidPoint;
|
972
|
}
|
973
|
else
|
974
|
{
|
975
|
if (temp.isFixed)
|
976
|
{
|
977
|
var endP = MathSet.getNearPoint(ps, temp.MidPoint);
|
978
|
var testP = endP;
|
979
|
if (ps[0] == endP) //상단
|
980
|
{
|
981
|
testP = new Point(endP.X, endP.Y - 50);
|
982
|
}
|
983
|
else if (ps[1] == endP) //하단
|
984
|
{
|
985
|
testP = new Point(endP.X, endP.Y + 50);
|
986
|
}
|
987
|
else if (ps[2] == endP) //좌단
|
988
|
{
|
989
|
testP = new Point(endP.X - 50, endP.Y);
|
990
|
}
|
991
|
else if (ps[3] == endP) //우단
|
992
|
{
|
993
|
testP = new Point(endP.X + 50, endP.Y);
|
994
|
}
|
995
|
list[count] = testP;
|
996
|
}
|
997
|
else
|
998
|
{
|
999
|
var endP = MathSet.getNearPoint(ps, instance.MidPoint);
|
1000
|
list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
|
1001
|
}
|
1002
|
}
|
1003
|
}
|
1004
|
}
|
1005
|
|
1006
|
/// ArrowTextControl text box 화면 출력
|
1007
|
if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
|
1008
|
{
|
1009
|
tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
|
1010
|
tm.Width = (member as ArrowTextControl).BoxWidth;
|
1011
|
tm.Height = (member as ArrowTextControl).BoxHeight;
|
1012
|
var angle = (member as ArrowTextControl).PageAngle;
|
1013
|
if (Math.Abs(angle).ToString() == "90")
|
1014
|
{
|
1015
|
tm.RenderTransformOrigin = new Point(0, 0);
|
1016
|
tm.RenderTransform = new RotateTransform { Angle = 270 };
|
1017
|
}
|
1018
|
else if (Math.Abs(angle).ToString() == "270")
|
1019
|
{
|
1020
|
tm.RenderTransformOrigin = new Point(0, 0);
|
1021
|
tm.RenderTransform = new RotateTransform { Angle = 90 };
|
1022
|
}
|
1023
|
else
|
1024
|
{
|
1025
|
tm.RenderTransformOrigin = new Point(0.5, 0.5);
|
1026
|
tm.RenderTransform = new RotateTransform()
|
1027
|
{
|
1028
|
Angle = angle
|
1029
|
};
|
1030
|
}
|
1031
|
}
|
1032
|
|
1033
|
if (member.GetType().Name == "CloudControl")
|
1034
|
{
|
1035
|
if (i == list.Count() - 1)
|
1036
|
{
|
1037
|
tm.Visibility = System.Windows.Visibility.Collapsed;
|
1038
|
}
|
1039
|
}
|
1040
|
if (member.GetType().Name == "PolygonControl")
|
1041
|
{
|
1042
|
if (i == list.Count() - 1)
|
1043
|
{
|
1044
|
if ((member as PolygonControl).ControlType == ControlType.ChainLine)
|
1045
|
{
|
1046
|
|
1047
|
}
|
1048
|
else
|
1049
|
{
|
1050
|
tm.Visibility = System.Windows.Visibility.Collapsed;
|
1051
|
}
|
1052
|
}
|
1053
|
if ((member as PolygonControl).ControlType == ControlType.Ink)
|
1054
|
{
|
1055
|
tm.Visibility = System.Windows.Visibility.Collapsed;
|
1056
|
}
|
1057
|
}
|
1058
|
|
1059
|
this.ContainerContent.Children.Add(tm);
|
1060
|
Canvas.SetLeft(tm, list[count].X);
|
1061
|
Canvas.SetTop(tm, list[count].Y);
|
1062
|
if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
|
1063
|
{
|
1064
|
Canvas.SetZIndex(tm, 95);
|
1065
|
//tm.Opacity = 0;
|
1066
|
tm.DragDelta += MidPoint_DragDelta;
|
1067
|
}
|
1068
|
else
|
1069
|
{
|
1070
|
tm.DragDelta += ResizeTm_DragDelta;
|
1071
|
Canvas.SetZIndex(tm, 99);
|
1072
|
}
|
1073
|
|
1074
|
tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
|
1075
|
tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
|
1076
|
|
1077
|
tm.MouseMove += new MouseEventHandler(resize_MouseMove);
|
1078
|
count++;
|
1079
|
}
|
1080
|
}
|
1081
|
|
1082
|
private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
|
1083
|
{
|
1084
|
MyThumb thumb = sender as MyThumb;
|
1085
|
double newHorizontalChange = e.HorizontalChange;
|
1086
|
double newVerticalChange = e.VerticalChange;
|
1087
|
|
1088
|
var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), 0);// commentInfo.VisualPageAngle);
|
1089
|
|
1090
|
var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
|
1091
|
|
1092
|
System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
|
1093
|
|
1094
|
AdornerMember control = CurrentAdornerMember(thumb);
|
1095
|
var commentInfo = (control.DrawingData) as CommentUserInfo;
|
1096
|
|
1097
|
if (commentInfo is ArrowTextControl)
|
1098
|
{
|
1099
|
Point getThumbPoint = GetPosition(thumb);
|
1100
|
|
1101
|
var arrowText = commentInfo as ArrowTextControl;
|
1102
|
|
1103
|
//var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
|
1104
|
//arrowText.MidPoint = newpoint;
|
1105
|
thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
|
1106
|
|
1107
|
commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
|
1108
|
|
1109
|
control.UpdateThumb();
|
1110
|
|
1111
|
System.Diagnostics.Debug.WriteLine($"text {Canvas.GetLeft(arrowText.Base_TextBox)},{Canvas.GetTop(arrowText.Base_TextBox)}");
|
1112
|
|
1113
|
System.Diagnostics.Debug.WriteLine($"Page Angle : {ViewerDataModel.Instance.PageAngle} GetPoint : {getThumbPoint.X},{getThumbPoint.Y} Change Value : {newpoint.X},{newpoint.Y}");
|
1114
|
}
|
1115
|
|
1116
|
}
|
1117
|
|
1118
|
|
1119
|
private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
|
1120
|
{
|
1121
|
if (sender.GetType() != typeof(MyThumb)) return;
|
1122
|
|
1123
|
MyThumb thumb = sender as MyThumb;
|
1124
|
|
1125
|
if (this.Members.Count > 1) return;
|
1126
|
|
1127
|
System.Diagnostics.Debug.WriteLine($"Value {e.HorizontalChange},{e.VerticalChange}");
|
1128
|
|
1129
|
double newHorizontalChange = e.HorizontalChange;
|
1130
|
double newVerticalChange = e.VerticalChange;
|
1131
|
|
1132
|
//if (reSizePoint != new Point(0, 0))
|
1133
|
//{
|
1134
|
//Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
|
1135
|
|
1136
|
Point setPoint = GetPosition(thumb);
|
1137
|
|
1138
|
//System.Diagnostics.Debug.WriteLine($"1. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y} Change Value : {newHorizontalChange},{newVerticalChange}");
|
1139
|
|
1140
|
AdornerMember control = CurrentAdornerMember(thumb);
|
1141
|
var commentInfo = (control.DrawingData) as CommentUserInfo;
|
1142
|
|
1143
|
double ratatePointAngle = 0;
|
1144
|
|
1145
|
if (commentInfo is ArrowTextControl)
|
1146
|
{
|
1147
|
var textControl = (commentInfo as ArrowTextControl);
|
1148
|
|
1149
|
if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
|
1150
|
|
1151
|
{
|
1152
|
textControl.CommentAngle = 0;
|
1153
|
this.AngleValue = 0;
|
1154
|
ratatePointAngle = commentInfo.VisualPageAngle;
|
1155
|
}
|
1156
|
else
|
1157
|
{
|
1158
|
//textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
|
1159
|
textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
|
1160
|
this.AngleValue = textControl.CommentAngle;
|
1161
|
commentInfo.CommentAngle = this.AngleValue;
|
1162
|
}
|
1163
|
//CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
|
1164
|
}
|
1165
|
System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
|
1166
|
thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
|
1167
|
|
1168
|
// 페이지회전에 따른 화살표텍스트 박스의 이동 수정
|
1169
|
var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
|
1170
|
|
1171
|
Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
|
1172
|
|
1173
|
//thumbPoint.X = Math.Abs(thumbPoint.X);
|
1174
|
//thumbPoint.Y = Math.Abs(thumbPoint.Y);
|
1175
|
|
1176
|
//if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
|
1177
|
//{
|
1178
|
// newpoint.X = 0;
|
1179
|
//}
|
1180
|
|
1181
|
//if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
|
1182
|
//{
|
1183
|
// newpoint.Y = 0;
|
1184
|
//}
|
1185
|
|
1186
|
commentInfo.OnMoveCtrlPoint(setPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
|
1187
|
|
1188
|
//System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
|
1189
|
control.UpdateThumb();
|
1190
|
|
1191
|
//System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
|
1192
|
this.BorderUpdate();
|
1193
|
|
1194
|
//System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
|
1195
|
//}
|
1196
|
}
|
1197
|
|
1198
|
private AdornerMember CurrentAdornerMember(MyThumb thumb)
|
1199
|
{
|
1200
|
AdornerMember result = null;
|
1201
|
|
1202
|
try
|
1203
|
{
|
1204
|
result = (from userThumb in this.Members
|
1205
|
where userThumb.ThumbList.Contains(thumb)
|
1206
|
select userThumb).FirstOrDefault();
|
1207
|
}
|
1208
|
catch (Exception ex)
|
1209
|
{
|
1210
|
App.FileLogger.Error(ex);
|
1211
|
}
|
1212
|
|
1213
|
return result;
|
1214
|
}
|
1215
|
|
1216
|
private Point GetPosition(Thumb thumb)
|
1217
|
{
|
1218
|
return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
|
1219
|
}
|
1220
|
|
1221
|
#endregion
|
1222
|
#region 이벤트
|
1223
|
|
1224
|
void tm_DragCompleted(object sender, DragCompletedEventArgs e)
|
1225
|
{
|
1226
|
this.isDragging = false;
|
1227
|
DraggerThumb = null;
|
1228
|
|
1229
|
var comments = (from drawing in this.Members
|
1230
|
select drawing.DrawingData as CommentUserInfo).ToList();
|
1231
|
UndoCommand.Instance.Push(comments, this.AngleValue);
|
1232
|
}
|
1233
|
|
1234
|
/// <summary>
|
1235
|
/// start drag
|
1236
|
/// </summary>
|
1237
|
/// <param name="sender"></param>
|
1238
|
/// <param name="e"></param>
|
1239
|
void tm_DragStarted(object sender, DragStartedEventArgs e)
|
1240
|
{
|
1241
|
this.DraggerThumb = sender as Thumb;
|
1242
|
this.isDragging = true;
|
1243
|
|
1244
|
if (ViewerDataModel.Instance.UndoDataList == null)
|
1245
|
{
|
1246
|
return;
|
1247
|
}
|
1248
|
|
1249
|
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
|
1250
|
{
|
1251
|
return;
|
1252
|
}
|
1253
|
|
1254
|
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
|
1255
|
{
|
1256
|
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
|
1257
|
{
|
1258
|
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
|
1259
|
{
|
1260
|
return;
|
1261
|
}
|
1262
|
}
|
1263
|
}
|
1264
|
|
1265
|
var comments = (from drawing in this.Members
|
1266
|
select drawing.DrawingData as CommentUserInfo).ToList();
|
1267
|
UndoCommand.Instance.Push(comments, this.AngleValue);
|
1268
|
}
|
1269
|
|
1270
|
private void rotate_MouseMove(object sender, MouseEventArgs e)
|
1271
|
{
|
1272
|
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
|
1273
|
{
|
1274
|
if (LastRotateVerticalValue < e.GetPosition(this).X)
|
1275
|
IsTextAngle = true;
|
1276
|
else
|
1277
|
IsTextAngle = false;
|
1278
|
LastRotateVerticalValue = e.GetPosition(this).X;
|
1279
|
}
|
1280
|
else
|
1281
|
{
|
1282
|
if (e.GetPosition(this).X > LastRotateHorizontalValue)
|
1283
|
{
|
1284
|
RotateFlag = true;
|
1285
|
}
|
1286
|
else
|
1287
|
{
|
1288
|
RotateFlag = false;
|
1289
|
}
|
1290
|
LastRotateHorizontalValue = e.GetPosition(this).X;
|
1291
|
}
|
1292
|
}
|
1293
|
|
1294
|
private void drag_DragStarted(object sender, DragStartedEventArgs e)
|
1295
|
{
|
1296
|
/// save mouse down and current mouse point
|
1297
|
this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
|
1298
|
this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
|
1299
|
/// up to here
|
1300
|
|
1301
|
if (ViewerDataModel.Instance.UndoDataList == null)
|
1302
|
{
|
1303
|
return;
|
1304
|
}
|
1305
|
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
|
1306
|
{
|
1307
|
return;
|
1308
|
}
|
1309
|
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
|
1310
|
{
|
1311
|
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
|
1312
|
{
|
1313
|
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
|
1314
|
{
|
1315
|
return;
|
1316
|
}
|
1317
|
}
|
1318
|
}
|
1319
|
|
1320
|
var comments = (from drawing in this.Members
|
1321
|
select drawing.DrawingData as CommentUserInfo).ToList();
|
1322
|
UndoCommand.Instance.Push(comments, this.AngleValue);
|
1323
|
}
|
1324
|
|
1325
|
private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
|
1326
|
{
|
1327
|
DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
|
1328
|
|
1329
|
var comments = (from drawing in this.Members
|
1330
|
select drawing.DrawingData as CommentUserInfo).ToList();
|
1331
|
UndoCommand.Instance.Push(comments, this.AngleValue);
|
1332
|
}
|
1333
|
|
1334
|
private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
|
1335
|
{
|
1336
|
double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
|
1337
|
|
1338
|
var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
|
1339
|
|
1340
|
var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
|
1341
|
var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
|
1342
|
|
1343
|
try
|
1344
|
{
|
1345
|
DragThumb.Cursor = Cursors.SizeAll;
|
1346
|
System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
|
1347
|
System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
|
1348
|
|
1349
|
|
1350
|
var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
|
1351
|
|
1352
|
//if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
|
1353
|
//{
|
1354
|
// mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
|
1355
|
//}
|
1356
|
|
1357
|
mainRect = MathHelper.RotateRect(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect(), new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
|
1358
|
|
1359
|
var rect = (this.ContainerContent.FindChildByType<CommentUserInfo>() as CommentUserInfo).ItemRect; //this.AdornerBorder.Bounds(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel);
|
1360
|
|
1361
|
var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
|
1362
|
|
1363
|
var moveDirection = mainRect.Movement(rotationRect);
|
1364
|
|
1365
|
System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}");
|
1366
|
//System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : Top:{rect.Top}, Left:{rect.Left}, Right:{rect.Right}, Bottom:{rect.Bottom} ,BottomLeft : {rect.BottomLeft} BottomRight : {rect.BottomRight}");
|
1367
|
|
1368
|
//if (Math.Abs(horzChange) > 0)
|
1369
|
//{
|
1370
|
// if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right))
|
1371
|
// {
|
1372
|
// //this.TranslateItems(horzChange * -1, 0);
|
1373
|
// //e.Handled = true;
|
1374
|
// horzChange = 0;
|
1375
|
// newMousePoint.X = this.CurrentMousePoint.X;
|
1376
|
// }
|
1377
|
//}
|
1378
|
|
1379
|
//if (Math.Abs(vertChange) > 0)
|
1380
|
//{
|
1381
|
// if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
|
1382
|
// {
|
1383
|
// //this.TranslateItems(0, vertChange * -1);
|
1384
|
// //e.Handled = true;
|
1385
|
// vertChange = 0;
|
1386
|
// newMousePoint.Y = this.CurrentMousePoint.Y;
|
1387
|
// }
|
1388
|
//}
|
1389
|
|
1390
|
this.TranslateItems(horzChange, vertChange);
|
1391
|
}
|
1392
|
finally
|
1393
|
{
|
1394
|
/// update CurrentMousePoint
|
1395
|
this.CurrentMousePoint = newMousePoint;
|
1396
|
}
|
1397
|
}
|
1398
|
|
1399
|
/// <summary>
|
1400
|
/// translate all members
|
1401
|
/// </summary>
|
1402
|
/// <param name="e"></param>
|
1403
|
public void TranslateItems(double dx, double dy)
|
1404
|
{
|
1405
|
Dispatcher.BeginInvoke((Action)(() =>
|
1406
|
{
|
1407
|
foreach (var item in this.Members)
|
1408
|
{
|
1409
|
this.TranslateItem(dx, dy, item);
|
1410
|
}
|
1411
|
|
1412
|
this.BorderUpdate();
|
1413
|
}));
|
1414
|
}
|
1415
|
|
1416
|
/// <summary>
|
1417
|
/// translate a item
|
1418
|
/// </summary>
|
1419
|
/// <param name="e"></param>
|
1420
|
/// <param name="item"></param>
|
1421
|
private void TranslateItem(double dx, double dy, AdornerMember item)
|
1422
|
{
|
1423
|
/// rotate point with page rotation
|
1424
|
var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
|
1425
|
Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
|
1426
|
/// up to here
|
1427
|
(item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
|
1428
|
|
1429
|
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
|
1430
|
MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);
|
1431
|
|
1432
|
item.UpdateThumb();
|
1433
|
}
|
1434
|
|
1435
|
private void resize_MouseMove(object sender, MouseEventArgs e)
|
1436
|
{
|
1437
|
//reSizePoint = e.GetPosition(this);
|
1438
|
}
|
1439
|
|
1440
|
/// <summary>
|
1441
|
/// 회전
|
1442
|
/// </summary>
|
1443
|
/// <param name="sender"></param>
|
1444
|
/// <param name="e"></param>
|
1445
|
public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
|
1446
|
{
|
1447
|
MoveRotate(e);
|
1448
|
}
|
1449
|
|
1450
|
double LastRotateHorizontalValue = 0;
|
1451
|
double LastRotateVerticalValue = 0;
|
1452
|
bool RotateFlag = false;
|
1453
|
|
1454
|
/// <summary>
|
1455
|
/// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
|
1456
|
/// </summary>
|
1457
|
/// <param name="e"></param>
|
1458
|
public void MoveRotate(DragDeltaEventArgs e)
|
1459
|
{
|
1460
|
Point CenterPoint = this.Centeroid;
|
1461
|
Point pt = Mouse.GetPosition(this);
|
1462
|
|
1463
|
Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
|
1464
|
Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
|
1465
|
double dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
|
1466
|
|
1467
|
AngleValue += dDeltaAngle;
|
1468
|
if (AngleValue > 360) AngleValue -= 360;
|
1469
|
if (AngleValue < 0) AngleValue += 360;
|
1470
|
this.rotatePoint = pt; /// save rotatePoint
|
1471
|
|
1472
|
Dispatcher.BeginInvoke((Action)(() =>
|
1473
|
{
|
1474
|
foreach (var member in this.Members)
|
1475
|
{
|
1476
|
member.RotateAbout(CenterPoint, dDeltaAngle);
|
1477
|
#region 보더 업데이트
|
1478
|
switch (member.Drawingtype)
|
1479
|
{
|
1480
|
case ControlType.TextControl:
|
1481
|
(member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
|
1482
|
|
1483
|
DragThumb.RenderTransformOrigin = new Point(0, 0);
|
1484
|
DragThumb.RenderTransform = new RotateTransform()
|
1485
|
{
|
1486
|
|
1487
|
Angle = (member.DrawingData as CommentUserInfo).CommentAngle
|
1488
|
};
|
1489
|
|
1490
|
AdornerBorder.RenderTransformOrigin = new Point(0, 0);
|
1491
|
AdornerBorder.RenderTransform = new RotateTransform()
|
1492
|
{
|
1493
|
Angle = (member.DrawingData as CommentUserInfo).CommentAngle
|
1494
|
};
|
1495
|
|
1496
|
//(member.DrawingData as TextControl).Angle = AngleValue;
|
1497
|
|
1498
|
(member.DrawingData as CommentUserInfo).UpdateControl();
|
1499
|
BorderUpdate();
|
1500
|
break;
|
1501
|
|
1502
|
case ControlType.ArrowMultiLine:
|
1503
|
case ControlType.ArcLine:
|
1504
|
case ControlType.ArcArrow:
|
1505
|
case ControlType.SingleLine:
|
1506
|
case ControlType.Triangle:
|
1507
|
case ControlType.ArrowTextControl:
|
1508
|
case ControlType.PolygonControl:
|
1509
|
case ControlType.Ink:
|
1510
|
BorderUpdate();
|
1511
|
break;
|
1512
|
case ControlType.Date:
|
1513
|
case ControlType.RectCloud:
|
1514
|
case ControlType.Rectangle:
|
1515
|
case ControlType.ImgControl:
|
1516
|
case ControlType.Sign:
|
1517
|
case ControlType.Symbol:
|
1518
|
case ControlType.Stamp:
|
1519
|
(member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
|
1520
|
BorderUpdate();
|
1521
|
break;
|
1522
|
case ControlType.PolygonCloud:
|
1523
|
((ICloudControl)member.DrawingData).DrawingCloud();
|
1524
|
BorderUpdate();
|
1525
|
break;
|
1526
|
case ControlType.Circle:
|
1527
|
(member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
|
1528
|
((CircleControl)member.DrawingData).SetCenterXY();
|
1529
|
BorderUpdate();
|
1530
|
break;
|
1531
|
default:
|
1532
|
break;
|
1533
|
}
|
1534
|
}
|
1535
|
#endregion
|
1536
|
}));
|
1537
|
}
|
1538
|
|
1539
|
private void rotate_DragStarted(object sender, DragStartedEventArgs e)
|
1540
|
{
|
1541
|
this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
|
1542
|
rotateTop.Cursor = Cursors.SizeAll;
|
1543
|
|
1544
|
/// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
|
1545
|
if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
|
1546
|
{
|
1547
|
this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).CommentAngle;
|
1548
|
}
|
1549
|
/// up to here
|
1550
|
|
1551
|
if (ViewerDataModel.Instance.UndoDataList == null)
|
1552
|
{
|
1553
|
return;
|
1554
|
}
|
1555
|
|
1556
|
if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
|
1557
|
{
|
1558
|
return;
|
1559
|
}
|
1560
|
|
1561
|
if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
|
1562
|
{
|
1563
|
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
|
1564
|
{
|
1565
|
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
|
1566
|
{
|
1567
|
return;
|
1568
|
}
|
1569
|
}
|
1570
|
}
|
1571
|
|
1572
|
var comments = (from drawing in this.Members
|
1573
|
select drawing.DrawingData as CommentUserInfo).ToList();
|
1574
|
UndoCommand.Instance.Push(comments, this.AngleValue);
|
1575
|
}
|
1576
|
|
1577
|
private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
|
1578
|
{
|
1579
|
rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
|
1580
|
|
1581
|
var comments = (from drawing in this.Members
|
1582
|
select drawing.DrawingData as CommentUserInfo).ToList();
|
1583
|
UndoCommand.Instance.Push(comments, this.AngleValue);
|
1584
|
}
|
1585
|
|
1586
|
public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
1587
|
{
|
1588
|
AdornerMember control = this.Members.FirstOrDefault();
|
1589
|
|
1590
|
if ((control.DrawingData as ArrowTextControl) != null)
|
1591
|
{
|
1592
|
if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
|
1593
|
{
|
1594
|
(control.DrawingData as ArrowTextControl).isTrans = true;
|
1595
|
}
|
1596
|
}
|
1597
|
|
1598
|
}
|
1599
|
|
1600
|
public void TextControlChanger()
|
1601
|
{
|
1602
|
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
|
1603
|
{
|
1604
|
TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
|
1605
|
AllControl.Base_TextBox.Focus();
|
1606
|
AllControl.Base_TextBox.Visibility = Visibility.Visible;
|
1607
|
AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
|
1608
|
AllControl.Base_TextBox.IsHitTestVisible = true;
|
1609
|
AllControl.Base_TextBox.Focus();
|
1610
|
|
1611
|
AllControl.SizeChanged += (sen, ea) =>
|
1612
|
{
|
1613
|
if (AllControl.Base_TextBox != null)
|
1614
|
{
|
1615
|
RectangleGeometry Data = new RectangleGeometry
|
1616
|
{
|
1617
|
Rect = new Rect()
|
1618
|
{
|
1619
|
X = AllControl.StartPoint.X,
|
1620
|
Y = AllControl.StartPoint.Y,
|
1621
|
Width = AllControl.Base_TextBox.Width,
|
1622
|
Height = AllControl.Base_TextBox.Height,
|
1623
|
}
|
1624
|
};
|
1625
|
|
1626
|
Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
|
1627
|
Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
|
1628
|
AllControl.Base_Grid.RenderTransform = new RotateTransform()
|
1629
|
{
|
1630
|
Angle = AllControl.CommentAngle,
|
1631
|
CenterX = middle.X,
|
1632
|
CenterY = middle.Y,
|
1633
|
};
|
1634
|
}
|
1635
|
BorderUpdate();
|
1636
|
};
|
1637
|
}
|
1638
|
}
|
1639
|
|
1640
|
private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
|
1641
|
{
|
1642
|
if (e.ClickCount == 2 && this.Members.Count == 1)
|
1643
|
{
|
1644
|
|
1645
|
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
|
1646
|
{
|
1647
|
TextControlChanger();
|
1648
|
}
|
1649
|
|
1650
|
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
|
1651
|
{
|
1652
|
ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
|
1653
|
Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
|
1654
|
((ArrowTextControl)AllControl).Base_TextBox.Focus();
|
1655
|
|
1656
|
//ArrowControl TextBox Thumb없애기
|
1657
|
tm.Visibility = Visibility.Collapsed;
|
1658
|
|
1659
|
((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
|
1660
|
|
1661
|
((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
|
1662
|
|
1663
|
{
|
1664
|
tm.Width = (AllControl as ArrowTextControl).BoxWidth;
|
1665
|
tm.Height = (AllControl as ArrowTextControl).BoxHeight;
|
1666
|
|
1667
|
List<Point> ps = new List<Point>();
|
1668
|
|
1669
|
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
|
1670
|
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
|
1671
|
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
|
1672
|
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //우단
|
1673
|
|
1674
|
|
1675
|
|
1676
|
|
1677
|
var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
|
1678
|
var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
|
1679
|
if (AllControl.isTrans)
|
1680
|
{
|
1681
|
Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
|
1682
|
Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
|
1683
|
}
|
1684
|
else
|
1685
|
{
|
1686
|
Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
|
1687
|
Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
|
1688
|
}
|
1689
|
|
1690
|
|
1691
|
BorderUpdate();
|
1692
|
|
1693
|
};
|
1694
|
}
|
1695
|
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
|
1696
|
{
|
1697
|
DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
|
1698
|
CalendarControl instanceCal = new CalendarControl(data.Text);
|
1699
|
//dropData.IsOpen = true;
|
1700
|
RadWindow rc = new RadWindow();
|
1701
|
rc.Width = 300;
|
1702
|
rc.Height = 300;
|
1703
|
rc.Header = "Change Date";
|
1704
|
rc.Content = instanceCal;
|
1705
|
rc.BorderThickness = new Thickness(3);
|
1706
|
rc.ResizeMode = ResizeMode.NoResize;
|
1707
|
rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
1708
|
rc.ModalBackground = new SolidColorBrush(Colors.Black);
|
1709
|
rc.ModalBackground.Opacity = 0.6;
|
1710
|
Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
|
1711
|
instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
|
1712
|
{
|
1713
|
data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
|
1714
|
rc.Close();
|
1715
|
};
|
1716
|
rc.ShowDialog();
|
1717
|
//CalendarControl.xaml
|
1718
|
}
|
1719
|
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
|
1720
|
{
|
1721
|
ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
|
1722
|
if (instance.isTransOn)
|
1723
|
{
|
1724
|
instance.isTransOn = false;
|
1725
|
}
|
1726
|
else
|
1727
|
{
|
1728
|
instance.isTransOn = true;
|
1729
|
}
|
1730
|
///instance.SetArcPath();
|
1731
|
BorderUpdate();
|
1732
|
}
|
1733
|
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
|
1734
|
{
|
1735
|
ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
|
1736
|
if (instance.isTransOn)
|
1737
|
{
|
1738
|
instance.isTransOn = false;
|
1739
|
}
|
1740
|
else
|
1741
|
{
|
1742
|
instance.isTransOn = true;
|
1743
|
}
|
1744
|
instance.SetArcPath();
|
1745
|
BorderUpdate();
|
1746
|
}
|
1747
|
|
1748
|
}
|
1749
|
|
1750
|
}
|
1751
|
#endregion
|
1752
|
|
1753
|
private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
1754
|
{
|
1755
|
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
|
1756
|
{
|
1757
|
DragThumb.Visibility = Visibility.Collapsed;
|
1758
|
}
|
1759
|
}
|
1760
|
|
1761
|
}
|
1762
|
}
|