当前位置: 首页>>代码示例>>C#>>正文


C# Shape.CalculateRelativePosition方法代码示例

本文整理汇总了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);
				}
			}
开发者ID:jestonitiro,项目名称:nshape,代码行数:17,代码来源:ShapeAggregation.cs

示例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);
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:38,代码来源:TextShape.cs


注:本文中的Shape.CalculateRelativePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。