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


C# Controls.MapArgs类代码示例

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


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


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