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