本文整理汇总了C#中IViewport类的典型用法代码示例。如果您正苦于以下问题:C# IViewport类的具体用法?C# IViewport怎么用?C# IViewport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IViewport类属于命名空间,在下文中一共展示了IViewport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: RenderLabelLayer
public static Canvas RenderLabelLayer(IViewport viewport, LabelLayer layer)
{
var canvas = new Canvas { Opacity = layer.Opacity };
// todo: take into account the priority
var features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
var layerStyles = BaseLayer.GetLayerStyles(layer);
foreach (var layerStyle in layerStyles)
{
foreach (var feature in features)
{
var style = (layerStyle is IThemeStyle) ? (layerStyle as IThemeStyle).GetStyle(feature) : layerStyle;
if ((style == null) ||
(style.Enabled == false) ||
(style.MinVisible > viewport.Resolution) ||
(style.MaxVisible < viewport.Resolution)) continue;
if (!(style is LabelStyle)) throw new Exception("Style of label is not a LabelStyle");
var labelStyle = style as LabelStyle;
labelStyle.Text = layer.GetLabelText(feature);
var postion = feature.Geometry.GetBoundingBox().GetCentroid();
var labelText = labelStyle.GetLabelText(feature);
canvas.Children.Add(SingleLabelRenderer.RenderLabel(postion, labelStyle, viewport, labelText));
}
}
return canvas;
}
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:32,代码来源:LabelRenderer.cs
示例17: Draw
public static void Draw(IViewport viewport, IStyle style, IFeature feature)
{
var lineString = ((LineString)feature.Geometry).Vertices;
float lineWidth = 1;
var lineColor = Color.White;
var vectorStyle = style as VectorStyle;
if (vectorStyle != null)
{
lineWidth = (float)vectorStyle.Line.Width;
lineColor = vectorStyle.Line.Color;
}
float[] points = ToOpenTK(lineString);
WorldToScreen(viewport, points);
GL.LineWidth(lineWidth);
GL.Color4((byte)lineColor.R, (byte)lineColor.G, (byte)lineColor.B, (byte)lineColor.A);
GL.EnableClientState(All.VertexArray);
GL.VertexPointer(2, All.Float, 0, points);
GL.DrawArrays(All.Lines, 0, points.Length / 2);
GL.DisableClientState(All.VertexArray);
}
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:25,代码来源:LineStringRenderer.cs
示例18: RenderPoint
public static UIElement RenderPoint(Point point, IStyle style, IViewport viewport)
{
UIElement symbol;
var matrix = XamlMedia.Matrix.Identity;
if (style is SymbolStyle)
{
var symbolStyle = style as SymbolStyle;
if (symbolStyle.Symbol == null || symbolStyle.Symbol.Data == null)
symbol = CreateSymbolFromVectorStyle(symbolStyle, symbolStyle.Opacity, symbolStyle.SymbolType);
else
symbol = CreateSymbolFromBitmap(symbolStyle.Symbol.Data, symbolStyle.Opacity);
matrix = CreatePointSymbolMatrix(viewport.Resolution, symbolStyle);
}
else
{
symbol = CreateSymbolFromVectorStyle((style as VectorStyle) ?? new VectorStyle());
MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
}
MatrixHelper.Append(ref matrix, CreateTransformMatrix(point, viewport));
symbol.RenderTransform = new XamlMedia.MatrixTransform { Matrix = matrix };
symbol.IsHitTestVisible = false;
return symbol;
}
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:29,代码来源:GeometryRenderer.cs
示例19: RenderLabel
public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text)
{
// Offset stackOffset,
Mapsui.Geometries.Point p = viewport.WorldToScreen(point);
//var pointF = new xPointF((float)p.X, (float)p.Y);
var label = new CATextLayer ();
var aString = new Foundation.NSAttributedString (text,
new CoreText.CTStringAttributes(){
Font = new CoreText.CTFont("ArialMT", 10)
});
var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString));
//label.Frame = frame;
//frame.Width = (float)(p2.X - p1.X);// + margin);
//frame.Height = (float)(p1.Y - p2.Y);
label.FontSize = 10;
label.ForegroundColor = new CoreGraphics.CGColor (0, 0, 255, 150);
label.BackgroundColor = new CoreGraphics.CGColor (255, 0, 2, 150);
label.String = text;
label.Frame = frame;
Console.WriteLine ("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height);
// = MonoTouch.UIKit.UIScreen.MainScreen.Scale;
// label.ContentsScale = scale;
return label;
}
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:31,代码来源:LabelRenderer.cs
示例20: Render
public void Render(IViewport viewport, Sprite sprite, Matrix view, Matrix projection, Matrix world, float xScale, float yScale, float rotation)
{
var buffer = BufferManager.Instance.Current;
var image = sprite.CurrentFrame;
var position = new Vector(0, 0, 0);
var transformedPosition = Vector.Transform(position, world, view);
var translatedPosition = Vector.Translate(transformedPosition, projection, viewport.Width, viewport.Height);
var depthBufferAdjustedZ = -transformedPosition.Z / viewport.Camera.DepthDivisor;
var positionOffset = (((int)translatedPosition.X)) + (((int)translatedPosition.Y) * buffer.FrameBuffer.Stride);
var bufferSize = buffer.FrameBuffer.Stride*buffer.Height;
var bufferZ = (UInt32)(depthBufferAdjustedZ * (float)UInt32.MaxValue);
if( depthBufferAdjustedZ < 0f || depthBufferAdjustedZ >= 1f)
{
return;
}
if( xScale != 1f || yScale != 1f )
{
RenderScaled(buffer, positionOffset, sprite.CurrentFrame, translatedPosition, bufferSize, bufferZ, xScale, yScale);
} else
{
RenderUnscaled(buffer,positionOffset,sprite.CurrentFrame,translatedPosition,bufferSize,bufferZ);
}
}
开发者ID:baldercollaborator,项目名称:Balder,代码行数:29,代码来源:SpriteContext.cs
注:本文中的IViewport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论