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


C# Rect.GetCenter方法代码示例

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


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

示例1: Apply

		public override Rect Apply(Rect oldDataRect, Rect newDataRect, Viewport2D viewport)
		{
			double ratio = newDataRect.Width / newDataRect.Height;
			double coeff = Math.Sqrt(ratio);

			double newWidth = newDataRect.Width / coeff;
			double newHeight = newDataRect.Height * coeff;

			Point center = newDataRect.GetCenter();
			Rect res = RectExtensions.FromCenterSize(center, newWidth, newHeight);
			return res;
		}
开发者ID:BdGL3,项目名称:CXPortal,代码行数:12,代码来源:ProportionsRestriction.cs

示例2: Apply

		public override Rect Apply(Rect oldDataRect, Rect newDataRect, Viewport2D viewport)
		{
			Rect output = viewport.Output;
			if (output.Width == 0 || output.Height == 0)
				return newDataRect;

			double screenRatio = output.Width / output.Height;
			double viewportRatio = newDataRect.Width / newDataRect.Height;
			double ratio = screenRatio / viewportRatio;
			double width = proportionRatio * newDataRect.Width * ratio;
			double height = newDataRect.Height;

			if (width < newDataRect.Width)
			{
				height = newDataRect.Height / proportionRatio / ratio;
				width = newDataRect.Width;
			}

			Point center = newDataRect.GetCenter();
			Rect res = RectExtensions.FromCenterSize(center, width, height);

			return res;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:23,代码来源:PhysicalProportionsResriction.cs

示例3: RectZoom

		public static Rect RectZoom(Rect rect, double ratio)
		{
			return RectZoom(rect, rect.GetCenter(), ratio);
		}
开发者ID:BdGL3,项目名称:CXPortal,代码行数:4,代码来源:CoordinateUtils.cs

示例4: Quadivide

        private static IEnumerable<Point> Quadivide(Rect area)
        {
            if (area.Width > 0 && area.Height > 0)
            {
                var center = area.GetCenter();

                var x = Math.Floor(center.X);
                var y = Math.Floor(center.Y);

                yield return new Point(x, y);

                var quad1 = new Rect(area.TopLeft, new Point(x, y + 1));
                var quad2 = new Rect(area.TopRight, new Point(x, y));
                var quad3 = new Rect(area.BottomLeft, new Point(x + 1, y + 1));
                var quad4 = new Rect(area.BottomRight, new Point(x + 1, y));

                var quads = new Queue<IEnumerator<Point>>();
                quads.Enqueue(Quadivide(quad1).GetEnumerator());
                quads.Enqueue(Quadivide(quad2).GetEnumerator());
                quads.Enqueue(Quadivide(quad3).GetEnumerator());
                quads.Enqueue(Quadivide(quad4).GetEnumerator());
                while (quads.Count > 0)
                {
                    var quad = quads.Dequeue();
                    if (quad.MoveNext())
                    {
                        yield return quad.Current;
                        quads.Enqueue(quad);
                    }
                }
            }
        }
开发者ID:Jlinc,项目名称:Test_SurfaceWPF,代码行数:32,代码来源:MultiScaleTileSource.cs

示例5: EnlargeRect

		protected Rect EnlargeRect(Rect rect)
		{
			Size newSize = rect.Size;
			newSize.Width += 1;
			newSize.Height += 1;
			Rect result = RectExtensions.FromCenterSize(rect.GetCenter(), newSize);
			return result;

			//double coeff = 1 + 1.0 / tileWidth;
			//return EnlargeRect(rect, coeff);
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:11,代码来源:Map.cs


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