프로젝트

일반

사용자정보

개정판 0d00f9c8

ID0d00f9c81d1c7f1736863a06f43686f6fe0df84e
상위 5984979a
하위 8771edc4

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

issue #923: implementing drag textcontrol

Change-Id: I17d1f4ec754ea13646260d1c331d574ad680d47d

차이점 보기:

KCOM/Controls/AdornerFinal.xaml.cs
37 37
        /// </summary>
38 38
        /// <param name="e"></param>
39 39
        /// <param name="angle"></param>
40
        public void Translate(DragDeltaEventArgs e, double angle)
40
        public void Translate(double dx, double dy, double angle)
41 41
        {
42 42
            double radian = angle * Math.PI / 180;
43 43
            double cos = Math.Cos(radian);
44 44
            double sin = Math.Sin(radian);
45 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);
46
            double _dx = dx * cos - dy * sin;
47
            double _dy = dx * sin + dy * cos;
48
            Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx);
49
            Canvas.SetTop(this, Canvas.GetTop(this) + _dy);
50 50
        }
51 51

  
52 52
        /// <summary>
......
102 102

  
103 103
        public Point reSizePoint { get; set; }
104 104
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
105
        private Point MouseDownPoint = new Point();
106
        private Point CurrentMousePoint = new Point();
105 107
        #endregion
106 108
        #region 생성자
107 109
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
......
865 867
                    {
866 868
                        tm.RenderTransformOrigin = new Point(0, 0);
867 869
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
868

  
869 870
                    }
870 871
                    else
871 872
                    {
......
930 931
            {
931 932
                MyThumb thumb = sender as MyThumb;
932 933
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
933
                thumb.Translate(e, this.AngleValue);
934
                thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue);
934 935
                
935 936
                AdornerMember control = (from userThumb in this.Members
936 937
                                         where userThumb.ThumbList.Contains(thumb)
......
1018 1019

  
1019 1020
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1020 1021
        {
1021
            DragThumb.Cursor = Cursors.SizeAll;
1022
            Thumb thumb = sender as Thumb;
1023
            MoveAdorner(e);
1022
            try
1023
            {
1024
                double dx = this.MouseDownPoint.X + e.HorizontalChange - this.CurrentMousePoint.X;
1025
                double dy = this.MouseDownPoint.Y + e.VerticalChange - this.CurrentMousePoint.Y;
1026

  
1027
                DragThumb.Cursor = Cursors.SizeAll;
1028
                Thumb thumb = sender as Thumb;
1029
                this.TranslateItems(e.HorizontalChange, e.VerticalChange);
1030
                System.Diagnostics.Debug.WriteLine(String.Format("dx={0}, dy={1}", e.HorizontalChange - dx, e.VerticalChange - dy));
1031
            }
1032
            finally
1033
            {
1034
                /// update CurrentMousePoint
1035
                this.CurrentMousePoint.X = this.MouseDownPoint.X + e.HorizontalChange;
1036
                this.CurrentMousePoint.Y = this.MouseDownPoint.Y + e.VerticalChange;
1037
            }
1024 1038
        }
1025 1039

  
1026
        public void MoveAdorner(DragDeltaEventArgs e)
1040
        /// <summary>
1041
        /// translate all members
1042
        /// </summary>
1043
        /// <param name="e"></param>
1044
        public void TranslateItems(double dx, double dy)
1027 1045
        {
1028
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1029

  
1030 1046
            Dispatcher.BeginInvoke((Action)(() =>
1031 1047
            {
1032 1048
                foreach (var item in this.Members)
1033 1049
                {
1034
                    #region 라인  & 아크
1035
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine || item.Drawingtype == ControlType.ArcArrow)
1036
                    {
1037
                        DynamicThumbUpdate(e, item);
1038
                    }
1039
                    #endregion
1040
                    #region 지시선화살표
1041
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1042
                    {
1043
                        DynamicThumbUpdate(e, item);
1044
                    }
1045
                    #endregion
1046

  
1047
                    #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
                    {
1062
                        //DynamicThumbUpdate(e, item);
1063
                        (item.DrawingData as TextControl).Move(e.HorizontalChange, e.VerticalChange);
1064
                    }
1065
                    #endregion
1066
                    #region 날짜
1067
                    if (item.Drawingtype == ControlType.Date)
1068
                    {
1069
                        DynamicThumbUpdate(e, item);
1070
                    }
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
                    #region 심볼
1081

  
1082
                    #endregion
1083

  
1084
                    #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();
1050
                    this.TranslateItem(dx, dy, item);
1116 1051
                }
1117 1052
            }));
1053
            ///this.BorderUpdate();
1118 1054
        }
1119 1055

  
1120
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1056
        /// <summary>
1057
        /// translate a item
1058
        /// </summary>
1059
        /// <param name="e"></param>
1060
        /// <param name="item"></param>
1061
        private void TranslateItem(double dx, double dy, AdornerMember item)
1121 1062
        {
1122
            var AllControl = item.DrawingData as IPath;
1123
            List<Point> point = AllControl.PointSet;
1063
            ///dx = this.CurrentMousePoint.X - this.MouseDownPoint.X + dx;
1064
            ///dy = this.CurrentMousePoint.Y - this.MouseDownPoint.Y + dy;
1065

  
1066
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), this.trRotate.Angle);
1067
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1124 1068
            for (int i = 0; i < item.ThumbList.Count(); i++)
1125 1069
            {
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
                }
1070
                (item.ThumbList[i] as MyThumb).Translate(dx, dy , this.trRotate.Angle);
1145 1071
            }
1146 1072
        }
1147 1073

  
......
1152 1078

  
1153 1079
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1154 1080
            {
1155

  
1156 1081
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1157 1082
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1158 1083
            }
......
1365 1290

  
1366 1291
                        case ControlType.Date:
1367 1292
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1368
                            (item.DrawingData as IPath).updateControl();
1293
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1369 1294
                            BorderUpdate();
1370 1295
                            break;
1371 1296
                        case ControlType.ArrowMultiLine:
......
1373 1298
                        case ControlType.ArcArrow:
1374 1299
                        case ControlType.SingleLine:
1375 1300
                        case ControlType.Triangle:
1376
                            (item.DrawingData as IPath).updateControl();
1301
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1377 1302
                            BorderUpdate();
1378 1303
                            break;
1379 1304
                        case ControlType.ArrowTextControl:
1380
                            (item.DrawingData as IPath).updateControl();
1305
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1381 1306
                            BorderUpdate();
1382 1307
                            break;
1383 1308
                        case ControlType.RectCloud:
1384 1309
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1385
                            (item.DrawingData as IPath).updateControl();
1310
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1386 1311
                            BorderUpdate();
1387 1312
                            break;
1388 1313
                        case ControlType.Rectangle:
1389 1314
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1390
                            (item.DrawingData as IPath).updateControl();
1315
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1391 1316
                            BorderUpdate();
1392 1317
                            break;
1393 1318
                        case ControlType.ImgControl:
1394 1319
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1395
                            (item.DrawingData as IPath).updateControl();
1320
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1396 1321
                            BorderUpdate();
1397 1322
                            break;
1398 1323
                        case ControlType.Sign:
1399 1324
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1400
                            (item.DrawingData as IPath).updateControl();
1325
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1401 1326
                            BorderUpdate();
1402 1327
                            break;
1403 1328
                        case ControlType.Symbol:
1404 1329
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1405
                            (item.DrawingData as IPath).updateControl();
1330
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1406 1331
                            BorderUpdate();
1407 1332
                            break;
1408 1333
                        case ControlType.Stamp:
1409 1334
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1410
                            (item.DrawingData as IPath).updateControl();
1335
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1411 1336
                            BorderUpdate();
1412 1337
                            break;
1413 1338
                        case ControlType.PolygonControl:
1414
                            (item.DrawingData as IPath).updateControl();
1339
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1415 1340
                            BorderUpdate();
1416 1341
                            break;
1417 1342
                        case ControlType.PolygonCloud:
1418 1343
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1419
                            (item.DrawingData as IPath).updateControl();
1344
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1420 1345
                            BorderUpdate();
1421 1346
                            break;
1422 1347
                        case ControlType.Circle:
1423 1348
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1424
                            (item.DrawingData as IPath).updateControl();
1349
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1425 1350
                            ((CircleControl)item.DrawingData).SetCenterXY();
1426 1351
                            BorderUpdate();
1427 1352
                            break;
1428 1353
                        case ControlType.Ink:
1429
                            (item.DrawingData as IPath).updateControl();
1354
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1430 1355
                            BorderUpdate();
1431 1356
                            break;
1432 1357
                        case ControlType.InsideWhite:
1433 1358
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1434
                            (item.DrawingData as IPath).updateControl();
1359
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1435 1360
                            BorderUpdate();
1436 1361
                            break;
1437 1362
                        case ControlType.OverlapWhite:
1438 1363
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1439
                            (item.DrawingData as IPath).updateControl();
1364
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1440 1365
                            BorderUpdate();
1441 1366
                            break;
1442 1367
                        case ControlType.ClipWhite:
1443 1368
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1444
                            (item.DrawingData as IPath).updateControl();
1369
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1445 1370
                            BorderUpdate();
1446 1371
                            break;
1447 1372
                        case ControlType.Coordinate:
1448 1373
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1449
                            (item.DrawingData as IPath).updateControl();
1374
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1450 1375
                            BorderUpdate();
1451 1376
                            break;
1452 1377
                        default:
......
1461 1386
        {
1462 1387
            reSizePoint = e.GetPosition(this);
1463 1388
        }
1389

  
1464 1390
        /// <summary>
1465 1391
        /// 회전
1466 1392
        /// </summary>
......
1468 1394
        /// <param name="e"></param>
1469 1395
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1470 1396
        {
1471

  
1472 1397
            MoveRotate(e);
1473 1398
        }
1474 1399

  
......
1594 1519

  
1595 1520
                        case ControlType.Date:
1596 1521
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1597
                            (item.DrawingData as IPath).updateControl();
1522
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1598 1523
                            BorderUpdate();                          
1599 1524
                            break;
1600 1525
                        case ControlType.ArrowMultiLine:
......
1602 1527
                        case ControlType.ArcArrow:
1603 1528
                        case ControlType.SingleLine:
1604 1529
                        case ControlType.Triangle:
1605
                            (item.DrawingData as IPath).updateControl();
1530
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1606 1531
                            BorderUpdate();
1607 1532
                            break;
1608 1533
                        case ControlType.ArrowTextControl:
1609
                            (item.DrawingData as IPath).updateControl();
1534
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1610 1535
                            BorderUpdate();
1611 1536
                            break;
1612 1537
                        case ControlType.RectCloud:
1613 1538
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1614
                            (item.DrawingData as IPath).updateControl();
1539
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1615 1540
                            BorderUpdate();
1616 1541
                            break;
1617 1542
                        case ControlType.Rectangle:
1618 1543
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1619
                            (item.DrawingData as IPath).updateControl();
1544
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1620 1545
                            BorderUpdate();
1621 1546
                            break;
1622 1547
                        case ControlType.ImgControl:
1623 1548
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1624
                            (item.DrawingData as IPath).updateControl();
1549
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1625 1550
                            BorderUpdate();
1626 1551
                            break;                        
1627 1552
                        case ControlType.Sign:
1628 1553
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1629
                            (item.DrawingData as IPath).updateControl();
1554
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1630 1555
                            BorderUpdate();
1631 1556
                            break;                        
1632 1557
                        case ControlType.Symbol:
1633 1558
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1634
                            (item.DrawingData as IPath).updateControl();
1559
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1635 1560
                            BorderUpdate();
1636 1561
                            break;
1637 1562
                        case ControlType.Stamp:
1638 1563
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1639
                            (item.DrawingData as IPath).updateControl();
1564
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1640 1565
                            BorderUpdate();
1641 1566
                            break;
1642 1567
                        case ControlType.PolygonControl:
1643
                            (item.DrawingData as IPath).updateControl();
1568
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1644 1569
                            BorderUpdate();
1645 1570
                            break;
1646 1571
                        case ControlType.PolygonCloud:
1647 1572
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1648
                            (item.DrawingData as IPath).updateControl();
1573
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1649 1574
                            BorderUpdate();
1650 1575
                            break;
1651 1576
                        case ControlType.Circle:
1652 1577
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1653
                            (item.DrawingData as IPath).updateControl();
1578
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1654 1579
                            ((CircleControl)item.DrawingData).SetCenterXY();
1655 1580
                            BorderUpdate();
1656 1581
                            break;
......
1662 1587
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1663 1588
                                }
1664 1589
                            }
1665
                            (item.DrawingData as IPath).updateControl();
1590
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1666 1591
                            BorderUpdate();
1667 1592
                            break;
1668 1593
                        
......
1727 1652

  
1728 1653
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1729 1654
        {
1655
            /// save mouse down and current mouse point
1656
            this.MouseDownPoint.X = e.HorizontalOffset;
1657
            this.MouseDownPoint.Y = e.VerticalOffset;
1658
            this.CurrentMousePoint.X = e.HorizontalOffset;
1659
            this.CurrentMousePoint.Y = e.VerticalOffset;
1660
            /// up to here
1661

  
1730 1662
            if (ViewerDataModel.Instance.UndoDataList == null)
1731 1663
            {
1732 1664
                return;

내보내기 Unified diff

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