本文整理汇总了C#中Shape.GetControlPointIds方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.GetControlPointIds方法的具体用法?C# Shape.GetControlPointIds怎么用?C# Shape.GetControlPointIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.GetControlPointIds方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFrom
/// <override></override>
public override void CopyFrom(Shape source)
{
base.CopyFrom(source);
// Copy size if the source is a DiameterShape
if (source is DiameterShapeBase)
internalDiameter = ((DiameterShapeBase) source).DiameterInternal;
else {
// If not, try to calculate the size a good as possible
Rectangle srcBounds = Geometry.InvalidRectangle;
if (source is PathBasedPlanarShape) {
PathBasedPlanarShape src = (PathBasedPlanarShape) source;
// Calculate the bounds of the (unrotated) resize handles because with
// GetBoundingRectangle(), we receive the bounds including the children's bounds
List<Point> pointBuffer = new List<Point>();
int centerX = src.X;
int centerY = src.Y;
float angleDeg = Geometry.TenthsOfDegreeToDegrees(-src.Angle);
foreach (ControlPointId id in source.GetControlPointIds(ControlPointCapabilities.Resize))
pointBuffer.Add(Geometry.RotatePoint(centerX, centerY, angleDeg, source.GetControlPointPosition(id)));
Geometry.CalcBoundingRectangle(pointBuffer, out srcBounds);
}
else {
// Generic approach: try to fit into the bounding rectangle
srcBounds = source.GetBoundingRectangle(true);
}
//
// Calculate new size
if (Geometry.IsValid(srcBounds)) {
float scale = Geometry.CalcScaleFactor(DiameterInternal, DiameterInternal, srcBounds.Width, srcBounds.Height);
DiameterInternal = (int) Math.Round(DiameterInternal*scale);
}
}
}
示例2: 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);
}
}
示例3: CopyFrom
/// <override></override>
public override void CopyFrom(Shape source)
{
base.CopyFrom(source);
if (source is RectangleBase) {
size.Width = ((RectangleBase) source).Width;
size.Height = ((RectangleBase) source).Height;
}
else {
// If not, try to calculate the size a good as possible
Rectangle srcBounds = Geometry.InvalidRectangle;
if (source is PathBasedPlanarShape) {
PathBasedPlanarShape src = (PathBasedPlanarShape) source;
// Calculate the bounds of the (unrotated) resize handles because with
// GetBoundingRectangle(), we receive the bounds including the children's bounds
List<Point> pointBuffer = new List<Point>();
int centerX = src.X;
int centerY = src.Y;
float angleDeg = Geometry.TenthsOfDegreeToDegrees(-src.Angle);
foreach (ControlPointId id in source.GetControlPointIds(ControlPointCapabilities.Resize))
pointBuffer.Add(Geometry.RotatePoint(centerX, centerY, angleDeg, source.GetControlPointPosition(id)));
Geometry.CalcBoundingRectangle(pointBuffer, out srcBounds);
}
else {
// Generic approach: try to fit into the bounding rectangle
srcBounds = source.GetBoundingRectangle(true);
}
if (Geometry.IsValid(srcBounds))
size = srcBounds.Size;
}
}
示例4: IsConnectedToNonSelectedShape
private bool IsConnectedToNonSelectedShape(IDiagramPresenter diagramPresenter, Shape shape)
{
foreach (ControlPointId gluePointId in shape.GetControlPointIds(ControlPointCapabilities.Glue)) {
ShapeConnectionInfo sci = shape.GetConnectionInfo(gluePointId, null);
if (!sci.IsEmpty
&& !diagramPresenter.SelectedShapes.Contains(sci.OtherShape))
return true;
}
return false;
}
示例5: ExcludeFromFitting
// There are lines without glue points (SwitchBar) and planar shapes with glue points (Label)
// so we better check on glue points here...
/// <ToBeCompleted></ToBeCompleted>
protected bool ExcludeFromFitting(Shape shape)
{
foreach (ControlPointId pointId in shape.GetControlPointIds(ControlPointCapabilities.Glue)) {
if (shape.IsConnected(pointId, null) != ControlPointId.None) return true;
}
return false;
}
示例6: GetShapeAnchorPoints
private IEnumerable<ControlPointId> GetShapeAnchorPoints(Shape shape)
{
if (shape == null) throw new ArgumentNullException("shape");
// First, (re)store position of reference point
yield return ControlPointId.Reference;
// Then, (re)store positions of all other resize points
foreach (ControlPointId id in shape.GetControlPointIds(ControlPointCapabilities.Resize))
yield return id;
}
示例7: GetGluePointState
private GluePointState GetGluePointState(Shape shape)
{
int gluePtCnt = 0, connectedGluePtCnt = 0;
foreach (ControlPointId gluePtId in shape.GetControlPointIds(ControlPointCapabilities.Glue)) {
++gluePtCnt;
if (shape.IsConnected(gluePtId, null) != ControlPointId.None)
++gluePtCnt;
}
// Skip shapes connected with all glue points as they will move with their partner shape
if (gluePtCnt == 0)
return GluePointState.HasNone;
else {
if (connectedGluePtCnt == 0)
return GluePointState.NoneConnected;
if (connectedGluePtCnt == gluePtCnt)
return GluePointState.AllConnected;
else return GluePointState.SomeConnected;
}
}
示例8: CountControlPoints
private int CountControlPoints(Shape shape) {
if (shape == null) throw new ArgumentNullException("shape");
int result = 0;
foreach (ControlPointId id in shape.GetControlPointIds(ControlPointCapabilities.All))
++result;
return result;
}
示例9: FindNearestSnapPoint
/// <summary>
/// Finds the nearest SnapPoint in range of the given shape.
/// </summary>
/// <param name="diagramPresenter">The <see cref="T:Dataweb.NShape.Controllers.IDiagramPresenter" /></param>
/// <param name="shape">The shape for which the nearest snap point is searched.</param>
/// <param name="pointOffsetX">Declares the distance, the shape is moved on X axis before finding snap point.</param>
/// <param name="pointOffsetY">Declares the distance, the shape is moved on X axis before finding snap point.</param>
/// <param name="snapDeltaX">Horizontal distance between ptX and the nearest snap point.</param>
/// <param name="snapDeltaY">Vertical distance between ptY and the nearest snap point.</param>
/// <param name="controlPointCapability">Filter for control points taken into
/// account while calculating the snap distance.</param>
/// <returns>Control point of the shape, the calculated distance refers to.</returns>
protected ControlPointId FindNearestSnapPoint(IDiagramPresenter diagramPresenter, Shape shape, int pointOffsetX, int pointOffsetY,
out int snapDeltaX, out int snapDeltaY, ControlPointCapabilities controlPointCapability) {
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
if (shape == null) throw new ArgumentNullException("shape");
snapDeltaX = snapDeltaY = 0;
ControlPointId result = ControlPointId.None;
int snapDistance = diagramPresenter.SnapDistance;
float lowestDistance = float.MaxValue;
foreach (ControlPointId ptId in shape.GetControlPointIds(controlPointCapability)) {
int dx, dy;
float currDistance = FindNearestSnapPoint(diagramPresenter, shape, ptId, pointOffsetX, pointOffsetY, out dx, out dy);
if (currDistance < lowestDistance && currDistance >= 0 && currDistance <= snapDistance) {
lowestDistance = currDistance;
result = ptId;
snapDeltaX = dx;
snapDeltaY = dy;
}
}
return result;
}
示例10: DeletePreviewShape
/// <summary>
/// Disconnect, disposes and deletes the given preview <see cref="T:Dataweb.NShape.Advanced.Shape" />.
/// </summary>
/// <param name="shape"></param>
protected void DeletePreviewShape(ref Shape shape) {
if (shape != null) {
// Disconnect all existing connections (disconnects model, too)
foreach (ControlPointId pointId in shape.GetControlPointIds(ControlPointCapabilities.Connect | ControlPointCapabilities.Glue)) {
ControlPointId otherPointId = shape.IsConnected(pointId, null);
if (otherPointId != ControlPointId.None) shape.Disconnect(pointId);
}
// Delete model obejct
if (shape.ModelObject != null)
shape.ModelObject = null;
// Delete shape
shape.Invalidate();
shape.Dispose();
shape = null;
}
}
示例11: ShapeHasGluePoint
private bool ShapeHasGluePoint(Shape shape) {
foreach (ControlPointId id in shape.GetControlPointIds(ControlPointCapabilities.Glue))
return true;
return false;
}
示例12: CountControlPoints
private int CountControlPoints(Shape shape, ControlPointCapabilities pointCapability) {
int result = 0;
foreach (ControlPointId id in shape.GetControlPointIds(pointCapability))
++result;
return result;
}