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


C# Shape.GetControlPointIds方法代码示例

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

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

示例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;
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:31,代码来源:RectangleShape.cs

示例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;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:10,代码来源:ConfigFiltersAndPatching-Tools.cs

示例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;
 }
开发者ID:LudovicT,项目名称:NShape,代码行数:10,代码来源:Layouter.cs

示例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;
 }
开发者ID:LudovicT,项目名称:NShape,代码行数:9,代码来源:ShapeAggregation.cs

示例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;
     }
 }
开发者ID:LudovicT,项目名称:NShape,代码行数:19,代码来源:ShapeAggregation.cs

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

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

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

示例11: ShapeHasGluePoint

		private bool ShapeHasGluePoint(Shape shape) {
			foreach (ControlPointId id in shape.GetControlPointIds(ControlPointCapabilities.Glue))
				return true;
			return false;
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:5,代码来源:Tool.cs

示例12: CountControlPoints

		private int CountControlPoints(Shape shape, ControlPointCapabilities pointCapability) {
			int result = 0;
			foreach (ControlPointId id in shape.GetControlPointIds(pointCapability))
				++result;
			return result;
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:6,代码来源:TemplatePresenter.cs


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