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