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


C# IViewport.ScreenToWorld方法代码示例

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


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

示例1: Pan

 public static void Pan(IViewport transform, Point currentMap, Point previousMap)
 {
   var current = transform.ScreenToWorld(currentMap.X, currentMap.Y);
   var previous = transform.ScreenToWorld(previousMap.X, previousMap.Y);
   var diffX = previous.X - current.X;
   var diffY = previous.Y - current.Y;
   transform.Center = new Point(transform.Center.X + diffX, transform.Center.Y + diffY);
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:8,代码来源:MapTransformHelpers.cs

示例2: ConvertPointBoundingBox

        public static CGRect ConvertPointBoundingBox(SymbolStyle symbolStyle, BoundingBox boundingBox, IViewport viewport)
        {
            var screenMin = viewport.WorldToScreen(boundingBox.Min);
            var screenMax = viewport.WorldToScreen(boundingBox.Max);

            //boundingBox.Offset = symbolStyle.SymbolOffset;
            //var newMin = boundingBox.Min;
            //var newMax = boundingBox.Max;

            if (symbolStyle.SymbolOffset != null)
            {
                screenMin = new Geometries.Point(
                    screenMin.X - symbolStyle.SymbolOffset.X,
                    screenMin.Y - symbolStyle.SymbolOffset.Y);
                screenMax = new Geometries.Point(
                    screenMax.X - symbolStyle.SymbolOffset.X,
                    screenMax.Y - symbolStyle.SymbolOffset.Y);

                var w = viewport.ScreenToWorld(screenMin);

                boundingBox.Offset(new Geometries.Point(w.X - boundingBox.MinX, w.Y - boundingBox.MinY));

                screenMin = viewport.WorldToScreen(boundingBox.Min);
                screenMax = viewport.WorldToScreen(boundingBox.Max);
            }

            var min = new Geometries.Point(screenMin.X - (32 / 2), screenMax.Y - (32 / 2)); //!!!
            var max = new Geometries.Point((min.X + 32), (min.Y + 32)); //!!!

            var frame = RoundToPixel(min, max);
            //if(symbolStyle.SymbolOffset != null)
            //	frame.Offset ((float)symbolStyle.SymbolOffset.X, (float)symbolStyle.SymbolOffset.Y);

            return frame;
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:35,代码来源:GeometryRenderer.cs

示例3: CenterClusters

		/*
		public static void CenterClusters(IEnumerable<Cluster> clusters, IViewport viewport)
		{
			foreach (var cluster in clusters)
			{
				var feature = cluster.Features.FirstOrDefault ();
				var center = cluster.Box.GetCentroid ();

				var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
				var style = styles.FirstOrDefault () as SymbolStyle;

				var min = viewport.WorldToScreen (cluster.Box.Left, cluster.Box.Bottom);
				var max = viewport.WorldToScreen (cluster.Box.Right, cluster.Box.Top);
				//style.Width = .Width;
				//style.Height = cluster.Box.Height;

				var size = (int)Math.Min ((max.X - min.X), (min.Y - max.Y));

				//Console.WriteLine ("Size = " + size);
				//style.Width = size;
				//style.Height = size;

				feature.Geometry = center;

				//var fCenter = firstFeature.Geometry.GetBoundingBox ().GetCentroid ();
				//if(fCenter.X == cluster.Box.GetCentroid().X)
			}
		}
		*/

		private static BoundingBox GetFeatureBoundingBox(IFeature feature, 
		                                   IViewport viewport)
		{
			var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
			var symbolStyle = styles.FirstOrDefault () as SymbolStyle;
			var boundingBox = feature.Geometry.GetBoundingBox ();
			//var width = style.Width;

			//var frame = GeometryRenderer.ConvertPointBoundingBox (style, feature.Geometry.GetBoundingBox (), viewport); 
			var screenMin = viewport.WorldToScreen(boundingBox.Min);
			var screenMax = viewport.WorldToScreen(boundingBox.Max);

			var min = new Mapsui.Geometries.Point(screenMin.X - (symbolStyle.Width / 2), screenMax.Y - (symbolStyle.Height / 2));
			var max = new Mapsui.Geometries.Point((min.X + symbolStyle.Width), (min.Y + symbolStyle.Height));
	
			var x = min.X;
			var y = min.Y;
			var width = max.X - min.X;
			var height = max.Y - min.Y;

			var frame = new RectangleF((float)x, (float)y, (float)width, (float)height);

			var nmin = viewport.ScreenToWorld (frame.Left, frame.Bottom);
			var nmax = viewport.ScreenToWorld (frame.Right, frame.Top);


			var bb = new BoundingBox (nmin, nmax);


			return bb;
		}
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:61,代码来源:SymbolRenderer.cs

示例4: MapToWorld

 public static Geometries.BoundingBox MapToWorld(Geometries.BoundingBox box, IViewport view)
 {
     Geometries.Point lowerLeft = view.ScreenToWorld(box.BottomLeft);
     Geometries.Point upperRight = view.ScreenToWorld(box.TopRight);
     return new Geometries.BoundingBox(lowerLeft, upperRight);
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:6,代码来源:MapTransformHelper.cs


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