本文整理汇总了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;
//.........这里部分代码省略.........