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


C# IViewport类代码示例

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


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

示例1: Draw

        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var polygon = (Polygon)geometry;

            float lineWidth = 1;
            var lineColor = Color.Black; // default
            var fillColor = Color.Gray; // default

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float) vectorStyle.Outline.Width;
                lineColor = vectorStyle.Outline.Color;
                fillColor = vectorStyle.Fill?.Color;
            }

            using (var path = ToSkia(viewport, polygon))
            {
                using (var paint = new SKPaint())
                {
                    paint.IsAntialias = true;
                    paint.StrokeWidth = lineWidth;

                    paint.Style = SKPaintStyle.Fill;
                    paint.Color = fillColor.ToSkia();
                    canvas.DrawPath(path, paint);
                    paint.Style = SKPaintStyle.Stroke;
                    paint.Color = lineColor.ToSkia();
                    canvas.DrawPath(path, paint);
                }
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:33,代码来源:PolygonRenderer.cs

示例2: DrawPolygon

        public static void DrawPolygon(Graphics graphics, Polygon pol, Brush brush, Pen pen, IViewport viewport)
        {
            if (pol.ExteriorRing == null) return;
            if (pol.ExteriorRing.Vertices.Count <= 2) return;

            //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
            var gp = new GraphicsPath();

            //Add the exterior polygon
            var points = GeometryRenderer.WorldToScreenGDI(pol.ExteriorRing, viewport);
            if (points.Length > 2)
                gp.AddPolygon(points);
            //Add the interior polygons (holes)
            foreach (LinearRing linearRing in pol.InteriorRings)
            {
                var interiorPoints = GeometryRenderer.WorldToScreenGDI(linearRing, viewport);
                if (interiorPoints.Length > 2)
                    gp.AddPolygon(interiorPoints);
            }

            if (gp.PointCount == 0) return;

            // Only render inside of polygon if the brush isn't null or isn't transparent
            if (brush != null && brush != Brushes.Transparent)
                graphics.FillPath(brush, gp);
            // Create an outline if a pen style is available
            if (pen != null)
                graphics.DrawPath(pen, gp);
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:29,代码来源:PolygonRenderer.cs

示例3: Tick

		public void Tick (IViewport viewport, AGS.API.Size roomSize, AGS.API.Size virtualResoution, bool resetPosition)
		{
			IObject target = Target == null ? null : Target();
			if (!Enabled || target == null) return;

			setScale(target, viewport, resetPosition);

			//todo: Allow control over which point in the target to follow
			float targetX = target.X;//target.CenterPoint == null ? target.X : target.CenterPoint.X;
			float targetY = target.Y;//target.CenterPoint == null ? target.Y : target.CenterPoint.Y;
			float maxResolutionX = virtualResoution.Width / viewport.ScaleX;
			float maxResolutionY = virtualResoution.Height / viewport.ScaleY;
			targetX = getTargetPos(targetX, roomSize.Width, maxResolutionX);
			targetY = getTargetPos(targetY, roomSize.Height, maxResolutionY);
			if (resetPosition)
			{
				viewport.X = targetX;
				viewport.Y = targetY;
				return;
			}
			float newX = getPos (viewport.X, targetX, StartSpeedX, 0.1f, ref _speedX);
			float newY = getPos (viewport.Y, targetY, StartSpeedY, 0.1f, ref _speedY);
			viewport.X = clamp(newX, roomSize.Width, maxResolutionX);
			viewport.Y = clamp(newY, roomSize.Height, maxResolutionY);
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:25,代码来源:AGSCamera.cs

示例4: Draw

        public static void Draw(IViewport viewport, IStyle style, IFeature feature, IDictionary<object, TextureInfo> TextureCache, long currentIteration)
        {
            try
            {
                var raster = (IRaster)feature.Geometry;

                TextureInfo textureInfo;

                if (!TextureCache.Keys.Contains(raster))
                {
                    textureInfo = TextureHelper.LoadTexture(raster.Data);
                    TextureCache[raster] = textureInfo;
                }
                else
                {
                    textureInfo = TextureCache[raster];
                }

                textureInfo.IterationUsed = currentIteration;
                TextureCache[raster] = textureInfo;
                var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                TextureHelper.RenderTexture(textureInfo.TextureId, ToVertexArray(RoundToPixel(destination)));
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:28,代码来源:RasterRenderer.cs

示例5: RenderFeaturesForLayer

		private static string RenderFeaturesForLayer(IViewport viewport, ILayer layer)
		{
			if (layer.Enabled == false) return null;

			/*
			if (layer is BasicLayer) {
				var renderedFeatures = SymbolRenderer.RenderStackedLabelLayer (viewport, layer as BasicLayer);

				if (renderedFeatures != null && renderedFeatures.Count > 0){
					renderQueue.PutLayer (layer.Name, renderedFeatures);
					return layer.Name;
				}
			}
			else*/ if (layer is LabelLayer) {
				var renderedFeatures = LabelRenderer.RenderStackedLabelLayer (viewport, layer as LabelLayer);

				if (renderedFeatures != null && renderedFeatures.Count > 0){
					renderQueue.PutLayer (layer.Name, renderedFeatures);
					return layer.Name;
				}
			} else {
				var renderedFeatures = RenderVectorLayerFeatures (viewport, layer);// new List<CALayer> ();

				if (renderedFeatures != null && renderedFeatures.Count > 0){
					//renderQueue.PutLayer (layer.Name, renderedFeatures);
					_featuresForLayer.Add(layer.Name, renderedFeatures);
					return layer.Name;
				}
			}

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

示例6: IterateLayer

        private static void IterateLayer(IViewport viewport, ILayer layer,
            Action<IViewport, IStyle, IFeature> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();

            var layerStyles = layer.Style is StyleCollection ? (layer.Style as StyleCollection).ToArray() : new [] {layer.Style};
            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                foreach (var feature in features)
                {
                    if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);
                    if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.RenderResolution) || (style.MaxVisible < viewport.RenderResolution)) continue;

                    callback(viewport, style, feature);
                }
            }

            foreach (var feature in features)
            {
                var featureStyles = feature.Styles ?? Enumerable.Empty<IStyle>();
                foreach (var featureStyle in featureStyles)
                {
                    if (feature.Styles != null && featureStyle.Enabled)
                    {
                        callback(viewport, featureStyle, feature);
                    }
                }
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:31,代码来源:VisibleFeatureIterator.cs

示例7: RenderMapAsByteArray

 public byte[] RenderMapAsByteArray(IViewport viewport, Map map)
 {
     Image image = RenderMapAsImage(viewport, map);
     var memoryStream = new MemoryStream();
     image.Save(memoryStream, ImageFormat.Bmp);
     return memoryStream.ToArray();
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:7,代码来源:GdiMapRenderer.cs

示例8: RenderGeometry

        public void RenderGeometry(MultiPolygon multiPolygon, IStyle style, IFeature feature, IViewport viewport)
        {
            if (_bgWorker == null)
                _bgWorker = new BackgroundWorker();
            /*
            while (_bgWorker.IsBusy) {
                Thread.Sleep (00001);
            }
            */
            _bgWorker.RunWorkerCompleted += (sender, e) =>
                {
                    var layer = e.Result as CALayer;

                    if (layer != null)
                    {
                        var styleKey = style.GetHashCode().ToString();
                        feature[styleKey] = layer;
                    }
                };

            _bgWorker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    var layer = RenderImage(multiPolygon, style, viewport);
                    e.Result = layer;
                };

            _bgWorker.RunWorkerAsync();
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:28,代码来源:ContextRenderer.cs

示例9: Draw

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        public void Draw(Map map, IViewport viewport, GameTime gameTime)
        {
            if (spriteBatch == null) spriteBatch = new SpriteBatch(game.GraphicsDevice);

            game.GraphicsDevice.Clear(Color.LightGray);
            spriteBatch.Begin();
            
            foreach (var layer in map.Layers)
            {
                foreach (var feature in layer.GetFeaturesInView(viewport.Extent, viewport.Resolution))
                {
                    if (feature.Geometry is IRaster)
                    {
                        var raster = (feature.Geometry as IRaster);
                        var destination = ToXna(RoundToPixel(WorldToScreen(viewport, raster.GetBoundingBox())));
                        var source = new Rectangle(0, 0, 256, 256);

                        raster.Data.Position = 0;
                        if (!feature.RenderedGeometry.Keys.Contains(new VectorStyle()))
                        {
                            feature.RenderedGeometry[new VectorStyle()] = Texture2D.FromStream(game.GraphicsDevice, raster.Data);
                        }
                        spriteBatch.Draw(feature.RenderedGeometry[new VectorStyle()] as Texture2D, destination, source, Color.White);
                    }
                }
            }
            spriteBatch.End();
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:31,代码来源:MapRenderer.cs

示例10: Render

 public static void Render(Graphics graphics, IViewport viewport, Map map, AbortRenderDelegate abortRender)
 {
     foreach (var layer in map.Layers)
     {
         if (layer.Enabled &&
             layer.MinVisible <= viewport.Resolution &&
             layer.MaxVisible >= viewport.Resolution)
         {
             if (layer is LabelLayer)
             {
                 //!!!GdiLabelRenderer.Render(graphics, view, layer as LabelLayer);
             }
             else if (layer is ITileLayer)
             {
                 var tileLayer = (layer as ITileLayer);
                 GdiTileRenderer.Render(graphics, tileLayer.Schema, viewport, tileLayer.MemoryCache);
             }
             else
             {
                 RenderLayer(graphics, viewport, layer, abortRender);
             }
         }
         
         if (abortRender != null && abortRender()) return; 
     }
 }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:26,代码来源:GdiMapRenderer.cs

示例11: ToUIKit

		public static UIBezierPath ToUIKit(this IEnumerable<LinearRing> linearRings, IViewport viewport)
		{
			var pathGeometry = new UIBezierPath();
			foreach (var linearRing in linearRings)
				pathGeometry.AppendPath(CreatePathFigure(linearRing, viewport));
			return pathGeometry;
		}
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:7,代码来源:GeometryExtension.cs

示例12: ToSkia

        private static SKPath ToSkia(IViewport viewport, Polygon polygon)
        {
            var vertices = polygon.ExteriorRing.Vertices;
            var path = new SKPath();
            {
                // todo: use transform matrix
                var first = viewport.WorldToScreen(vertices[0].X, vertices[0].Y);
                path.MoveTo((float)first.X, (float) first.Y);

                for (var i = 1; i < vertices.Count; i++)
                {
                   var point = viewport.WorldToScreen(vertices[i].X, vertices[i].Y);
                    path.LineTo((float) point.X, (float) point.Y);
                }
                path.Close();
                foreach (var interiorRing in polygon.InteriorRings)
                {
                    // note: For Skia inner rings need to be clockwise and outer rings
                    // need to be counter clockwise (if this is the other way around it also
                    // seems to work)
                    // this is not a requirement of the OGC polygon.
                    var firstInner = viewport.WorldToScreen(interiorRing.Vertices[0].X, interiorRing.Vertices[0].Y);
                    path.MoveTo((float)firstInner.X, (float)firstInner.Y);
                    for (var i = 1; i < interiorRing.Vertices.Count; i++)
                    {
                        var point = viewport.WorldToScreen(interiorRing.Vertices[i].X, interiorRing.Vertices[i].Y);
                        path.LineTo((float)point.X, (float)point.Y);
                    }
                }
                path.Close();
                return path;
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:33,代码来源:PolygonRenderer.cs

示例13: Render

        public void Render(IViewport viewport, IEnumerable<ILayer> layers)
        {
            if (targetBitmap == null ||
                targetBitmap.PixelWidth != (int)target.ActualWidth ||
                targetBitmap.PixelHeight != (int)target.ActualHeight)
            {
                target.Arrange(new Rect(0, 0, viewport.Width, viewport.Height));
                if (target.ActualWidth <= 0 || target.ActualHeight <= 0) return; 
                target.Children.Clear();
                target.Children.Add(InitializeBitmap((int)target.ActualWidth, (int)target.ActualHeight));
            }

            targetBitmap.Clear(Colors.White);

            foreach (var layer in layers)
            {
                if (layer.Enabled &&
                    layer.MinVisible <= viewport.Resolution &&
                    layer.MaxVisible >= viewport.Resolution)
                {
                    RenderLayer(targetBitmap, viewport, layer);
                }
            }

            target.Arrange(new Rect(0, 0, viewport.Width, viewport.Height));
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:26,代码来源:WbxMapRenderer.cs

示例14: MemoryStream

        MemoryStream IRenderer.RenderToBitmapStream(IViewport viewport, IEnumerable<ILayer> layers, Color background)
        {
            UIImage image = null;
            var handle = new ManualResetEvent(false);

            var view = new UIView();
            view.InvokeOnMainThread(() =>
            {
                try
                {
                    view.Opaque = false;
                    view.BackgroundColor = new UIColor(background.R, background.G, background.B, background.A);
                    Render(view, viewport, layers, background);
                    image = ToImage(view, new CGRect(0, 0, (float)viewport.Width, (float)viewport.Height));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"Exception in {nameof(IRenderer.RenderToBitmapStream)}: {ex}");
                }
                finally
                {
                    handle.Set();
                }
            });

            handle.WaitOne();
            using (var nsdata = image.AsPNG())
            {
                return new MemoryStream(nsdata.ToArray());
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:31,代码来源:MapRenderer.cs

示例15: Draw

        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var lineString = ((LineString) geometry).Vertices;

            float lineWidth = 1;
            var lineColor = new Color();

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float) vectorStyle.Line.Width;
                lineColor = vectorStyle.Line.Color;
            }

            var line = WorldToScreen(viewport, lineString);
            var path = ToSkia(line);

            using (var paint = new SKPaint())
            {
                paint.IsStroke = true;
                paint.StrokeWidth = lineWidth;
                paint.Color = lineColor.ToSkia();
                paint.StrokeJoin = SKStrokeJoin.Round;

                canvas.DrawPath(path, paint);
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:28,代码来源:LineStringRenderer.cs


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