프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / MarkupToPDF_Old / Controls / Event / Move.cs @ 5538eb5a

이력 | 보기 | 이력해설 | 다운로드 (26.5 KB)

1
#region using문
2
using System;
3
using System.Windows;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.Text;
7
using System.Windows.Media;
8
using System.Windows.Controls;
9
using System.Threading.Tasks;
10
using MarkupToPDF.Controls.Common;
11
using MarkupToPDF.Controls.Line;
12
using MarkupToPDF.Controls.Polygon;
13
using MarkupToPDF.Controls.Shape;
14
using MarkupToPDF.Controls.Text;
15
using MarkupToPDF.Controls.Etc;
16
#endregion
17

    
18
namespace MarkupToPDF.Controls.Event
19
{
20
    public class Move
21
    {
22
        #region 변수 선언
23
        public SelectControl selectcontrol;
24
        private Dictionary<object, Point> Dic;
25
        RectangleControl rectanglecontrol;
26
        CircleControl circlecontrol;
27
        TriControl tricontrol;
28
        RectCloudControl rectCloudcontrol;
29
        LineControl linecontrol;
30
        ArcControl arccontrol;
31
        TextControl textcontrol;
32
        IMarkupCommonData CommonData;
33
        Vector rectSize;
34
        Rect itemRect;
35
        Point s_point;
36
        Point e_point;
37
        Rect DragRect;
38
        Dictionary<Geometry, string> selected_item;
39
        #endregion
40

    
41
        Point[] StartPoint
42
        {
43
            get;
44
            set;
45
        }
46

    
47
        Point[] MidPoint
48
        {
49
            get;
50
            set;
51
        }
52

    
53
        Point[] EndPoint
54
        {
55
            get;
56
            set;
57
        }
58

    
59
        public Control CurrentControl
60
        {
61
            get;
62
            set;
63
        }
64

    
65
        public MouseMode mousemode
66
        {
67
            get;
68
            set;
69
        }
70

    
71

    
72
        #region 아이템 선택
73
        public Dictionary<Geometry, string> control_Select(object Control, IMarkupCommonData commonData, Rect dragrect)
74
        {
75
            CommonData = commonData;
76
            DragRect = dragrect;
77

    
78
            ItemRect(Control);
79

    
80
            switch (commonData.ControlType)
81
            {
82
                #region Shape
83
                case (ControlType.Rectangle):
84
                    {
85
                        IsSelectionControl((Control as RectangleControl).OverViewPathData);
86
                        return selected_item;
87
                    }
88
                case (ControlType.Circle):
89
                    {
90
                        IsSelectionControl((Control as CircleControl).OverViewPathData);
91
                        return selected_item;
92
                    }
93
                case (ControlType.RectCloud):
94
                    {
95
                        IsSelectionControl((Control as RectCloudControl).OverViewPathData);
96
                        return selected_item;
97
                    }
98
                case (ControlType.Triangle):
99
                    {
100
                        IsSelectionControl((Control as TriControl).OverViewPathData);
101
                        return selected_item;
102
                    }
103
                #endregion
104
                #region Line
105
                case (ControlType.SingleLine):
106
                    {
107
                        IsSelectionControl((Control as LineControl).OverViewPathData);
108
                        return selected_item;
109
                    }
110
                case (ControlType.ArrowLine):
111
                    {
112
                        IsSelectionControl((Control as LineControl).OverViewPathData);
113
                        return selected_item;
114
                    }
115
                case (ControlType.ArrowMultiLine):
116
                    {
117
                        IsSelectionControl((Control as ArrowControl_Multi).OverViewPathData);
118
                        return selected_item;
119
                    }
120
                case (ControlType.CancelLine):
121
                    {
122
                        IsSelectionControl((Control as LineControl).OverViewPathData);
123
                        return selected_item;
124
                    }
125
                case (ControlType.ChainLine):
126
                    {
127
                        IsSelectionControl((Control as LineControl).OverViewPathData);
128
                        return selected_item;
129
                    }
130
                case (ControlType.DimLine):
131
                    {
132
                        IsSelectionControl((Control as LineControl).OverViewPathData);
133
                        return selected_item;
134
                    }
135
                case (ControlType.TwinLine):
136
                    {
137
                        IsSelectionControl((Control as LineControl).OverViewPathData);
138
                        return selected_item;
139
                    }
140
                case (ControlType.ArcLine):
141
                    {
142
                        IsSelectionControl((Control as ArcControl).OverViewPathData);
143
                        return selected_item;
144
                    }
145
                case (ControlType.ArcArrow):
146
                    {
147
                        IsSelectionControl((Control as ArcControl).OverViewPathData);
148
                        return selected_item;
149
                    }
150
                #endregion
151
                case (ControlType.TextControl):
152
                    {
153
                        //IsSelectionControl((Control as TextControl).OverViewPathData);
154
                        IsSelectionControl((Control as TextControl).OverViewPathData);
155
                        return selected_item;
156
                    }
157
            }
158
            return selected_item;
159
        }
160
        #endregion
161

    
162
        #region 선택된 아이템 클릭
163
        public ControlType control_Move_R(List<object> ControlList, Point m_point)
164
        {
165
            if (ControlList == null)
166
            {
167
                ControlList = new List<object>();
168
                Dic = new Dictionary<object, Point>();
169
            }
170
            foreach (object content in ControlList)
171
            {
172
                if ((content as IMarkupCommonData).IsSelected == true)
173
                {
174
                    ItemRect(content);
175
                    mousemode = MouseMode.Drawing;
176
                    if (itemRect.Contains(m_point))
177
                    {
178
                        switch ((content as IMarkupCommonData).ControlType)
179
                        {
180
                            #region Shape
181
                            case (ControlType.Rectangle):
182
                                {CurrentControl = content as RectangleControl;}
183
                                break;
184
                            case (ControlType.Circle):
185
                                {CurrentControl = content as CircleControl;}
186
                                break;
187
                            case (ControlType.RectCloud):
188
                                {CurrentControl = content as RectCloudControl;}
189
                                break;
190
                            case (ControlType.Triangle):
191
                                {CurrentControl = content as TriControl;}
192
                                break;
193
                            #endregion
194
                            #region Line
195
                            case (ControlType.SingleLine):
196
                                { CurrentControl = content as LineControl; }
197
                                break;
198
                            case (ControlType.ArrowLine):
199
                                { CurrentControl = content as LineControl; }
200
                                break;
201
                            case (ControlType.ArrowMultiLine):
202
                                { CurrentControl = content as ArrowControl_Multi; }
203
                                break;
204
                            case (ControlType.CancelLine):
205
                                { CurrentControl = content as LineControl; }
206
                                break;
207
                            case (ControlType.DimLine):
208
                                { CurrentControl = content as LineControl; }
209
                                break;
210
                            case (ControlType.TwinLine):
211
                                { CurrentControl = content as LineControl; }
212
                                break;
213
                            case (ControlType.ChainLine):
214
                                { CurrentControl = content as PolygonControl; }
215
                                break;
216
                            case (ControlType.ArcLine):
217
                                { CurrentControl = content as ArcControl; }
218
                                break;
219
                            case (ControlType.ArcArrow):
220
                                {
221
                                    CurrentControl = content as ArcControl;
222
                                    (content as ArcControl).isTransOn = true;
223
                                }
224
                                break;
225
                            #endregion
226
                            case (ControlType.TextControl):
227
                                { CurrentControl = content as TextControl; }
228
                                break;
229
                        }
230
                        return (content as IMarkupCommonData).ControlType;
231
                    }
232
                }
233
            }
234
            return ControlType.None;
235
        }
236
        #endregion
237

    
238
        #region 선택된 아이템 이동
239
        public void control_Move(List<object> ControlList, bool Flag, double p_x, double p_y)
240
        {
241
            if (ControlList == null)
242
            {
243
                ControlList = new List<object>();
244
                Dic = new Dictionary<object, Point>();
245
            }
246

    
247
            int cnt = 0;
248

    
249
            if (StartPoint == null)
250
            {
251
                StartPoint = new Point[ControlList.Count];
252
                MidPoint = new Point[ControlList.Count];
253
                EndPoint = new Point[ControlList.Count];
254
            }
255

    
256
            foreach (var control in ControlList)
257
            {
258
                if ((control as IMarkupCommonData).IsSelected == true)
259
                {
260
                    switch (control.GetType().Name)
261
                    {
262
                        #region Shape
263
                        case "RectangleControl":
264
                            {
265
                                rectanglecontrol = control as RectangleControl;
266

    
267
                                if (StartPoint[cnt] == new Point())
268
                                {
269
                                    StartPoint[cnt] = rectanglecontrol.StartPoint;
270
                                    EndPoint[cnt] = rectanglecontrol.EndPoint;
271
                                }
272
                                rectanglecontrol.StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
273
                                rectanglecontrol.LeftBottomPoint = new Point(StartPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
274
                                rectanglecontrol.TopRightPoint = new Point(EndPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
275
                                rectanglecontrol.EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
276
                            }
277
                            break;
278
                        case "CircleControl":
279
                            {
280
                                circlecontrol = control as CircleControl;
281

    
282
                                if (StartPoint[cnt] == new Point())
283
                                {
284
                                    StartPoint[cnt] = circlecontrol.StartPoint;
285
                                    EndPoint[cnt] = circlecontrol.EndPoint;
286
                                }
287
                                circlecontrol.StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
288
                                circlecontrol.LeftBottomPoint = new Point(StartPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
289
                                circlecontrol.TopRightPoint = new Point(EndPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
290
                                circlecontrol.EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
291
                            }
292
                            break;
293
                        case "RectCloudControl":
294
                            {
295
                                rectCloudcontrol = control as RectCloudControl;
296

    
297
                                if (StartPoint[cnt] == new Point())
298
                                {
299
                                    StartPoint[cnt] = rectCloudcontrol.StartPoint;
300
                                    EndPoint[cnt] = rectCloudcontrol.EndPoint;
301
                                }
302
                                rectCloudcontrol.StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
303
                                rectCloudcontrol.LeftBottomPoint = new Point(StartPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
304
                                rectCloudcontrol.TopRightPoint = new Point(EndPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
305
                                rectCloudcontrol.EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
306
                            }
307
                            break;
308
                        case "TriControl":
309
                            {
310
                                tricontrol = control as TriControl;
311

    
312
                                if (StartPoint[cnt] == new Point())
313
                                {
314
                                    StartPoint[cnt] = tricontrol.StartPoint;
315
                                    MidPoint[cnt] = tricontrol.MidPoint;
316
                                    EndPoint[cnt] = tricontrol.EndPoint;
317
                                }
318
                                (control as TriControl).StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
319
                                (control as TriControl).MidPoint = new Point(MidPoint[cnt].X + p_x, MidPoint[cnt].Y + p_y);
320
                                (control as TriControl).EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
321
                            }
322
                            break;
323
                        #endregion
324

    
325
                        case "LineControl":
326
                            {
327
                                linecontrol = control as LineControl;
328

    
329
                                if (StartPoint[cnt] == new Point())
330
                                {
331
                                    StartPoint[cnt] = linecontrol.StartPoint;
332
                                    EndPoint[cnt] = linecontrol.EndPoint;
333
                                }
334
                                linecontrol.StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
335
                                linecontrol.EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
336
                            }
337
                            break;
338
                        case "ArcControl":
339
                            {
340
                                arccontrol = control as ArcControl;
341

    
342
                                if (Flag)
343
                                {
344
                                    (control as ArcControl).isTransOn = true;
345
                                }
346
                                if (StartPoint[cnt] == new Point())
347
                                {
348
                                    StartPoint[cnt] = arccontrol.StartPoint;
349
                                    EndPoint[cnt] = arccontrol.EndPoint;
350
                                }
351
                                arccontrol.StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
352
                                arccontrol.MidPoint = new Point(MidPoint[cnt].X + p_x, MidPoint[cnt].Y + p_y);
353
                                arccontrol.EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
354
                            }
355
                            break;
356
                        case "TextControl":
357
                            {
358
                                textcontrol = control as TextControl;
359

    
360
                                if (StartPoint[cnt] == new Point())
361
                                {
362
                                    StartPoint[cnt] = textcontrol.StartPoint;
363
                                    EndPoint[cnt] = textcontrol.EndPoint;
364
                                }
365
                                textcontrol.StartPoint = new Point(StartPoint[cnt].X + p_x, StartPoint[cnt].Y + p_y);
366
                                textcontrol.EndPoint = new Point(EndPoint[cnt].X + p_x, EndPoint[cnt].Y + p_y);
367
                            }
368
                            break;
369
                    }
370
                }
371
                cnt++;
372
            }
373
        }
374
        #endregion
375

    
376
        public void ItemRect(object control)
377
        {
378
            switch ((control as IMarkupCommonData).ControlType)
379
            {
380
                #region Shape
381
                case (ControlType.Rectangle):
382
                    {
383
                        s_point.X = Math.Min((control as RectangleControl).StartPoint.X, (control as RectangleControl).EndPoint.X);
384
                        s_point.Y = Math.Min((control as RectangleControl).StartPoint.Y, (control as RectangleControl).EndPoint.Y);
385
                        e_point.X = Math.Max((control as RectangleControl).StartPoint.X, (control as RectangleControl).EndPoint.X);
386
                        e_point.Y = Math.Max((control as RectangleControl).StartPoint.Y, (control as RectangleControl).EndPoint.Y);
387
                        rectSize = e_point - s_point;
388
                    }
389
                    break;
390
                case (ControlType.Circle):
391
                    {
392
                        s_point.X = Math.Min((control as CircleControl).StartPoint.X, (control as CircleControl).EndPoint.X);
393
                        s_point.Y = Math.Min((control as CircleControl).StartPoint.Y, (control as CircleControl).EndPoint.Y);
394
                        e_point.X = Math.Max((control as CircleControl).StartPoint.X, (control as CircleControl).EndPoint.X);
395
                        e_point.Y = Math.Max((control as CircleControl).StartPoint.Y, (control as CircleControl).EndPoint.Y);
396
                        rectSize = e_point - s_point;
397
                    }
398
                    break;
399
                case (ControlType.RectCloud):
400
                    {
401
                        s_point.X = Math.Min((control as RectCloudControl).StartPoint.X, (control as RectCloudControl).EndPoint.X);
402
                        s_point.Y = Math.Min((control as RectCloudControl).StartPoint.Y, (control as RectCloudControl).EndPoint.Y);
403
                        e_point.X = Math.Max((control as RectCloudControl).StartPoint.X, (control as RectCloudControl).EndPoint.X);
404
                        e_point.Y = Math.Max((control as RectCloudControl).StartPoint.Y, (control as RectCloudControl).EndPoint.Y);
405
                        rectSize = e_point - s_point;
406
                    }
407
                    break;
408
                case (ControlType.Triangle):
409
                    {
410
                        s_point.X = Math.Min((control as TriControl).StartPoint.X, (control as TriControl).EndPoint.X);
411
                        s_point.X = Math.Min((control as TriControl).MidPoint.X, s_point.X);
412
                        s_point.Y = Math.Min((control as TriControl).StartPoint.Y, (control as TriControl).EndPoint.Y);
413
                        s_point.Y = Math.Min((control as TriControl).MidPoint.Y, s_point.Y);
414
                        e_point.X = Math.Max((control as TriControl).StartPoint.X, (control as TriControl).EndPoint.X);
415
                        e_point.X = Math.Max((control as TriControl).MidPoint.X, e_point.X);
416
                        e_point.Y = Math.Max((control as TriControl).StartPoint.Y, (control as TriControl).EndPoint.Y);
417
                        e_point.Y = Math.Max((control as TriControl).MidPoint.Y, e_point.Y);
418
                        rectSize = e_point - s_point;
419
                    }
420
                    break;
421
                #endregion
422
                #region Line
423
                case (ControlType.SingleLine):
424
                    {
425
                        s_point.X = Math.Min((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
426
                        s_point.Y = Math.Min((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
427
                        e_point.X = Math.Max((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
428
                        e_point.Y = Math.Max((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
429
                        rectSize = e_point - s_point;
430
                    }
431
                    break;
432
                case (ControlType.ArrowLine):
433
                    {
434
                        s_point.X = Math.Min((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
435
                        s_point.Y = Math.Min((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
436
                        e_point.X = Math.Max((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
437
                        e_point.Y = Math.Max((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
438
                        rectSize = e_point - s_point;
439
                    }
440
                    break;
441
                case (ControlType.ArrowMultiLine):
442
                    {
443
                        s_point.X = Math.Min((control as ArrowControl_Multi).StartPoint.X, (control as ArrowControl_Multi).EndPoint.X);
444
                        s_point.Y = Math.Min((control as ArrowControl_Multi).StartPoint.Y, (control as ArrowControl_Multi).EndPoint.Y);
445
                        e_point.X = Math.Max((control as ArrowControl_Multi).StartPoint.X, (control as ArrowControl_Multi).EndPoint.X);
446
                        e_point.Y = Math.Max((control as ArrowControl_Multi).StartPoint.Y, (control as ArrowControl_Multi).EndPoint.Y);
447
                        rectSize = e_point - s_point;
448
                    }
449
                    break;
450
                case (ControlType.CancelLine):
451
                    {
452
                        s_point.X = Math.Min((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
453
                        s_point.Y = Math.Min((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
454
                        e_point.X = Math.Max((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
455
                        e_point.Y = Math.Max((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
456
                        rectSize = e_point - s_point;
457
                    }
458
                    break;
459
                case (ControlType.DimLine):
460
                    {
461
                        s_point.X = Math.Min((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
462
                        s_point.Y = Math.Min((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
463
                        e_point.X = Math.Max((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
464
                        e_point.Y = Math.Max((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
465
                        rectSize = e_point - s_point;
466
                    }
467
                    break;
468
                case (ControlType.TwinLine):
469
                    {
470
                        s_point.X = Math.Min((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
471
                        s_point.Y = Math.Min((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
472
                        e_point.X = Math.Max((control as LineControl).StartPoint.X, (control as LineControl).EndPoint.X);
473
                        e_point.Y = Math.Max((control as LineControl).StartPoint.Y, (control as LineControl).EndPoint.Y);
474
                        rectSize = e_point - s_point;
475
                    }
476
                    break;
477
                case (ControlType.ArcLine):
478
                    {
479
                        s_point.X = Math.Min((control as ArcControl).StartPoint.X, (control as ArcControl).EndPoint.X);
480
                        s_point.X = Math.Min((control as ArcControl).MidPoint.X, s_point.X);
481
                        s_point.Y = Math.Min((control as ArcControl).StartPoint.Y, (control as ArcControl).EndPoint.Y);
482
                        s_point.Y = Math.Min((control as ArcControl).MidPoint.Y, s_point.Y);
483
                        e_point.X = Math.Max((control as ArcControl).StartPoint.X, (control as ArcControl).EndPoint.X);
484
                        e_point.X = Math.Max((control as ArcControl).MidPoint.X, e_point.X);
485
                        e_point.Y = Math.Max((control as ArcControl).StartPoint.Y, (control as ArcControl).EndPoint.Y);
486
                        e_point.Y = Math.Max((control as ArcControl).MidPoint.Y, e_point.Y);
487
                        rectSize = e_point - s_point;
488
                    }
489
                    break;
490
                case (ControlType.ArcArrow):
491
                    {
492
                        s_point.X = Math.Min((control as ArcControl).StartPoint.X, (control as ArcControl).EndPoint.X);
493
                        s_point.X = Math.Min((control as ArcControl).MidPoint.X, s_point.X);
494
                        s_point.Y = Math.Min((control as ArcControl).StartPoint.Y, (control as ArcControl).EndPoint.Y);
495
                        s_point.Y = Math.Min((control as ArcControl).MidPoint.Y, s_point.Y);
496
                        e_point.X = Math.Max((control as ArcControl).StartPoint.X, (control as ArcControl).EndPoint.X);
497
                        e_point.X = Math.Max((control as ArcControl).MidPoint.X, e_point.X);
498
                        e_point.Y = Math.Max((control as ArcControl).StartPoint.Y, (control as ArcControl).EndPoint.Y);
499
                        e_point.Y = Math.Max((control as ArcControl).MidPoint.Y, e_point.Y);
500
                        rectSize = e_point - s_point;
501
                    }
502
                    break;
503
                #endregion
504

    
505
                case (ControlType.TextControl):
506
                    {
507
                        //s_point.X = Math.Min((control as TextControl).StartPoint.X, (control as TextControl).EndPoint.X);
508
                        //s_point.Y = Math.Min((control as TextControl).StartPoint.Y, (control as TextControl).EndPoint.Y);
509
                        //e_point.X = Math.Max((control as TextControl).StartPoint.X, (control as TextControl).EndPoint.X);
510
                        //e_point.Y = Math.Max((control as TextControl).StartPoint.Y, (control as TextControl).EndPoint.Y);
511

    
512
                        s_point.X = (control as TextControl).CanvasX;
513
                        s_point.Y = (control as TextControl).CanvasY;
514

    
515
                        e_point.X = s_point.X + (control as TextControl).BoxWidth;
516
                        e_point.Y = s_point.Y + (control as TextControl).BoxHeight;
517

    
518
                        rectSize = e_point - s_point;
519
                    }
520
                    break;
521
            }
522
            itemRect = new Rect(s_point.X, s_point.Y, rectSize.X, rectSize.Y);
523
        }
524

    
525
        public void IsSelectionControl(Geometry OverViewPathData)
526
        {
527
            if (DragRect.Contains(itemRect))
528
            {
529
                selected_item = new Dictionary<Geometry, string>();
530
                selected_item.Add(OverViewPathData, CommonData.ToString());
531
            }
532
        }
533
    }
534
}
클립보드 이미지 추가 (최대 크기: 500 MB)