프로젝트

일반

사용자정보

개정판 3b797b23

ID3b797b23e56459c63e208f4574fc75c9cd2f43ad
상위 5785141e
하위 36425a72, fd452a01

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

Fix: CircleControl 회전 적용 중...

Change-Id: I4711f5cc93af7158369d745d9efa765491060841

차이점 보기:

KCOM/Controls/AdornerFinal.xaml.cs
33 33
            this.MouseLeave += MyThumb_MouseLeave;
34 34
        }
35 35

  
36
        /// <summary>
37
        /// translate thumb with given delta and angle
38
        /// </summary>
39
        /// <param name="e"></param>
40
        /// <param name="angle"></param>
41
        public void Translate_old(double dx, double dy, double angle)
42
        {
43
            double radian = angle * Math.PI / 180;
44
            double cos = Math.Cos(radian);
45
            double sin = Math.Sin(radian);
46

  
47
            double _dx = dx * cos - dy * sin;
48
            double _dy = dx * sin + dy * cos;
49

  
50
            Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx);
51
            Canvas.SetTop(this, Canvas.GetTop(this) + _dy);
52
        }
53

  
54 36
        public void Translate(double dx, double dy, double angle)
55 37
        {
56 38
            var ratotePoint = MathHelper.RotatePoint(new Point(dx, dy), new Point(), angle);
......
104 86
                Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
105 87
            }
106 88

  
107
            if (this.DrawingData as ArrowTextControl != null)
89
            if (this.DrawingData is ArrowTextControl ArrowTextCtrl)
108 90
            {
109
                if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
91
                if (!ArrowTextCtrl.isTrans) //trans가 True인경우
110 92
                {
111 93
                    List<Point> ps = new List<Point>();
112 94

  
......
388 370
            BorderUpdate();
389 371
        }
390 372

  
373
        
374
        private void ViewBoxRotate(UIElement member)
375
        {
376
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
377
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
378
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
379
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
380
        }
381

  
391 382
        /// <summary>
392 383
        /// UIElement를 종류에 맞게 등록시킴
393 384
        /// </summary>
......
428 419
                    AngleValue = (member as ArrowTextControl).CommentAngle;
429 420

  
430 421
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
431
                    
422

  
432 423
                    //Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
433 424
                    //{
434 425
                    //    TextCompensation = false;
......
547 538
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
548 539
        }
549 540

  
550
        private void ViewBoxRotate(UIElement member)
551
        {
552
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
553
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
554
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
555
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
556
        }
557 541

  
558 542
        public void SetAdornerMember(List<CommentUserInfo> members)
559 543
        {
......
695 679

  
696 680
            if (this.Members.Count == 1)
697 681
            {
698
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
682
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
699 683
                {
700
                    if ((this.Members.First().DrawingData as TextControl).CommentAngle != 0)
684
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
701 685
                    {
702
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
703
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
686
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
687
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
704 688
                    }
705 689
                    else
706 690
                    {
......
709 693
                    }
710 694
                }
711 695
            }
696

  
712 697
            foreach (var item in this.Members)
713 698
            {
714 699
                UIElement currentControl = (item as AdornerMember).DrawingData;
......
796 781
                    if (rt.Right > maxX) maxX = rt.Right;
797 782
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
798 783
                }
799
                else if ((currentControl as CircleControl) != null)
800
                {                    
801
                    List<Point> am = (currentControl as IPath).PointSet;
802
                    List<double> xSet = am.Select(p => p.X).ToList();
803
                    List<double> ySet = am.Select(p => p.Y).ToList();
804
                    if (xSet.Min() < minX) minX = xSet.Min();
805
                    if (ySet.Min() < minY) minY = ySet.Min();
806
                    if (xSet.Max() > maxX) maxX = xSet.Max();
807
                    if (ySet.Max() > maxY) maxY = ySet.Max();
784
                else if (currentControl is CircleControl CircleCtrl)
785
                {
786
                    List<Point> am = CircleCtrl.PointSet;
787
                    minX = am.Min(x => x.X);
788
                    minY = am.Min(x => x.Y);
789
                    maxX = am.Max(x => x.X);
790
                    maxY = am.Max(x => x.Y);
808 791
                }
809 792
                else
810 793
                {
......
859 842
                Canvas.SetTop(DragThumb, minY);
860 843
            }
861 844
        }
845

  
862 846
        /// <summary>
863 847
        /// UIElement 해제
864 848
        /// </summary>
......
881 865
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
882 866
        {
883 867
            int count = 0;
884
            double Minx = 100000000;
885
            double Miny = 100000000;
886 868
            List<Point> list = (member as IPath).PointSet;
887 869
            if (member.GetType().Name == "InkControl")
888 870
            {
......
892 874
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
893 875
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
894 876
            }
895
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
896
            foreach (var ax in list)
897
            {
898
                Minx = (ax.X < Minx) ? ax.X : Minx;
899
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
900
            }
901
            for (int i = 0; i < list.Count(); i++)
877
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
878
            double Minx = list.Min(x => x.X);
879
            double Miny = list.Min(x => x.Y);
880

  
881
            for (int i = 0; i < list.Count; i++)
902 882
            {
903 883
                MyThumb tm = new MyThumb
904 884
                {
......
922 902
                    {
923 903
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
924 904

  
925

  
926 905
                        switch (Math.Abs(temp.CommentAngle).ToString())
927 906
                        {
928 907
                            case "90":
......
1473 1452
            Point pt = Mouse.GetPosition(this);
1474 1453

  
1475 1454
            #region X축 기준으로 회전 각도를 구한다.
1476
            Point vec1 = new Point(1, 0);
1477
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1478
            double angle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1455
            Vector AxisY = new Vector(0, 1);
1456
            Vector vec2 = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1457
            vec2.Normalize();
1458
            double angle = Vector.AngleBetween(AxisY, vec2);
1479 1459
            if (angle > 360) angle -= 360;
1480 1460
            if (angle < 0) angle += 360;
1481 1461
            #endregion
......
1493 1473
            /// save rotatePoint
1494 1474
            this.rotatePoint = pt;
1495 1475

  
1496

  
1497 1476
            Dispatcher.BeginInvoke((Action)(() =>
1498 1477
            {
1499 1478
                foreach (var member in this.Members)
......
1564 1543
            rotateTop.Cursor = Cursors.SizeAll;
1565 1544

  
1566 1545
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1567
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1546
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1568 1547
            {
1569
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).CommentAngle;
1548
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1570 1549
            }
1571 1550
            /// up to here
1572 1551

  
......
1664 1643
        {
1665 1644
            if (e.ClickCount == 2 && this.Members.Count == 1)
1666 1645
            {
1667

  
1668 1646
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1669 1647
                {
1670 1648
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
......
1779 1757

  
1780 1758
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1781 1759
        {
1782
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1760
            if ((this.Members[0] as AdornerMember).DrawingData.GetType().Name == "TextControl" 
1761
                || (this.Members[0] as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1783 1762
            {
1784 1763
                DragThumb.Visibility = Visibility.Collapsed;
1785 1764
            }
1786 1765
        }
1787

  
1788 1766
    }
1789 1767
}

내보내기 Unified diff

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