개정판 d2114d3b
issue #923: add OnMoveCtrlPoint method to interface
Change-Id: If3b10f5b54eaecd8bd8fa299d702e70e05d4b97e
MarkupToPDF/Controls/Shape/RectCloudControl.cs | ||
---|---|---|
582 | 582 |
} |
583 | 583 |
|
584 | 584 |
/// <summary> |
585 |
/// move control point has same location of given pt along given delta |
|
586 |
/// </summary> |
|
587 |
/// <author>humkyung</author> |
|
588 |
/// <date>2019.06.20</date> |
|
589 |
/// <param name="pt"></param> |
|
590 |
/// <param name="dx"></param> |
|
591 |
/// <param name="dy"></param> |
|
592 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy) |
|
593 |
{ |
|
594 |
IPath path = (this as IPath); |
|
595 |
|
|
596 |
Point selected = MathSet.getNearPoint(path.PointSet, pt); |
|
597 |
selected.X += dx; |
|
598 |
selected.Y += dy; |
|
599 |
int i = 0; |
|
600 |
for (i = 0; i < (this as IPath).PointSet.Count; i++) |
|
601 |
{ |
|
602 |
if (pt.Equals((this as IPath).PointSet[i])) |
|
603 |
{ |
|
604 |
(this as IPath).PointSet[i] = selected; |
|
605 |
break; |
|
606 |
} |
|
607 |
} |
|
608 |
|
|
609 |
var ReverseP = (i + path.PointSet.Count() / 2) % path.PointSet.Count(); |
|
610 |
var PreviousP = (i + (path.PointSet.Count() - 1)) % path.PointSet.Count(); |
|
611 |
var NextP = (i + 1) % path.PointSet.Count(); |
|
612 |
|
|
613 |
var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]); |
|
614 |
|
|
615 |
var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]); |
|
616 |
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, |
|
617 |
path.PointSet[i].Y - path.PointSet[ReverseP].Y); |
|
618 |
path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet |
|
619 |
[ReverseP].Y + PreviousV.Y * l); |
|
620 |
|
|
621 |
var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]); |
|
622 |
l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet |
|
623 |
[i].Y - path.PointSet[ReverseP].Y); |
|
624 |
path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l); |
|
625 |
|
|
626 |
this.updateControl(); |
|
627 |
} |
|
628 |
|
|
629 |
/// <summary> |
|
585 | 630 |
/// return rectcloudcontrols' area |
586 | 631 |
/// </summary> |
587 | 632 |
/// <author>humkyung</author> |
내보내기 Unified diff