本文整理汇总了C#中Shape.CalculateRelativePosition方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.CalculateRelativePosition方法的具体用法?C# Shape.CalculateRelativePosition怎么用?C# Shape.CalculateRelativePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.CalculateRelativePosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointPositions
public PointPositions(Shape shape, Shape owner)
: this() {
if (shape == null) throw new ArgumentNullException("shape");
if (owner == null) throw new ArgumentNullException("owner");
// First, store position of reference point
RelativePosition relativePos = RelativePosition.Empty;
relativePos = owner.CalculateRelativePosition(shape.X, shape.Y);
Debug.Assert(relativePos != RelativePosition.Empty);
items.Add(ControlPointId.Reference, relativePos);
// Then, store all resize control point positions as relative position
foreach (ControlPointId ptId in shape.GetControlPointIds(ControlPointCapabilities.Resize)) {
Point p = shape.GetControlPointPosition(ptId);
relativePos = owner.CalculateRelativePosition(p.X, p.Y);
Debug.Assert(relativePos != RelativePosition.Empty);
items.Add(ptId, relativePos);
}
}
示例2: CalcGluePointCalcInfo
private void CalcGluePointCalcInfo(ControlPointId gluePointId, Shape otherShape, ControlPointId otherPointId) {
// Calculate GluePoint position and AnchorPoint position
Point gluePtPos = GetControlPointPosition(gluePointId);
Point labelPos = Point.Empty;
labelPos.Offset(X, Y);
int labelAngle;
// Calculate target shape's outline intersection point and the relative position of the gluePoint in/on the target shape
float alpha = float.NaN, beta = float.NaN;
if (otherShape is ILinearShape) {
// ToDo: Check if the point is on the line, if not, calculate an intersection point
Point normalVector = ((ILinearShape)otherShape).CalcNormalVector(gluePtPos);
float shapeAngleDeg = Geometry.RadiansToDegrees(Geometry.Angle(gluePtPos.X, gluePtPos.Y, normalVector.X, normalVector.Y)) - 90;
alpha = 360 - shapeAngleDeg + Geometry.RadiansToDegrees(Geometry.Angle(gluePtPos, labelPos));
beta = Geometry.RadiansToDegrees(Geometry.Angle(labelPos, gluePtPos));
labelAngle = Angle - Geometry.DegreesToTenthsOfDegree(shapeAngleDeg);
} else if (otherShape is IPlanarShape) {
float shapeAngleDeg = Geometry.TenthsOfDegreeToDegrees(((IPlanarShape)otherShape).Angle);
alpha = 360 - shapeAngleDeg + Geometry.RadiansToDegrees(Geometry.Angle(gluePtPos, labelPos));
beta = Geometry.RadiansToDegrees(Geometry.Angle(labelPos, gluePtPos));
labelAngle = Angle - ((IPlanarShape)otherShape).Angle;
} else {
alpha = 360 - Geometry.RadiansToDegrees(Geometry.Angle(gluePtPos, labelPos));
beta = Geometry.RadiansToDegrees(Geometry.Angle(labelPos, gluePtPos));
labelAngle = Angle;
}
RelativePosition relativePos = otherShape.CalculateRelativePosition(gluePtPos.X, gluePtPos.Y);
float distance = Geometry.DistancePointPoint(gluePtPos, labelPos);
// Store all calculated values in the GluePointCalcInfo structure
this.calcInfo.Alpha = alpha % 360;
this.calcInfo.Beta = beta % 360;
this.calcInfo.Distance = distance;
this.calcInfo.RelativePosition = relativePos;
this.calcInfo.LabelAngle = labelAngle;
Debug.Assert(calcInfo != GluePointCalcInfo.Empty);
}