本文整理汇总了C#中DotSpatial.Controls.MapArgs类的典型用法代码示例。如果您正苦于以下问题:C# MapArgs类的具体用法?C# MapArgs怎么用?C# MapArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapArgs类属于DotSpatial.Controls命名空间,在下文中一共展示了MapArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MapDrawArgs
/// <summary>
/// Creates a new instance of DrawArgs
/// </summary>
public MapDrawArgs(Graphics inGraphics, Rectangle clipRectangle, IMapFrame inMapFrame)
{
_graphics = inGraphics;
_geoGraphics = new MapArgs(clipRectangle, inMapFrame.ViewExtents);
_clipRectangle = clipRectangle;
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:10,代码来源:MapDrawArgs.cs
示例2: DrawWindows
/// <summary>
/// This draws to the back buffer. If the Backbuffer doesn't exist, this will create one.
/// This will not flip the back buffer to the front.
/// </summary>
/// <param name="args"></param>
/// <param name="regions"></param>
/// <param name="clipRectangles"></param>
private void DrawWindows(MapArgs args, IList<Extent> regions, IList<Rectangle> clipRectangles)
{
Graphics g = args.Device;
int numBounds = Math.Min(regions.Count, clipRectangles.Count);
for (int i = 0; i < numBounds; i++)
{
Bitmap bmp = DataSet.GetBitmap(regions[i], clipRectangles[i].Size);
if (bmp != null) g.DrawImage(bmp, clipRectangles[i]);
}
if (args.Device == null) g.Dispose();
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:19,代码来源:MapTiledImageLayer.cs
示例3: DrawWindows
/// <summary>
/// This draws to the back buffer. If the Backbuffer doesn't exist, this will create one.
/// This will not flip the back buffer to the front.
/// </summary>
/// <param name="args"></param>
/// <param name="regions"></param>
/// <param name="clipRectangles"></param>
private void DrawWindows(MapArgs args, IList<Extent> regions, IList<Rectangle> clipRectangles)
{
Graphics g;
if (args.Device != null)
{
g = args.Device; // A device on the MapArgs is optional, but overrides the normal buffering behaviors.
}
else
{
if (_backBuffer == null) _backBuffer = new Bitmap(_bufferRectangle.Width, _bufferRectangle.Height);
g = Graphics.FromImage(_backBuffer);
}
int numBounds = Math.Min(regions.Count, clipRectangles.Count);
for (int i = 0; i < numBounds; i++)
{
// For panning tiles, the region needs to be expanded.
// This is not always 1 pixel. When very zoomed in, this could be many pixels,
// but should correspond to 1 pixel in the source image.
int dx = (int)Math.Ceiling(DataSet.Bounds.AffineCoefficients[1] * clipRectangles[i].Width / regions[i].Width);
Rectangle r = RectangleExt.ExpandBy(clipRectangles[i], dx * 2);
if (r.X < 0) r.X = 0;
if (r.Y < 0) r.Y = 0;
if (r.Width > 2 * clipRectangles[i].Width) r.Width = 2 * clipRectangles[i].Width;
if (r.Height > 2 * clipRectangles[i].Height) r.Height = 2 * clipRectangles[i].Height;
Extent env = regions[i].Reproportion(clipRectangles[i], r);
Bitmap bmp;
try
{
bmp = DataSet.GetBitmap(env, r);
}
catch
{
continue;
}
if (bmp == null) continue;
g.DrawImage(bmp, r);
bmp.Dispose();
}
if (args.Device == null) g.Dispose();
}
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:49,代码来源:MapImageLayer.cs
示例4: DrawRegions
public void DrawRegions(MapArgs args, List<Extent> regions)
{
// Assert that the map has the same size as the DotSpatial map
var size = args.ImageRectangle.Size;
_map.Size = size;
// Make sure the map is zoomed to the same extent
var env = Topology.GeometryConverter.ToGeoAPI(args.GeographicExtents);
_map.ZoomToBox(env);
// Always render the whole map to the device
_map.RenderMap(args.Device);
/*
* This is not suitable because we might draw to printer/plotter
* which will make for a huge Image
*/
#region
//using (var mapImage = _map.GetMap())
//{
// foreach (var region in regions)
// {
// var loc = args.ProjToPixel(region);
// args.Device.DrawImage(mapImage, loc,
// loc.X, loc.Y, loc.Width, loc.Height,
// GraphicsUnit.Pixel);
// }
//}
#endregion
}
开发者ID:haoas,项目名称:DotSpatial.Plugins,代码行数:30,代码来源:SharpMapLayer.cs
示例5: DrawFeatures
// This draws the individual line features
private void DrawFeatures(MapArgs e, IEnumerable<IFeature> features)
{
Graphics g = e.Device ?? Graphics.FromImage(_backBuffer);
for (int selectState = 0; selectState < 2; selectState++)
{
foreach (ILineCategory category in Symbology.Categories)
{
// Define the symbology based on the category and selection state
ILineSymbolizer ls = category.Symbolizer;
if (selectState == SELECTED) ls = category.SelectionSymbolizer;
if (ls.Smoothing)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
}
else
{
g.SmoothingMode = SmoothingMode.None;
}
Rectangle clipRect = ComputeClippingRectangle(e, ls);
// Determine the subset of the specified features that are visible and match the category
ILineCategory lineCategory = category;
int i = selectState;
Func<IDrawnState, bool> isMember = state =>
state.SchemeCategory == lineCategory &&
state.IsVisible &&
state.IsSelected == (i == 1);
var drawnFeatures = from feature in features
where isMember(DrawingFilter[feature])
select feature;
GraphicsPath graphPath = new GraphicsPath();
foreach (IFeature f in drawnFeatures)
{
BuildLineString(graphPath, DataSet.Vertex, f.ShapeIndex, e, clipRect);
}
double scale = 1;
if (ls.ScaleMode == ScaleMode.Geographic)
{
scale = e.ImageRectangle.Width / e.GeographicExtents.Width;
}
foreach (IStroke stroke in ls.Strokes)
{
stroke.DrawPath(g, graphPath, scale);
}
graphPath.Dispose();
}
}
if (e.Device == null) g.Dispose();
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:56,代码来源:MapLineLayer.cs
示例6: BuildLineString
internal static void BuildLineString(GraphicsPath path, double[] vertices, ShapeRange shpx, MapArgs args, Rectangle clipRect)
{
double minX = args.MinX;
double maxY = args.MaxY;
double dx = args.Dx;
double dy = args.Dy;
for (int prt = 0; prt < shpx.Parts.Count; prt++)
{
PartRange prtx = shpx.Parts[prt];
int start = prtx.StartIndex;
int end = prtx.EndIndex;
List<double[]> points = new List<double[]>();
for (int i = start; i <= end; i++)
{
double[] pt = new double[2];
pt[X] = (vertices[i * 2] - minX) * dx;
pt[Y] = (maxY - vertices[i * 2 + 1]) * dy;
points.Add(pt);
}
List<List<double[]>> multiLinestrings;
if (!shpx.Extent.Within(args.GeographicExtents))
{
multiLinestrings = CohenSutherland.ClipLinestring(points, clipRect.Left, clipRect.Top,
clipRect.Right, clipRect.Bottom);
}
else
{
multiLinestrings = new List<List<double[]>>();
multiLinestrings.Add(points);
}
foreach (List<double[]> linestring in multiLinestrings)
{
List<Point> intPoints = DuplicationPreventer.Clean(linestring);
if (intPoints.Count < 2)
{
points.Clear();
continue;
}
path.StartFigure();
Point[] pointArray = intPoints.ToArray();
path.AddLines(pointArray);
}
}
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:47,代码来源:MapLineLayer.cs
示例7: DrawRegions
/// <summary>
/// This will draw any features that intersect this region. To specify the features
/// directly, use OnDrawFeatures. This will not clear existing buffer content.
/// For that call Initialize instead.
/// </summary>
/// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
/// <param name="regions">The geographic regions to draw</param>
public virtual void DrawRegions(MapArgs args, List<Extent> regions)
{
// First determine the number of features we are talking about based on region.
List<Rectangle> clipRects = args.ProjToPixel(regions);
if (EditMode)
{
List<IFeature> drawList = new List<IFeature>();
foreach (Extent region in regions)
{
if (region != null)
{
// Use union to prevent duplicates. No sense in drawing more than we have to.
drawList = drawList.Union(DataSet.Select(region)).ToList();
}
}
DrawFeatures(args, drawList, clipRects, true);
}
else
{
List<int> drawList = new List<int>();
List<ShapeRange> shapes = DataSet.ShapeIndices;
for (int shp = 0; shp < shapes.Count; shp++)
{
foreach (Extent region in regions)
{
if (!shapes[shp].Extent.Intersects(region)) continue;
drawList.Add(shp);
break;
}
}
DrawFeatures(args, drawList, clipRects, true);
}
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:40,代码来源:MapLineLayer.cs
示例8: BuildPolygon
/// <summary>
/// Appends the specified polygon to the graphics path.
/// </summary>
private static void BuildPolygon(double[] vertices, ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
{
double minX = args.MinX;
double maxY = args.MaxY;
double dx = args.Dx;
double dy = args.Dy;
for (int prt = 0; prt < shpx.Parts.Count; prt++)
{
PartRange prtx = shpx.Parts[prt];
int start = prtx.StartIndex;
int end = prtx.EndIndex;
var points = new List<double[]>(end - start + 1);
for (int i = start; i <= end; i++)
{
var pt = new[]
{
(vertices[i*2] - minX)*dx,
(maxY - vertices[i*2 + 1])*dy
};
points.Add(pt);
}
if (null != shClip)
{
points = shClip.Clip(points);
}
var intPoints = DuplicationPreventer.Clean(points).ToArray();
if (intPoints.Length < 2)
{
continue;
}
borderPath.StartFigure();
borderPath.AddLines(intPoints);
}
}
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:40,代码来源:MapPolygonLayer.cs
示例9: DrawRegions
/// <summary>
/// This will draw any features that intersect this region. To specify the features
/// directly, use OnDrawFeatures. This will not clear existing buffer content.
/// For that call Initialize instead.
/// </summary>
/// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
/// <param name="regions">The geographic regions to draw</param>
public void DrawRegions(MapArgs args, List<Extent> regions)
{
List<Rectangle> clipRects = args.ProjToPixel(regions);
DrawWindows(args, regions, clipRects);
}
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:12,代码来源:MapRasterLayer.cs
示例10: BuildPolygon
/// <summary>
/// Appends the specified polygon to the graphics path.
/// </summary>
private static void BuildPolygon(double[] vertices, ShapeRange shpx, GraphicsPath borderPath, MapArgs args, SoutherlandHodgman shClip)
{
double minX = args.MinX;
double maxY = args.MaxY;
double dx = args.Dx;
double dy = args.Dy;
for (int prt = 0; prt < shpx.Parts.Count; prt++)
{
PartRange prtx = shpx.Parts[prt];
int start = prtx.StartIndex;
int end = prtx.EndIndex;
List<double[]> points = new List<double[]>();
for (int i = start; i <= end; i++)
{
double[] pt = new double[2];
pt[X] = (vertices[i * 2] - minX) * dx;
pt[Y] = (maxY - vertices[i * 2 + 1]) * dy;
points.Add(pt);
}
if (null != shClip)
{
points = shClip.Clip(points);
}
List<Point> intPoints = DuplicationPreventer.Clean(points);
if (intPoints.Count < 2)
{
points.Clear();
continue;
}
//Would be nice to figure out how to get rid of this lock
lock (lock1)
{
borderPath.StartFigure();
Point[] pointArray = intPoints.ToArray();
borderPath.AddLines(pointArray);
}
points.Clear();
}
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:45,代码来源:MapPolygonLayer.cs
示例11: DrawFeatures
// This draws the individual polygon features
private void DrawFeatures(MapArgs e, IEnumerable<IFeature> features)
{
List<GraphicsPath> paths;
Stopwatch sw = new Stopwatch();
sw.Start();
// First, use the coordinates to build the drawing paths
BuildPaths(e, features, out paths);
// Next draw all the paths using the various category symbols.
DrawPaths(e, paths);
sw.Stop();
//Debug.WriteLine("Drawing time: " + sw.ElapsedMilliseconds);
foreach (GraphicsPath path in paths)
{
path.Dispose();
}
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:18,代码来源:MapPolygonLayer.cs
示例12: DrawFeatures
private void DrawFeatures(MapArgs e, List<int> indices)
{
var g = e.Device ?? Graphics.FromImage(BackBuffer);
var origTransform = g.Transform;
var minX = e.MinX;
var maxY = e.MaxY;
var dx = e.Dx;
var dy = e.Dy;
var states = DrawnStates;
foreach (var category in Symbology.Categories)
{
var normalSymbol = GetSymbolizerBitmap(category.Symbolizer, e);
var selectedSymbol = GetSymbolizerBitmap(category.SelectionSymbolizer, e);
foreach (var index in indices)
{
var state = states[index];
if (!state.Visible) continue;
var pc = state.Category as IPointCategory;
if (pc == null) continue;
if (pc != category) continue;
var bmp = state.Selected? selectedSymbol : normalSymbol;
if (bmp == null) continue;
var shape = DataSet.GetShape(index, false);
foreach (var part in shape.Range.Parts)
{
foreach (var vertex in part)
{
var pt = new Point
{
X = Convert.ToInt32((vertex.X - minX)*dx),
Y = Convert.ToInt32((maxY - vertex.Y)*dy)
};
var shift = origTransform.Clone();
shift.Translate(pt.X, pt.Y);
g.Transform = shift;
g.DrawImageUnscaled(bmp, -bmp.Width/2, -bmp.Height/2);
}
}
}
}
if (e.Device == null) g.Dispose();
else g.Transform = origTransform;
}
开发者ID:hanchao,项目名称:DotSpatial,代码行数:50,代码来源:MapPointLayer.cs
示例13: DrawRegions
/// <summary>
/// This will draw any features that intersect this region. To specify the features
/// directly, use OnDrawFeatures. This will not clear existing buffer content.
/// For that call Initialize instead.
/// </summary>
/// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
/// <param name="regions">The geographic regions to draw</param>
public virtual void DrawRegions(MapArgs args, List<Extent> regions)
{
// First determine the number of features we are talking about based on region.
var clipRects = args.ProjToPixel(regions);
var drawList = new List<int>();
for (var shp = 0; shp < DataSet.Count; shp++)
{
var pointExtent = DataSet.GetFeatureExtent(shp);
if (regions.Any(pointExtent.Intersects))
{
drawList.Add(shp);
}
}
DrawFeatures(args, drawList, clipRects, true);
}
开发者ID:hanchao,项目名称:DotSpatial,代码行数:23,代码来源:MapPointLayer.cs
示例14: BuildLineString
private static void BuildLineString(GraphicsPath path, double[] vertices, ShapeRange shpx, MapArgs args, Rectangle clipRect)
{
var minX = args.MinX;
var maxY = args.MaxY;
var dx = args.Dx;
var dy = args.Dy;
foreach (var prtx in shpx.Parts)
{
var points = prtx.Select(v => new Vertex((v.X - minX) * dx, (maxY - v.Y) * dy)).ToList();
List<List<Vertex>> multiLinestrings;
if (!shpx.Extent.Within(args.GeographicExtents))
{
multiLinestrings = CohenSutherland.ClipLinestring(points, clipRect.Left, clipRect.Top,
clipRect.Right, clipRect.Bottom);
}
else
{
multiLinestrings = new List<List<Vertex>> { points };
}
foreach (var linestring in multiLinestrings)
{
var intPoints = DuplicationPreventer.Clean(linestring).ToArray();
if (intPoints.Length < 2) continue;
path.StartFigure();
path.AddLines(intPoints);
}
}
}
开发者ID:hanchao,项目名称:DotSpatial,代码行数:32,代码来源:MapLineLayer.cs
示例15: BuildPaths
private void BuildPaths(MapArgs e, IEnumerable<IFeature> features, out List<GraphicsPath> borderPaths)
{
borderPaths = new List<GraphicsPath>();
Rectangle clipRect = ComputeClippingRectangle(e);
Extent drawExtents = e.PixelToProj(clipRect);
SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect);
for (int selectState = 0; selectState < 2; selectState++)
{
foreach (IPolygonCategory category in Symbology.Categories)
{
// Determine the subset of the specified features that are visible and match the category
IPolygonCategory polygonCategory = category;
int i = selectState;
Func<IDrawnState, bool> isMember = state =>
state.SchemeCategory == polygonCategory &&
state.IsVisible &&
state.IsSelected == (i == 1);
var drawnFeatures = from feature in features
where isMember(DrawingFilter[feature])
select feature;
GraphicsPath borderPath = new GraphicsPath();
foreach (IFeature f in drawnFeatures)
{
BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e,
drawExtents.Contains(f.Envelope) ? null : shClip);
}
borderPaths.Add(borderPath);
}
}
}
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:33,代码来源:MapPolygonLayer.cs
示例16: ComputeClippingRectangle
private static Rectangle ComputeClippingRectangle(MapArgs args)
{
const int maxSymbologyFuzz = 50;
var clipRect = new Rectangle(args.ImageRectangle.Location.X, args.ImageRectangle.Location.Y, args.ImageRectangle.Width, args.ImageRectangle.Height);
clipRect.Inflate(maxSymbologyFuzz, maxSymbologyFuzz);
return clipRect;
}
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:7,代码来源:MapPolygonLayer.cs
示例17: DrawWindows
/// <summary>
/// This draws to the back buffer. If the back buffer doesn't exist, this will create one.
/// This will not flip the back buffer to the front.
/// </summary>
/// <param name="args"></param>
/// <param name="regions"></param>
/// <param name="clipRectangles"></param>
private void DrawWindows(MapArgs args, IList<Extent> regions, IList<Rectangle> clipRectangles)
{
Graphics g;
if (args.Device != null)
{
g = args.Device; // A device on the MapArgs is optional, but overrides the normal buffering behaviors.
}
else
{
if (_backBuffer == null) _backBuffer = new Bitmap(_bufferRectangle.Width, _bufferRectangle.Height);
g = Graphics.FromImage(_backBuffer);
}
int numBounds = Math.Min(regions.Count, clipRectangles.Count);
for (int i = 0; i < numBounds; i++)
{
using (Bitmap bmp = BitmapGetter.GetBitmap(regions[i], clipRectangles[i]))
{
if (bmp != null) g.DrawImage(bmp, clipRectangles[i]);
}
}
if (args.Device == null) g.Dispose();
}
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:31,代码来源:MapRasterLayer.cs
示例18: DrawRegions
/// <summary>
/// Draws the LiDAR data points in the currently visible map display
/// </summary>
/// <param name="args">Information about the map display</param>
/// <param name="regions">Information about the visible regions</param>
public void DrawRegions(MapArgs args, List<Extent> regions)
{
throw new NotImplementedException();
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:9,代码来源:MapLiDARLayer.cs
示例19: FromBruTileExtent
/*
private static Extent FromBruTileExtent(BruTile.Extent extent)
{
return new Extent(extent.MinX, extent.MinY, extent.MaxX, extent.MaxY);
}
*/
/// <summary>
/// This draws content from the specified geographic regions onto the specified graphics
/// object specified by MapArgs.
/// </summary>
public void DrawRegions(MapArgs args, List<Extent> regions)
{
System.Windows.Threading.Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
BruTile.Extent extent = ToBrutileExtent(args.GeographicExtents);
double pixelSize = extent.Width / args.ImageRectangle.Width;
int level = Utilities.GetNearestLevel(TileSource.Schema.Resolutions, pixelSize);
IList<TileInfo> tiles = TileSource.Schema.GetTilesInView(extent, level);
IList<WaitHandle> waitHandles = new List<WaitHandle>();
foreach (TileInfo info in tiles)
{
if (TileCache.Find(info.Index) != null) continue;
AutoResetEvent waitHandle = new AutoResetEvent(false);
waitHandles.Add(waitHandle);
ThreadPool.QueueUserWorkItem(GetTileOnThread,
new object[] { TileSource.Provider, info, TileCache, waitHandle });
}
foreach (WaitHandle handle in waitHandles)
handle.WaitOne();
foreach (TileInfo info in tiles)
{
using (Image bitmap = Image.FromStream(new MemoryStream(TileCache.Find(info.Index))))
{
PointF min = args.ProjToPixel(new Coordinate(info.Extent.MinX, info.Extent.MinY));
PointF max = args.ProjToPixel(new Coordinate(info.Extent.MaxX, info.Extent.MaxY));
min = new PointF((float)Math.Round(min.X), (float)Math.Round(min.Y));
max = new PointF((float)Math.Round(max.X), (float)Math.Round(max.Y));
args.Device.DrawImage(bitmap,
new Rectangle((int)min.X, (int)max.Y, (int)(max.X - min.X), (int)(min.Y - max.Y)),
0, 0, TileSource.Schema.Width, TileSource.Schema.Height,
GraphicsUnit.Pixel);
}
}
}
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:52,代码来源:BruTileLayer.cs
示例20: DrawRegions
/// <summary>
/// This will draw any features that intersect this region. To specify the features
/// directly, use OnDrawFeatures. This will not clear existing buffer content.
/// For that call Initialize instead.
/// </summary>
/// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
/// <param name="regions">The geographic regions to draw</param>
public virtual void DrawRegions(MapArgs args, List<Extent> regions)
{
List<Rectangle> clipRects = args.ProjToPixel(regions);
if (EditMode)
{
List<IFeature> drawList = new List<IFeature>();
drawList = regions.Where(region => region != null).Aggregate(drawList, (current, region) => current.Union(DataSet.Select(region)).ToList());
DrawFeatures(args, drawList, clipRects, true);
}
else
{
List<int> drawList = new List<int>();
List<ShapeRange> shapes = DataSet.ShapeIndices;
for (int shp = 0; shp < shapes.Count; shp++)
{
foreach (Extent region in regions)
{
if (!shapes[shp].Extent.Intersects(region)) continue;
drawList.Add(shp);
break;
}
}
DrawFeatures(args, drawList, clipRects, true);
}
}
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:32,代码来源:MapPolygonLayer.cs
注:本文中的DotSpatial.Controls.MapArgs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论