개정판 d2114d3b
issue #923: add OnMoveCtrlPoint method to interface
Change-Id: If3b10f5b54eaecd8bd8fa299d702e70e05d4b97e
MarkupToPDF/Controls/Etc/ImgControl.cs | ||
---|---|---|
366 | 366 |
} |
367 | 367 |
|
368 | 368 |
/// <summary> |
369 |
/// move control point has same location of given pt along given delta |
|
370 |
/// </summary> |
|
371 |
/// <author>humkyung</author> |
|
372 |
/// <date>2019.06.20</date> |
|
373 |
/// <param name="pt"></param> |
|
374 |
/// <param name="dx"></param> |
|
375 |
/// <param name="dy"></param> |
|
376 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy) |
|
377 |
{ |
|
378 |
IPath path = (this as IPath); |
|
379 |
|
|
380 |
Point selected = MathSet.getNearPoint(path.PointSet, pt); |
|
381 |
selected.X += dx; |
|
382 |
selected.Y += dy; |
|
383 |
int i = 0; |
|
384 |
for (i = 0; i < (this as IPath).PointSet.Count; i++) |
|
385 |
{ |
|
386 |
if (pt.Equals((this as IPath).PointSet[i])) |
|
387 |
{ |
|
388 |
path.PointSet[i] = selected; |
|
389 |
break; |
|
390 |
} |
|
391 |
} |
|
392 |
|
|
393 |
var ReverseP = (i + path.PointSet.Count() / 2) % path.PointSet.Count(); |
|
394 |
var PreviousP = (i + (path.PointSet.Count() - 1)) % path.PointSet.Count(); |
|
395 |
var NextP = (i + 1) % path.PointSet.Count(); |
|
396 |
|
|
397 |
var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]); |
|
398 |
|
|
399 |
var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]); |
|
400 |
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, |
|
401 |
path.PointSet[i].Y - path.PointSet[ReverseP].Y); |
|
402 |
path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet[ReverseP].Y + PreviousV.Y * l); |
|
403 |
|
|
404 |
var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]); |
|
405 |
l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet |
|
406 |
[i].Y - path.PointSet[ReverseP].Y); |
|
407 |
path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l); |
|
408 |
|
|
409 |
this.updateControl(); |
|
410 |
} |
|
411 |
|
|
412 |
/// <summary> |
|
369 | 413 |
/// return ImgControl's area |
370 | 414 |
/// </summary> |
371 | 415 |
/// <author>humkyung</author> |
내보내기 Unified diff