프로젝트

일반

사용자정보

개정판 e65e8c5c

IDe65e8c5cb23d23362889f3be6e0a4248c9aa29c4
상위 1b0edce7
하위 5a565c3c

백흠경이(가) 9달 전에 추가함

Fix: 회전 로직 수정

Change-Id: I8f2e7b85a1365f06764fbd9203f29594610b14c5

차이점 보기:

KCOM/Controls/AdornerFinal.xaml.cs
158 158

  
159 159
        private List<double> AlignedAngles {get;} = new List<double>() { 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330, 360 };
160 160

  
161
        private double angleValue;
161
        /// <summary>
162
        /// 회전 시작할때의 각도
163
        /// </summary>
162 164
        public double dBeforeAngle { get; set; }
163 165

  
166
        private double angleValue;
164 167
        public double AngleValue { get => angleValue;
165 168
            set
166 169
            {
......
171 174
            }
172 175
        }
173 176

  
177
        /// <summary>
178
        /// Axis Lock을 적용하지 않는 실제 회전 각도
179
        /// </summary>
180
        private double _ActualAngle { get; set; }
181

  
174 182
        public List<Point> lstBeforePointSet { get; set; }
175 183

  
176 184
        public bool IsTextAngle = false;
......
185 193
        private bool disposed;
186 194

  
187 195
        public Point reSizePoint { get; set; }
188
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
196
        private Point RotatedPoint { get; set; } /// 2018.05.09 added by humkyung
189 197
        private Point MouseDownPoint = new Point();
190 198
        private Point CurrentMousePoint = new Point();
191 199
        #endregion
......
408 416
                case "ClipWhiteControl":
409 417
                case "CoordinateControl":
410 418
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
419
                    _ActualAngle = AngleValue = member.CommentAngle;
411 420
                    break;
412 421
                case "ArrowTextControl":
413 422
                    this.Members.Add(new AdornerMember
......
419 428
                        Group_ID = member.GroupID,
420 429
                    });
421 430
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
422
                    AngleValue = (member as ArrowTextControl).CommentAngle;
431
                    _ActualAngle = AngleValue = (member as ArrowTextControl).CommentAngle;
423 432

  
424 433
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
425

  
426
                    //Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
427
                    //{
428
                    //    TextCompensation = false;
429
                    //    BorderUpdate();
430
                    //    if ((a.Sender as TextBox).Text == "") //보류
431
                    //    {
432
                    //        this.ContainerContent.Children.Remove(member);
433
                    //        this.Visibility = Visibility.Collapsed;
434
                    //    }
435
                    //});
436 434
                    break;
437 435
                case "ImgControl":
438 436
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
439
                    AngleValue = (member as ImgControl).CommentAngle;
437
                    _ActualAngle = AngleValue = (member as ImgControl).CommentAngle;
440 438
                    break;
441 439
                case "DateControl":
442 440
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
443
                    AngleValue = (member as DateControl).CommentAngle;
441
                    _ActualAngle = AngleValue = (member as DateControl).CommentAngle;
444 442
                    break;
445 443
                case "SignControl":
446 444
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
447
                    AngleValue = (member as SignControl).CommentAngle;
445
                    _ActualAngle = AngleValue = (member as SignControl).CommentAngle;
448 446
                    break;
449 447
                case "SymControl":
450 448
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
451
                    AngleValue = (member as SymControl).CommentAngle;
449
                    _ActualAngle = AngleValue = (member as SymControl).CommentAngle;
452 450
                    break;
453 451
                case "SymControlN":
454 452
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
455
                    AngleValue = (member as SymControlN).CommentAngle;
453
                    _ActualAngle = AngleValue = (member as SymControlN).CommentAngle;
456 454
                    break;
457 455
                case "TextControl":
458 456
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
......
464 462
                            Y = Canvas.GetTop((member as TextControl)),
465 463
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
466 464
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
467
                            //Width = (member as TextControl).BoxWidth / 2,
468
                            //Height = (member as TextControl).BoxHeight / 2,
469 465
                        }
470 466
                    };
471 467
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
......
476 472
                    DragThumb.RenderTransform = new RotateTransform()
477 473
                    {
478 474
                        Angle = (member as TextControl).CommentAngle,
479
                        //CenterX = middle.X,
480
                        //CenterY = middle.Y,
481 475
                    };
482 476

  
483 477
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
484 478
                    AdornerBorder.RenderTransform = new RotateTransform()
485 479
                    {
486 480
                        Angle = (member as TextControl).CommentAngle,
487
                        //CenterX = middle.X,
488
                        //CenterY = middle.Y,
489 481
                    };
490
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
491
                    //{
492
                    //    TextCompensation = true;
493
                    //    BorderUpdate();
494
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
495
                    //});
496

  
497
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
498
                    //{
499
                    //    TextCompensation = true;
500
                    //    BorderUpdate();
501
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
502
                    //});
503 482

  
504 483
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
505 484
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
506

  
507
                    //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
508
                    //{
509
                    //    TextCompensation = false;
510
                    //    BorderUpdate();
511
                    //    if ((a.Sender as TextBox).Text == "") //보류
512
                    //    {
513
                    //        this.ContainerContent.Children.Remove(member);
514
                    //        this.Visibility = Visibility.Collapsed;
515
                    //    }
516

  
517
                    //    //((TextControl)member).UnEditingMode();
518
                    //    //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
519
                    //    //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
520
                    //    //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
521
                    //});
522 485
                    break;
523 486
                default:
524 487
                    break;
......
868 831
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
869 832
        {
870 833
            int count = 0;
871
            List<Point> list = (member as IPath).PointSet;
834
            List<Point> pts = (member as IPath).PointSet;
872 835
            if (member.GetType().Name == "InkControl")
873 836
            {
874
                list.Clear();
875
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
876
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
877
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
878
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
837
                pts.Clear();
838
                pts.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
839
                pts.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
840
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
841
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
879 842
            }
880 843
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
881
            double Minx = list.Min(x => x.X);
882
            double Miny = list.Min(x => x.Y);
844
            double Minx = pts.Min(x => x.X);
845
            double Miny = pts.Min(x => x.Y);
883 846

  
884
            for (int i = 0; i < list.Count; i++)
847
            for (int i = 0; i < pts.Count; i++)
885 848
            {
886 849
                MyThumb tm = new MyThumb
887 850
                {
......
890 853

  
891 854
                this.Members.Last().ThumbList.Add(tm);
892 855

  
893
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MiddlePoint))
856
                if ((markT == ControlType.ArcLine && pts[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && pts[i] == (member as ArrowArcControl).MiddlePoint))
894 857
                {
895 858
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
896 859
                }
......
955 918
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
956 919
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
957 920
                            //list[count] = tempP;
958
                            list[count] = temp.MidPoint;
921
                            pts[count] = temp.MidPoint;
959 922
                        }
960 923
                        else
961 924
                        {
......
979 942
                                {
980 943
                                    testP = new Point(endP.X + 50, endP.Y);
981 944
                                }
982
                                list[count] = testP;
945
                                pts[count] = testP;
983 946
                            }
984 947
                            else
985 948
                            {
986 949
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
987
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
950
                                pts[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
988 951
                            }
989 952
                        }
990 953
                    }
991 954
                }
992 955

  
993 956
                /// ArrowTextControl text box 화면 출력
994
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
957
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == pts.Last())
995 958
                {
996 959
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
997 960
                    tm.Width = (member as ArrowTextControl).BoxWidth;
......
1019 982
                
1020 983
                if (member.GetType().Name == "CloudControl")
1021 984
                {
1022
                    if (i == list.Count() - 1)
985
                    if (i == pts.Count() - 1)
1023 986
                    {
1024 987
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1025 988
                    }
1026 989
                }
1027 990
                if (member.GetType().Name == "PolygonControl")
1028 991
                {
1029
                    if (i == list.Count() - 1)
992
                    if (i == pts.Count() - 1)
1030 993
                    {
1031 994
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
1032 995
                        {
......
1044 1007
                }
1045 1008
                
1046 1009
                this.ContainerContent.Children.Add(tm);
1047
                Canvas.SetLeft(tm, list[count].X);
1048
                Canvas.SetTop(tm, list[count].Y);
1049
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
1010
                Canvas.SetLeft(tm, pts[count].X);
1011
                Canvas.SetTop(tm, pts[count].Y);
1012
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == (member as ArrowTextControl).MidPoint)
1050 1013
                {
1051 1014
                    Canvas.SetZIndex(tm, 95);
1052 1015
                    //tm.Opacity = 0;
......
1472 1435
            Point pt = Mouse.GetPosition(this);
1473 1436

  
1474 1437
            #region X축 기준으로 회전 각도를 구한다.
1475
            Vector AxisY = new Vector(0, 1);
1476
            Vector vec2 = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1477
            vec2.Normalize();
1478
            double angle = Vector.AngleBetween(AxisY, vec2);
1479
            if (angle > 360) angle -= 360;
1480
            if (angle < 0) angle += 360;
1438
            Vector AxisX = new Vector(RotatedPoint.X - CenterPoint.X, RotatedPoint.Y - CenterPoint.Y);
1439
            AxisX.Normalize();
1440
            Vector AxisY = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1441
            AxisY.Normalize();
1442
            double dDeltaAngle = Vector.AngleBetween(AxisX, AxisY);
1481 1443
            #endregion
1482 1444

  
1445
            _ActualAngle += dDeltaAngle;
1446
            if (_ActualAngle > 360) _ActualAngle -= 360;
1447
            if (_ActualAngle < 0) _ActualAngle += 360;
1483 1448
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1484 1449
            if (ViewerDataModel.Instance.IsAxisLock)
1485 1450
            {
1486
                angle = AlignedAngles.OrderBy(x => Math.Abs(angle - x)).First();
1451
                double tmp = AlignedAngles.OrderBy(x => Math.Abs(_ActualAngle - x)).First();
1452
                dDeltaAngle = tmp - AngleValue;
1453
                AngleValue = tmp;
1454
            }
1455
            else
1456
            {
1457
                AngleValue = _ActualAngle;
1487 1458
            }
1488 1459
            #endregion
1489 1460

  
1490
            double dDeltaAngle = angle - AngleValue;
1491
            AngleValue = angle;
1492

  
1493 1461
            /// save rotatePoint
1494
            this.rotatePoint = pt;
1462
            this.RotatedPoint = pt;
1495 1463

  
1496 1464
            Dispatcher.BeginInvoke((Action)(() =>
1497 1465
            {
......
1559 1527

  
1560 1528
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1561 1529
        {            
1562
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1530
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1563 1531
            rotateTop.Cursor = Cursors.SizeAll;
1564 1532

  
1565 1533
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
......
1601 1569
        {
1602 1570
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1603 1571

  
1604

  
1605

  
1606 1572
            var comments = (from drawing in this.Members
1607 1573
                            select drawing.DrawingData as CommentUserInfo).ToList();
1608 1574
            UndoCommand.Instance.Push(comments, this.AngleValue, dBeforeAngle);

내보내기 Unified diff

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