프로젝트

일반

사용자정보

개정판 3b797b23

ID3b797b23e56459c63e208f4574fc75c9cd2f43ad
상위 5785141e
하위 36425a72, fd452a01

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

Fix: CircleControl 회전 적용 중...

Change-Id: I4711f5cc93af7158369d745d9efa765491060841

차이점 보기:

KCOM/Common/MathHelper.cs
11 11
    public static class MathHelper
12 12
    {
13 13

  
14
        /// <summary>
15
        /// p2를 기준으로 p1을 angle만큼 회전시킨다.
16
        /// </summary>
17
        /// <param name="p1"></param>
18
        /// <param name="p2"></param>
19
        /// <param name="angle">in degree</param>
20
        /// <returns></returns>
14 21
        public static Point RotatePoint(Point p1, Point p2, double angle)
15 22
        {
16

  
17
            //double radians = ConvertToRadians(angle);
18
            //double sin = Math.Sin(radians);
19
            //double cos = Math.Cos(radians);
20

  
21
            //// Translate point back to origin
22
            //p1.X -= p2.X;
23
            //p1.Y -= p2.Y;
24

  
25
            //// Rotate point
26
            //double xnew = p1.X * cos - p1.Y * sin;
27
            //double ynew = p1.X * sin + p1.Y * cos;
28

  
29
            //// Translate point back
30
            //Point newPoint = new Point((int)xnew + p2.X, (int)ynew + p2.Y);
31

  
32

  
33 23
            var transform = new RotateTransform() { Angle = angle, CenterX = p2.X, CenterY = p2.Y };
34 24
            var transformedPoint = transform.Transform(p1);
35 25

  
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
}
MarkupToPDF/Controls/Common/MathSet.cs
265 265

  
266 266
        public static Point getMiddlePoint(Point p1, Point p2)
267 267
        {
268
            return new Point { X = (p1.X + p2.X) / 2, Y = (p1.Y + p2.Y) / 2 };
268
            return new Point { X = (p1.X + p2.X) * 0.5, Y = (p1.Y + p2.Y) * 0.5 };
269 269
        }
270 270

  
271 271
        /// <summary>
......
327 327
            return new Point(getThePointX / count, getThePointY / count);
328 328
        }
329 329

  
330
        /// <summary>
331
        /// org 기준으로 dest를 dAngle(in degree)만큼 회전 시킨다.
332
        /// </summary>
333
        /// <param name="org"></param>
334
        /// <param name="dest"></param>
335
        /// <param name="dAngle"></param>
336
        /// <returns></returns>
330 337
        public static Point RotateAbout(Point org, Point dest, double dAngle)
331 338
        {
332 339
            double ptx = dest.X - org.X;
MarkupToPDF/Controls/Shape/CircleControl.cs
279 279
            get { return (double)GetValue(AngleProperty); }
280 280
            set { SetValue(AngleProperty, value); }
281 281
        }
282
        public double CommentAngle
282
        public override double CommentAngle
283 283
        {
284 284
            get { return (double)GetValue(AngleProperty); }
285 285
            set
......
360 360
            if (PropertyChanged != null)
361 361
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
362 362
        }
363
        
364
        /// <summary>
365
        /// Circle을 생성한다.
366
        /// </summary>
363 367
        private void SetCircle()
364 368
        {
365 369
            Base_CirclePath.StrokeDashArray.Clear();
......
371 375

  
372 376
            Point middle = MathSet.getMiddlePoint(this.EndPoint, this.StartPoint);
373 377

  
374
            instance.RadiusX = (MathSet.DistanceTo(this.LeftBottomPoint, this.EndPoint) / 2);
375
            instance.RadiusY = (MathSet.DistanceTo(this.EndPoint, this.TopRightPoint) / 2);
378
            instance.RadiusX = (MathSet.DistanceTo(this.LeftBottomPoint, this.EndPoint) * 0.5);
379
            instance.RadiusY = (MathSet.DistanceTo(this.EndPoint, this.TopRightPoint) * 0.5);
376 380
            instance.Center = middle;
381
            #region 회전 적용
382
            var rot = new RotateTransform(this.CommentAngle, middle.X, middle.Y);
383
            instance.Transform = rot;
384
            #endregion
385

  
377 386
            switch (this.Paint)
378 387
            {
379 388
                case PaintSet.None:
......
391 400
                    break;
392 401
            }
393 402

  
394

  
395 403
            CircleGroup.Children.Clear();
396 404
            CircleGroup.FillRule = FillRule.Nonzero;
397 405
            CircleGroup.Children.Add(instance);
406
            CircleGroup.Children.Add(new LineGeometry(this.StartPoint, this.LeftBottomPoint));
407
            CircleGroup.Children.Add(new LineGeometry(this.LeftBottomPoint, this.EndPoint));
408
            CircleGroup.Children.Add(new LineGeometry(this.EndPoint, this.TopRightPoint));
409
            CircleGroup.Children.Add(new LineGeometry(this.TopRightPoint, this.StartPoint));
398 410

  
399 411
            try
400 412
            {                
401
                //강인구 수정(원 테두리가 잘리는것 방지)
402
                //this.Width = Math.Abs(this.CircleGroup.Bounds.Right + 2);
403
                //this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + 2);
404
                this.Width = Math.Abs(this.CircleGroup.Bounds.Right + (this.LineSize / 2));
405
                this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + +(this.LineSize / 2)); 
413
                this.Width = Math.Abs(this.CircleGroup.Bounds.Right + (this.LineSize * 0.5));
414
                this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + +(this.LineSize * 0.5)); 
406 415
            }
407 416
            catch (Exception)
408 417
            {
409 418
                
410
            }            
419
            } 
420

  
411 421
            CenterX = Math.Abs(this.CircleGroup.Bounds.X / 2);
412 422
            CenterY = Math.Abs(this.CircleGroup.Bounds.Y / 2);
413 423
            this.PathData = CircleGroup;

내보내기 Unified diff

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