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


C# PointD.Offset方法代码示例

本文整理汇总了C#中PointD.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# PointD.Offset方法的具体用法?C# PointD.Offset怎么用?C# PointD.Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PointD的用法示例。


在下文中一共展示了PointD.Offset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostLayout

		/// <summary>
		/// Places each external constraint shape at the point corresponding to the average of all of its referenced shapes.
		/// Frequency constraints are handled differently, since they apply to only one fact type (but 1 or more roles in that
		/// fact type) at any time.
		/// </summary>
		/// <param name="minimumPoint">The minimum location for new element placement</param>
		public override void PostLayout(PointD minimumPoint)
		{
			ResolveReferences(myConstraintShapes);

			foreach (LayoutShape shape in myConstraintShapes)
			{
				if (!shape.Pinned)
				{
					PointD avg = new PointD(0, 0);
					NodeShape nodeShape = shape.Shape;
					FrequencyConstraintShape freqShape;
					FrequencyConstraint constraint;
					LinkedElementCollection<FactType> relatedFactTypes;
					int count;

					if (null != (freqShape = nodeShape as FrequencyConstraintShape) &&
						null != (constraint = freqShape.ModelElement as FrequencyConstraint) &&
						1 == (relatedFactTypes = constraint.FactTypeCollection).Count)
					{
						Diagram diagram = myDiagram;
						FactType factType = relatedFactTypes[0];
						FactTypeShape factTypeShape = null;
						LayoutShape factTypeLayoutShape = null;
						foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(factType))
						{
							FactTypeShape testShape = pel as FactTypeShape;
							if (testShape != null && testShape.Diagram == diagram)
							{
								if (factTypeShape == null)
								{
									factTypeShape = testShape;
								}
								if (myLayoutShapes.TryGetValue(testShape, out factTypeLayoutShape))
								{
									factTypeShape = testShape;
									break;
								}
							}
						}

						LinkedElementCollection<Role> constraintRoles = constraint.RoleCollection;
						LinkedElementCollection<RoleBase> displayOrder = factTypeShape.DisplayedRoleOrder;
						DisplayOrientation orientation = factTypeShape.DisplayOrientation;
						RectangleD shapeBounds = factTypeShape.AbsoluteBounds;
						SizeD shapeSize = factTypeShape.Size;
						PointD location = (factTypeLayoutShape != null) ? factTypeLayoutShape.TargetLocation : shapeBounds.Location;
						count = constraintRoles.Count;
						double width = shapeSize.Width;
						double height = shapeSize.Height;

						for (int i = 0; i < count; i++)
						{
							int targetIndex = displayOrder.IndexOf(constraintRoles[i]);
							switch (orientation)
							{
								case DisplayOrientation.Horizontal:
									avg.Offset((width / (targetIndex + 1)) + location.X, location.Y - height);
									break;
								case DisplayOrientation.VerticalRotatedRight:
									avg.Offset(location.X + width, (height / (targetIndex + 1)) + location.Y);
									break;
								case DisplayOrientation.VerticalRotatedLeft:
									avg.Offset(location.X + width, height - (height / (targetIndex + 1)) + location.Y);
									break;
							}
						}
						avg.X /= count;
						avg.Y /= count;
					}
					else if (0 != (count = shape.Count))
					{
						double minX = double.MaxValue;
						double minY = double.MaxValue;
						double maxX = 0;
						double maxY = 0;
						SizeD size;
						LayoutShapeList relatedShapes = shape.RelatedShapes;
						// Take the center of farthest bounds as the location.
						// This is the same as the average for two elements, but
						// balances more than two elements much better.
						for (int i = 0; i < count; ++i)
						{
							LayoutShape relatedShape = relatedShapes[i];
							PointD location = relatedShape.TargetLocation;
							size = relatedShape.Shape.Size;
							double x = location.X + size.Width / 2;
							double y = location.Y + size.Height / 2;
							minX = Math.Min(minX, x);
							minY = Math.Min(minY, y);
							maxX = Math.Max(maxX, x);
							maxY = Math.Max(maxY, y);
						}
						size = nodeShape.Size;
						avg.X = (maxX + minX) / 2 - size.Width / 2;
//.........这里部分代码省略.........
开发者ID:cjheath,项目名称:NORMA,代码行数:101,代码来源:ORMLayoutEngines.cs


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