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


C# Shape.GetBoundingRectangle方法代码示例

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


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

示例1: ShapeInfoDialog

        /// <summary>
        /// Displays a dialog showing various information on the given shape:
        /// Template, shape type, shape library and the shape's control points including their capabilities and connected shapes.
        /// </summary>
        public ShapeInfoDialog(Project project, Shape shape)
        {
            if (project == null) throw new ArgumentNullException("project");
            if (shape == null) throw new ArgumentNullException("shape");
            InitializeComponent();

            this.project = project;

            Rectangle shapeBounds = shape.GetBoundingRectangle(false);
            this.shape = shape;
            this.shapeClone = shape.Clone();
            this.shapeClone.Fit(0, 0, shapeBounds.Width, shapeBounds.Height);

            this.diagram.Size = shapeBounds.Size;
            this.diagram.Shapes.Add(shapeClone);

            diagramSetController.Project = project;
            display.DrawDiagramSheet = false;
            display.Diagram = diagram;
            display.ShowGrid = false;
            display.GripSize = 5;
            display.HighQualityRendering = true;
            display.RenderingQualityHighQuality = RenderingQuality.MaximumQuality;
            display.CurrentTool = tool;

            UpdateShapeInfo();
        }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:31,代码来源:ShapeInfoDialog.cs

示例2: 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

示例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: CheckOwnerboundsUpdateNeeded

 private void CheckOwnerboundsUpdateNeeded(Shape shape)
 {
     if (!ownerBoundsUpdateNeeded) {
         Rectangle shapeBounds = shape.GetBoundingRectangle(true);
         if (shapeBounds.Left < 0 || owner.Width < shapeBounds.Right
             || shapeBounds.Top < 0 || owner.Height < shapeBounds.Bottom)
             ownerBoundsUpdateNeeded = true;
     }
 }
开发者ID:LudovicT,项目名称:NShape,代码行数:9,代码来源:Diagram.cs

示例5: 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="shapeOffsetX">Declares the distance, the shape is moved on X axis before finding snap point.</param>
		/// <param name="shapeOffsetY">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>
		/// <returns>Distance to the calculated snap point.</returns>
		protected float FindNearestSnapPoint(IDiagramPresenter diagramPresenter, Shape shape, int shapeOffsetX, int shapeOffsetY,
			out int snapDeltaX, out int snapDeltaY) {
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			if (shape == null) throw new ArgumentNullException("shape");

			snapDeltaX = snapDeltaY = 0;
			int snapDistance = diagramPresenter.SnapDistance;
			float lowestDistance = float.MaxValue;

			Rectangle shapeBounds = shape.GetBoundingRectangle(true);
			shapeBounds.Offset(shapeOffsetX, shapeOffsetY);
			int boundsCenterX = (int)Math.Round(shapeBounds.X + shapeBounds.Width / 2f);
			int boundsCenterY = (int)Math.Round(shapeBounds.Y + shapeBounds.Width / 2f);

			int dx, dy;
			float currDistance;
			// Calculate snap distance of center point
			currDistance = FindNearestSnapPoint(diagramPresenter, boundsCenterX, boundsCenterY, out dx, out dy);
			if (currDistance < lowestDistance && currDistance >= 0 && currDistance <= snapDistance) {
				lowestDistance = currDistance;
				snapDeltaX = dx;
				snapDeltaY = dy;
			}

			// Calculate snap distance of bounding rectangle
			currDistance = FindNearestSnapPoint(diagramPresenter, shapeBounds.Left, shapeBounds.Top, out dx, out dy);
			if (currDistance < lowestDistance && currDistance >= 0 && currDistance <= snapDistance) {
				lowestDistance = currDistance;
				snapDeltaX = dx;
				snapDeltaY = dy;
			}
			currDistance = FindNearestSnapPoint(diagramPresenter, shapeBounds.Right, shapeBounds.Top, out dx, out dy);
			if (currDistance < lowestDistance && currDistance >= 0 && currDistance <= snapDistance) {
				lowestDistance = currDistance;
				snapDeltaX = dx;
				snapDeltaY = dy;
			}
			currDistance = FindNearestSnapPoint(diagramPresenter, shapeBounds.Left, shapeBounds.Bottom, out dx, out dy);
			if (currDistance < lowestDistance && currDistance >= 0 && currDistance <= snapDistance) {
				lowestDistance = currDistance;
				snapDeltaX = dx;
				snapDeltaY = dy;
			}
			currDistance = FindNearestSnapPoint(diagramPresenter, shapeBounds.Right, shapeBounds.Bottom, out dx, out dy);
			if (currDistance < lowestDistance && currDistance >= 0 && currDistance <= snapDistance) {
				lowestDistance = currDistance;
				snapDeltaX = dx;
				snapDeltaY = dy;
			}
			return lowestDistance;
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:61,代码来源:Tool.cs

示例6: CopyFrom

		/// <override></override>
		public override void CopyFrom(Shape source)
		{
			base.CopyFrom(source);

			if (source is IPlanarShape) {
				IPlanarShape src = (IPlanarShape) source;
				// Copy regular properties
				this.angle = src.Angle;
				// Copy templated properties
				this.fillStyle = (Template != null && src.FillStyle == ((IPlanarShape) Template.Shape).FillStyle)
				                 	? null
				                 	: src.FillStyle;
			}
			if (source is ICaptionedShape) {
				// Copy as many captions as possible. Leave the rest untouched.
				int ownCaptionCnt = CaptionCount;
				int srcCaptionCnt = ((ICaptionedShape) source).CaptionCount;
				int cnt = Math.Min(ownCaptionCnt, srcCaptionCnt);
				for (int i = 0; i < cnt; ++i) {
					this.SetCaptionText(i, ((ICaptionedShape) source).GetCaptionText(i));
					this.SetCaptionCharacterStyle(i, ((ICaptionedShape) source).GetCaptionCharacterStyle(i));
					this.SetCaptionParagraphStyle(i, ((ICaptionedShape) source).GetCaptionParagraphStyle(i));
				}
			}
			if (source is ImageBasedShape) {
				w = ((ImageBasedShape) source).w;
				h = ((ImageBasedShape) source).h;
				if (((ImageBasedShape) source).image != null)
					image = (Image) ((ImageBasedShape) source).image.Clone();
			}
			else {
				Rectangle r = source.GetBoundingRectangle(true);
				Fit(r.X, r.Y, r.Width, r.Height);
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:36,代码来源:ImageBasedShape.cs


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