프로젝트

일반

사용자정보

개정판 554aae3b

ID554aae3be84867ae4eb5fed4c18ccc93163a3425
상위 77bcd0c6
하위 e0cfc73c

백흠경이(가) 5년 이상 전에 추가함

issue #923: apply page rotation when drag controls

Change-Id: Ie927540d6831573609976d0e77cd767663c4bf4a

차이점 보기:

KCOM/Controls/AdornerFinal.xaml.cs
138 138
                }
139 139
            }
140 140
        }
141

  
142
        /// <summary>
143
        /// rotate members about given position and angle
144
        /// </summary>
145
        /// <param name="at"></param>
146
        /// <param name="angle">in degree</param>
147
        public void RotateAbout(Point at, double angle)
148
        {
149
            for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
150
            {
151
                (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
152
            }
153
            (this.DrawingData as CommentUserInfo).UpdateControl();
154

  
155
            this.UpdateThumb();
156
        }
141 157
    }
142 158

  
143 159
    public partial class AdornerFinal : UserControl
......
294 310
            switch (member.GetType().Name)
295 311
            {
296 312
                #region 컨트롤 조건
297
                case "LineControl": //Angle추가 안했음
298
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
299
                    break;
300
                case "ImgControl": //Angle추가 안했음
301
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
302
                    //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);            
303
                    //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
304
                    AngleValue = (member as ImgControl).Angle;
305
                    break;
306
                //case "SymControl": //Angle추가 안했음
307
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<MyThumb>() });
308
                //    AngleValue = (member as SymControl).Angle;
309
                //    //ViewBoxRotate(member);
310
                //    break;
311
                //case "SymControlN": //Angle추가 안했음
312
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<MyThumb>() });
313
                //    AngleValue = (member as SymControlN).Angle;
314
                //    //ViewBoxRotate(member);
315
                //    break;
316
                case "PolygonControl": //Angle추가 안했음
317
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
318
                    break;
313
                case "LineControl":
314
                case "PolygonControl":
319 315
                case "ArrowControl":
320
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
316
                case "ArcControl":
317
                case "ArrowArcControl":
318
                case "ArrowControl_Multi":
319
                case "RectangleControl":
320
                case "TriControl":
321
                case "CircleControl":
322
                case "CloudControl":
323
                case "RectCloudControl":
324
                case "InkControl":
325
                case "InsideWhiteControl":
326
                case "OverlapWhiteControl":
327
                case "ClipWhiteControl":
328
                case "CoordinateControl":
329
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
321 330
                    break;
322 331
                case "ArrowTextControl":
323 332
                    this.Members.Add(new AdornerMember
......
341 350
                        }
342 351
                    });
343 352
                    break;
344
                case "ArcControl":
345
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
346
                    break;
347
                case "ArrowArcControl":
348
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
349
                    break;
350
                case "ArrowControl_Multi":
351
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
352
                    break;
353
                case "RectangleControl":
354
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
355
                    break;
353
                case "ImgControl":
356 354
                case "DateControl":
357
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
358
                    AngleValue = (member as DateControl).Angle;
359
                    break;
360
                case "TriControl":
361
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
362
                    break;
363
                case "CircleControl":
364
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
365
                    break;
366
                case "CloudControl":
367
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
368
                    break;
369
                case "RectCloudControl":
370
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
371
                    break;
372 355
                case "SignControl":
373
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
374
                    AngleValue = (member as SignControl).Angle;
375
                    break;
376

  
377 356
                case "SymControl":
378
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
379
                    AngleValue = (member as SymControl).Angle;
380
                    break;
381 357
                case "SymControlN":
382
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
383
                    AngleValue = (member as SymControlN).Angle;
384
                    break;
385
                case "InkControl": //Angle추가 안했음
386
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
358
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
359
                    AngleValue = (member as DateControl).Angle;
387 360
                    break;
388 361
                case "TextControl":
389 362
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
......
440 413
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
441 414
                    });
442 415
                    break;
443
                case "InsideWhiteControl":
444
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
445
                    break;
446
                case "OverlapWhiteControl":
447
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
448
                    break;
449
                case "ClipWhiteControl":
450
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
451
                    break;
452
                case "CoordinateControl":
453
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
454
                    break;
455 416
                default:
456 417
                    break;
457 418
                    #endregion
458 419
            }
420

  
459 421
            if (member.GetType().Name == "TextControl")
460 422
            {
461 423
                TextControl content = ((TextControl)member);
462 424
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
463 425
                content.EndPoint = content.StartPoint;
464

  
465 426
            }
466 427
            else
467 428
            {
......
1156 1117
        /// <param name="item"></param>
1157 1118
        private void TranslateItem(double dx, double dy, AdornerMember item)
1158 1119
        {
1159
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), 0);
1120
            /// rotate point with page rotation
1121
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1122
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1123
            /// up to here
1160 1124
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1161 1125
            item.UpdateThumb();
1162 1126
        }
......
1469 1433
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1470 1434
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1471 1435

  
1472
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1473
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1474
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1475

  
1476 1436
            AngleValue += dDeltaAngle;
1477 1437
            if (AngleValue > 360) AngleValue -= 360;
1478 1438
            if (AngleValue < 0) AngleValue += 360;
......
1480 1440

  
1481 1441
            Dispatcher.BeginInvoke((Action)(() =>
1482 1442
            {
1483
                foreach (var item in this.Members)
1484
                {
1485
                    foreach (var thumb in item.ThumbList)
1486
                    {
1487
                        double x = Canvas.GetLeft(thumb);
1488
                        double y = Canvas.GetTop(thumb);
1489

  
1490
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1491
                        Canvas.SetLeft(thumb, value.X);
1492
                        Canvas.SetTop(thumb, value.Y);
1493
                    }
1494

  
1495
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1496
                    {
1497
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1498
                    }
1499
                }
1500
                #region 보더 업데이트
1501
                foreach (var item in this.Members)
1443
                foreach (var member in this.Members)
1502 1444
                {
1503
                    switch (item.Drawingtype)
1445
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1446
                    #region 보더 업데이트
1447
                    switch (member.Drawingtype)
1504 1448
                    {
1505 1449
                        case ControlType.TextControl:
1506
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1450
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1507 1451

  
1508 1452
                            RectangleGeometry Data = new RectangleGeometry
1509 1453
                            {
1510 1454
                                Rect = new Rect()
1511 1455
                                {
1512
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1513
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1514
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1515
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1456
                                    X = Canvas.GetLeft((member.DrawingData as TextControl)),
1457
                                    Y = Canvas.GetTop((member.DrawingData as TextControl)),
1458
                                    Width = (member.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1459
                                    Height = (member.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1516 1460
                                }
1517 1461
                            };
1518 1462

  
1519 1463
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1520
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1464
                            Point middle = MathSet.getMiddlePoint((member.DrawingData as TextControl).StartPoint, endPointV);
1521 1465

  
1522 1466
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1523 1467
                            DragThumb.RenderTransform = new RotateTransform()
1524 1468
                            {
1525
                                Angle = (item.DrawingData as TextControl).Angle,
1526
                                //CenterX = middle.X,
1527
                                //CenterY = middle.Y,
1469
                                Angle = (member.DrawingData as TextControl).Angle,
1528 1470
                            };
1529 1471

  
1530 1472
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1531 1473
                            AdornerBorder.RenderTransform = new RotateTransform()
1532 1474
                            {
1533
                                Angle = (item.DrawingData as TextControl).Angle,
1534
                                //CenterX = middle.X,
1535
                                //CenterY = middle.Y,
1475
                                Angle = (member.DrawingData as TextControl).Angle,
1536 1476
                            };
1537 1477

  
1538
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1478
                            (member.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1539 1479
                            {
1540
                                Angle = (item.DrawingData as TextControl).Angle,
1480
                                Angle = (member.DrawingData as TextControl).Angle,
1541 1481
                            };
1542 1482

  
1543 1483
                            BorderUpdate();
1544 1484
                            break;
1545 1485

  
1546
                        case ControlType.Date:
1547
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1548
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1549
                            BorderUpdate();                          
1550
                            break;
1551 1486
                        case ControlType.ArrowMultiLine:
1552 1487
                        case ControlType.ArcLine:
1553 1488
                        case ControlType.ArcArrow:
1554 1489
                        case ControlType.SingleLine:
1555 1490
                        case ControlType.Triangle:
1556
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1557
                            BorderUpdate();
1558
                            break;
1559 1491
                        case ControlType.ArrowTextControl:
1560
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1492
                        case ControlType.PolygonControl:
1493
                        case ControlType.Ink:
1561 1494
                            BorderUpdate();
1562 1495
                            break;
1496
                        case ControlType.Date:
1563 1497
                        case ControlType.RectCloud:
1564
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1565
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1566
                            BorderUpdate();
1567
                            break;
1568 1498
                        case ControlType.Rectangle:
1569
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1570
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1571
                            BorderUpdate();
1572
                            break;
1573 1499
                        case ControlType.ImgControl:
1574
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1575
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1576
                            BorderUpdate();
1577
                            break;                        
1578 1500
                        case ControlType.Sign:
1579
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1580
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1581
                            BorderUpdate();
1582
                            break;                        
1583 1501
                        case ControlType.Symbol:
1584
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1585
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1586
                            BorderUpdate();
1587
                            break;
1588 1502
                        case ControlType.Stamp:
1589
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1590
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1591
                            BorderUpdate();
1592
                            break;
1593
                        case ControlType.PolygonControl:
1594
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1503
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1595 1504
                            BorderUpdate();
1596 1505
                            break;
1597 1506
                        case ControlType.PolygonCloud:
1598
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1599
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1507
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1600 1508
                            BorderUpdate();
1601 1509
                            break;
1602 1510
                        case ControlType.Circle:
1603
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1604
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1605
                            ((CircleControl)item.DrawingData).SetCenterXY();
1511
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1512
                            ((CircleControl)member.DrawingData).SetCenterXY();
1606 1513
                            BorderUpdate();
1607 1514
                            break;
1608
                        case ControlType.Ink:
1609
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1610
                            {
1611
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1612
                                {
1613
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1614
                                }
1615
                            }
1616
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1617
                            BorderUpdate();
1618
                            break;
1619
                        
1620 1515
                        default:
1621 1516
                            break;
1622 1517
                    }
1623 1518
                }
1624 1519
                #endregion
1625 1520
            }));
1626
            BorderUpdate();
1627 1521
        }
1628 1522

  
1629 1523
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)