本文整理汇总了C#中DotSpatial.Controls.MapArgs.ProjToPixel方法的典型用法代码示例。如果您正苦于以下问题:C# MapArgs.ProjToPixel方法的具体用法?C# MapArgs.ProjToPixel怎么用?C# MapArgs.ProjToPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotSpatial.Controls.MapArgs
的用法示例。
在下文中一共展示了MapArgs.ProjToPixel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
for (int i = clipRects.Count - 1; i >= 0; i--)
{
if (clipRects[i].Width != 0 && clipRects[i].Height != 0) continue;
regions.RemoveAt(i);
clipRects.RemoveAt(i);
}
DrawWindows(args, regions, clipRects);
}
示例2: BuildPaths
private void BuildPaths(MapArgs e, IEnumerable<int> indices, out List<GraphicsPath> paths)
{
paths = new List<GraphicsPath>();
Extent drawExtents = e.GeographicExtents;
Rectangle clipRect = e.ProjToPixel(e.GeographicExtents);
SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect);
List<GraphicsPath> graphPaths = new List<GraphicsPath>();
Dictionary<FastDrawnState, GraphicsPath> borders = new Dictionary<FastDrawnState, GraphicsPath>();
for (int selectState = 0; selectState < 2; selectState++)
{
foreach (IPolygonCategory category in Symbology.Categories)
{
FastDrawnState state = new FastDrawnState(selectState == 1, category);
GraphicsPath border = new GraphicsPath();
borders.Add(state, border);
graphPaths.Add(border);
}
}
paths.AddRange(graphPaths);
List<ShapeRange> shapes = DataSet.ShapeIndices;
double[] vertices = DataSet.Vertex;
if (ProgressReportingEnabled)
{
ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indices.Count());
}
if (!DrawnStatesNeeded)
{
FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]);
foreach (int shp in indices)
{
if (ProgressReportingEnabled) ProgressMeter.Next();
ShapeRange shape = shapes[shp];
if (!shape.Extent.Intersects(e.GeographicExtents)) return;
if (shp >= shapes.Count) return;
if (!borders.ContainsKey(state)) return;
BuildPolygon(vertices, shapes[shp], borders[state], e, drawExtents.Contains(shape.Extent) ? null : shClip);
}
}
else
{
FastDrawnState[] states = DrawnStates;
foreach (GraphicsPath borderPath in borders.Values)
{
if (borderPath != null)
{
borderPath.FillMode = FillMode.Winding;
}
}
foreach (int shp in indices)
{
if (ProgressReportingEnabled) ProgressMeter.Next();
if (shp >= shapes.Count) return;
if (shp >= states.Length)
{
AssignFastDrawnStates();
states = DrawnStates;
}
if (states[shp].Visible == false) continue;
ShapeRange shape = shapes[shp];
if (!shape.Extent.Intersects(e.GeographicExtents)) continue;
if (drawExtents.Contains(shape.Extent))
{
FastDrawnState state = states[shp];
if (!borders.ContainsKey(state)) continue;
BuildPolygon(vertices, shapes[shp], borders[state], e, null);
}
else
{
FastDrawnState state = states[shp];
if (!borders.ContainsKey(state)) continue;
BuildPolygon(vertices, shapes[shp], borders[state], e, shClip);
}
}
}
if (ProgressReportingEnabled) ProgressMeter.Reset();
}
示例3: 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);
}
}
示例4: 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);
}
}
}
示例5: 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);
}
}
示例6: 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);
}
示例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.
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);
}
示例8: 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)
{
if (FeatureSet == null) return;
if (FeatureSet.IndexMode)
{
// First determine the number of features we are talking about based on region.
List<int> drawIndices = new List<int>();
foreach (Extent region in regions)
{
if (region != null)
{
// We need to consider labels that go off the screen. figure a region
// that is larger.
Extent sur = region.Copy();
sur.ExpandBy(region.Width, region.Height);
// Use union to prevent duplicates. No sense in drawing more than we have to.
drawIndices = drawIndices.Union(FeatureSet.SelectIndices(sur)).ToList();
}
}
List<Rectangle> clips = args.ProjToPixel(regions);
DrawFeatures(args, drawIndices, clips, true);
}
else
{
// First determine the number of features we are talking about based on region.
List<IFeature> drawList = new List<IFeature>();
foreach (Extent region in regions)
{
if (region != null)
{
// We need to consider labels that go off the screen. figure a region
// that is larger.
Extent r = region.Copy();
r.ExpandBy(region.Width, region.Height);
// Use union to prevent duplicates. No sense in drawing more than we have to.
drawList = drawList.Union(FeatureSet.Select(r)).ToList();
}
}
List<Rectangle> clipRects = args.ProjToPixel(regions);
DrawFeatures(args, drawList, clipRects, true);
}
}
示例9: DrawTile
private void DrawTile(MapArgs args, TileInfo info, Resolution resolution, byte[] buffer, TileReprojector tr = null)
{
if (buffer == null || buffer.Length == 0)
return;
tr = tr ?? new TileReprojector(args, _projection, _targetProjection);
using (var bitmap = (Bitmap)Image.FromStream(new MemoryStream(buffer)))
{
var inWorldFile = new Reprojection.WorldFile(resolution.UnitsPerPixel, 0,
0, -resolution.UnitsPerPixel,
info.Extent.MinX, info.Extent.MaxY);
Reprojection.WorldFile outWorldFile;
Bitmap outBitmap;
tr.Reproject(inWorldFile, bitmap, out outWorldFile, out outBitmap);
if (outWorldFile == null) return;
var lt = args.ProjToPixel(outWorldFile.ToGround(0, 0));
var rb = args.ProjToPixel(outWorldFile.ToGround(outBitmap.Width, outBitmap.Height));
var rect = new Rectangle(lt, Size.Subtract(new Size(rb), new Size(lt)));
args.Device.DrawImage(outBitmap, rect, 0, 0, outBitmap.Width, outBitmap.Height,
GraphicsUnit.Pixel, _imageAttributes);
if (outBitmap != bitmap) outBitmap.Dispose();
if (FrameTile)
{
if (FramePen != null)
args.Device.DrawRectangle(FramePen, rect);
}
}
}
示例10: Initialize
/// <summary>
/// Instructs the map frame to draw content from the specified regions to the buffer..
/// </summary>
/// <param name="regions">The regions to initialize.</param>
public virtual void Initialize(List<Extent> regions)
{
bool setView = false;
if (_backBuffer == null)
{
_backBuffer = CreateBuffer();
//set the view
setView = true;
}
Graphics bufferDevice = Graphics.FromImage(_backBuffer);
MapArgs args = new MapArgs(ClientRectangle, ViewExtents, bufferDevice);
GraphicsPath gp = new GraphicsPath();
foreach (Extent region in regions)
{
if (region == null) continue;
Rectangle rect = args.ProjToPixel(region);
gp.StartFigure();
gp.AddRectangle(rect);
}
bufferDevice.Clip = new Region(gp);
// Draw the background color
if (null != _parent) bufferDevice.Clear(_parent.BackColor);
else bufferDevice.Clear(Color.White);
// First draw all the vector content
foreach (IMapLayer layer in Layers)
{
if (layer.VisibleAtExtent(ViewExtents)) layer.DrawRegions(args, regions);
}
// Then
MapLabelLayer.ExistingLabels = new List<RectangleF>();
foreach (IMapLayer layer in Layers)
{
InitializeLabels(regions, args, layer);
}
// First draw all the vector content
foreach (IMapLayer layer in DrawingLayers)
{
if (layer.VisibleAtExtent(ViewExtents)) layer.DrawRegions(args, regions);
}
if (_buffer != null && _buffer != _backBuffer) _buffer.Dispose();
_buffer = _backBuffer;
if(setView)
_view = _backView;
bufferDevice.Clip = new Region(ImageRectangle);
gp.Dispose();
List<Rectangle> rects = args.ProjToPixel(regions);
OnBufferChanged(this, new ClipArgs(rects));
}