프로젝트

일반

사용자정보

개정판 d2114d3b

IDd2114d3b43eba86003919f41890e541e9e88a4ba
상위 6b518442
하위 018e77ac

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

issue #923: add OnMoveCtrlPoint method to interface

Change-Id: If3b10f5b54eaecd8bd8fa299d702e70e05d4b97e

차이점 보기:

MarkupToPDF/Controls/Shape/CircleControl.cs
458 458
        }
459 459

  
460 460
        /// <summary>
461
        /// move control point has same location of given pt along given delta
462
        /// </summary>
463
        /// <author>humkyung</author>
464
        /// <date>2019.06.20</date>
465
        /// <param name="pt"></param>
466
        /// <param name="dx"></param>
467
        /// <param name="dy"></param>
468
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy)
469
        {
470
            IPath path = (this as IPath);
471
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
472
            selected.X += dx;
473
            selected.Y += dy;
474
            int i = 0;
475
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
476
            {
477
                if (pt.Equals((this as IPath).PointSet[i]))
478
                {
479
                    (this as IPath).PointSet[i] = selected;
480
                    break;
481
                }
482
            }
483

  
484
            List<Point> newPointSet = new List<Point> { };
485
            Point middle = new Point(path.PathData.Bounds.X + path.PathData.Bounds.Width * 0.5, path.PathData.Bounds.Y + path.PathData.Bounds.Height * 0.5);
486
            foreach (Point _pt in path.PointSet)
487
            {
488
                newPointSet.Add(_pt);
489
            }
490
            var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
491
            var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
492
            var NextP = (i + 1) % newPointSet.Count();
493
            var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
494
            var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
495
            var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
496
                newPointSet[i].Y - newPointSet[ReverseP].Y);
497
            newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
498
                + PreviousV.Y * l);
499

  
500
            var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
501
            l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
502
                - newPointSet[ReverseP].Y);
503
            newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
504

  
505
            path.PointSet = newPointSet;
506
            this.updateControl();
507
        }
508

  
509
        /// <summary>
461 510
        /// return circlecontrols' area
462 511
        /// </summary>
463 512
        /// <author>humkyung</author>

내보내기 Unified diff

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