예제 #1
0
        private static CALayer CreateSymbolFromVectorStyle(VectorStyle style)
        {
            const int defaultWidth = 32;
            const int defaultHeight = 32;

            var symbol = new CAShapeLayer();

            if (style.Fill != null && style.Fill.Color != null)
            {
                symbol.FillColor = style.Fill.Color.ToCG();
            }
            else
            {
                symbol.BackgroundColor = new CGColor(0, 0, 0, 0);
            }

            if (style.Outline != null)
            {
                symbol.LineWidth = (float)style.Outline.Width;
                symbol.StrokeColor = style.Outline.Color.ToCG();
            }

            var frame = new CGRect(-defaultWidth * 0.5f, -defaultHeight * 0.5f, defaultWidth, defaultHeight);
            symbol.Path = UIBezierPath.FromRoundedRect((CGRect)frame, (nfloat)frame.Width / 2).CGPath;

            return symbol;
        }
예제 #2
0
        void layerRequest_LayerRecived(object sender, EventArgs e)
        {

            Polygon poligono;
            Earthwatchers.Models.KmlModels.Layer layer = sender as Earthwatchers.Models.KmlModels.Layer;

            if (layer != null)
            {
                isFirstTime = false;
                layersTest = layer;     
                foreach (Earthwatchers.Models.KmlModels.Zone zon in layer.Zones)
                {
                    foreach (var p in zon.Polygons)
                    {
                        poligono = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(p.Locations.Select(l => new Location(l.Longitude.Value, l.Latitude.Value)).ToList())) };
                        var feature = new Feature { Geometry = poligono };
                        var vStyle = new VectorStyle
                        {
                            Fill = new Brush { Color = Color.FromArgb(48, 255, 255, 255) },
                            Outline = new Pen { Color = Color.FromArgb(100, 241, 251, 187), Width = 2 }, //#F1FBBB
                        };
                        feature.Styles.Add(vStyle);
                        _source.Features.Add(feature);
                    }
                }
                Current.Instance.MapControl.OnViewChanged(true);
            }
            Current.Instance.MapControl.OnViewChanged(true);
        }
예제 #3
0
        private static XamlShapes.Shape CreateSymbolFromVectorStyle(VectorStyle style, double opacity = 1, SymbolType symbolType = SymbolType.Ellipse, double width = SymbolStyle.DefaultWidth, double height = SymbolStyle.DefaultHeight)
        {
            var path = new XamlShapes.Path { StrokeThickness = 0 };  //The SL StrokeThickness default is 1 which causes blurry bitmaps

            if (style.Fill != null && (style.Fill.Color != null || style.Fill.BitmapId != -1))
                path.Fill = style.Fill.ToXaml();
            else
                path.Fill = new XamlMedia.SolidColorBrush(XamlColors.Transparent);

            if (style.Outline != null)
            {
                path.Stroke = new XamlMedia.SolidColorBrush(style.Outline.Color.ToXaml());
                path.StrokeThickness = style.Outline.Width;
                path.StrokeDashArray = style.Outline.PenStyle.ToXaml();
            }

            if (symbolType == SymbolType.Ellipse)
                path.Data = CreateEllipse(width, height);
            else
                path.Data = CreateRectangle(width, height);

            path.Opacity = opacity;

            return path;
        }
예제 #4
0
        private void BtnNY_Click(object sender, RoutedEventArgs e)
        {
            this.xMapControl.Map = new Mapsui.Map();

            IProvider wShapeFile = new Mapsui.Desktop.Shapefile.ShapeFile("NYTOWNS_POLY.shp", true);

            var wLayerStyle = new Mapsui.Styles.VectorStyle();

            wLayerStyle.Fill = new Mapsui.Styles.Brush {
                FillStyle = FillStyle.Solid, Color = Mapsui.Styles.Color.Gray
            };
            wLayerStyle.Line = new Mapsui.Styles.Pen {
                Color = Mapsui.Styles.Color.Black, PenStyle = PenStyle.Solid
            };
            wLayerStyle.Outline = new Mapsui.Styles.Pen {
                Color = Mapsui.Styles.Color.Black, PenStyle = PenStyle.Solid
            };

            var wLayer = new Layer {
                Name = "NY Townships", DataSource = wShapeFile, Style = wLayerStyle, Enabled = true
            };

            this.xMapControl.Map.Layers.Add(wLayer);
            this.xMapControl.Refresh();


            this.xMapControl.Refresh();
        }
예제 #5
0
 protected BaseLayer()
 {
     Name = "Layer";
     Style = new VectorStyle();
     Enabled = true;
     MinVisible = 0;
     MaxVisible = double.MaxValue;
     Opacity = 1;
     Id = _instanceCounter++;
 }
예제 #6
0
 private static void DrawPointWithVectorStyle(VectorStyle vectorStyle, Point destination)
 {
     var color = vectorStyle.Fill.Color;
     GL.Color4((byte) color.R, (byte) color.G, (byte) color.B, (byte) color.A);
     GL.PointSize((float) SymbolStyle.DefaultWidth);
     GL.EnableClientState(All.VertexArray);
     var destAsArray = new[] {(float) destination.X, (float) destination.Y};
     GL.VertexPointer(2, All.Float, 0, destAsArray);
     GL.DrawArrays(All.Points, 0, 1);
     GL.DisableClientState(All.VertexArray);
 }
예제 #7
0
 public TileLayer(ITileSource source = null, int minTiles = 200, int maxTiles = 300, int maxRetries = TileFetcher.DefaultMaxAttempts,
     int maxThreads = TileFetcher.DefaultMaxThreads, IFetchStrategy fetchStrategy = null,
     IRenderGetStrategy renderFetchStrategy = null, int minExtraTiles = -1, int maxExtraTiles = -1)
 {
     _memoryCache = new MemoryCache<Feature>(minTiles, maxTiles);
     Style = new VectorStyle { Outline = { Color = Color.FromArgb(0, 0, 0, 0) } }; // initialize with transparent outline
     _maxRetries = maxRetries;
     _maxThreads = maxThreads;
     _fetchStrategy = fetchStrategy ?? new FetchStrategy();
     _renderFetchStrategy = renderFetchStrategy ?? new RenderGetStrategy();
     _minExtraTiles = minExtraTiles;
     _maxExtraTiles = maxExtraTiles;
     SetTileSource(source);
 }
예제 #8
0
		public static void Draw(CALayer target, IViewport viewport, IStyle style, IFeature feature)
		{
			var point = feature.Geometry as Geometries.Point;
			var dest = viewport.WorldToScreen(point);
            //var path = UIBezierPath.FromRect(new Rectangle((int)dest.X, (int)dest.Y, 20, 20));
            var path = CGPath.FromRect(new CGRect((float)dest.X, (float)dest.Y, 20, 20), CGAffineTransform.MakeIdentity());
            

            style = new VectorStyle();
            if (!feature.RenderedGeometry.Keys.Contains(style))
		    {
		        feature.RenderedGeometry[style] = CreateRenderedPoint();
		    }
            else
            {
                Console.WriteLine("test");
            }
		    var renderedGeometry = (CAShapeLayer) feature.RenderedGeometry[style];
		    renderedGeometry.Path = path;
            target.AddSublayer(renderedGeometry);
		}
예제 #9
0
        public TestLayer(string name)
            : base(name)
        {
            _source = new MemoryProvider();
            DataSource = _source;

            List<Location> locations = new List<Location>();
            locations.Add(new Location(-63.307, -23.203));
            locations.Add(new Location(-63.200, -23.203));
            locations.Add(new Location(-63.200, -23.350));
            locations.Add(new Location(-63.307, -23.350));
            locations.Add(new Location(-63.307, -23.203));

            var polygon = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(locations)) };
            
            var feature = new Feature { Geometry = polygon };

            var color = Color.Blue;

            if (name.Equals("08-may"))
            {
                color = Color.Green;
            }
            else if (name.Equals("03-jun"))
            {
                color = Color.Red;
            }

            var vStyle = new VectorStyle
            {
                Fill = new Brush { Color = color },
                Outline = new Pen { Color = Color.Black, Width = 0 },
            };

            feature.Styles.Add(vStyle);

            _source.Features.Add(feature);

            //Current.Instance.MapControl.OnViewChanged(true);
        }
예제 #10
0
        private void BtnOSMWithNY_Click(object sender, RoutedEventArgs e)
        {
            var customTrans = new CustomMinimalTransformation();

            customTrans.LoadSourceWKT("NYTOWNS_POLY.prj");

            //this.xMapControl.RenderMode = Mapsui.UI.Wpf.RenderMode.Wpf;
            this.xMapControl.Map = new Mapsui.Map()
            {
                CRS = "EPSG:3857", Transformation = customTrans
            };
            this.xMapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.BingHybrid)));

            IProvider wShapeFile = new Mapsui.Desktop.Shapefile.ShapeFile("NYTOWNS_POLY.shp", true)
            {
                CRS = "EPSG:CUSTOM"
            };

            var wLayerStyle = new Mapsui.Styles.VectorStyle();

            wLayerStyle.Fill = new Mapsui.Styles.Brush {
                FillStyle = FillStyle.Solid, Color = Mapsui.Styles.Color.Gray
            };
            wLayerStyle.Line = new Mapsui.Styles.Pen {
                Color = Mapsui.Styles.Color.Black, PenStyle = PenStyle.Solid
            };
            wLayerStyle.Outline = new Mapsui.Styles.Pen {
                Color = Mapsui.Styles.Color.Black, PenStyle = PenStyle.Solid
            };

            var wLayer = new Layer {
                Name = "NY Townships", DataSource = wShapeFile, Style = wLayerStyle, Enabled = true
            };

            this.xMapControl.Map.Layers.Add(wLayer);
            this.xMapControl.Refresh();
        }
예제 #11
0
        private void BtnOSMWithUS_Click(object sender, RoutedEventArgs e)
        {
            var customTrans = new CustomMinimalTransformation();

            customTrans.LoadSourceWKT(null);

            this.xMapControl.RenderMode = Mapsui.UI.Wpf.RenderMode.Wpf;
            this.xMapControl.Map        = new Mapsui.Map()
            {
                CRS = "EPSG:3857", Transformation = customTrans
            };
            this.xMapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.OpenStreetMap)));
            IProvider wShapeFile = new Mapsui.Desktop.Shapefile.ShapeFile("lower48.shp", true)
            {
                CRS = "EPSG:4326"
            };
            //IProvider wShapeFile = new Mapsui.Desktop.Shapefile.ShapeFile("lower48.shp", true);

            var wLayerStyle = new Mapsui.Styles.VectorStyle();

            wLayerStyle.Fill = new Mapsui.Styles.Brush {
                FillStyle = FillStyle.Solid, Color = Mapsui.Styles.Color.Orange
            };
            wLayerStyle.Line = new Mapsui.Styles.Pen {
                Color = Mapsui.Styles.Color.Black, PenStyle = PenStyle.Solid
            };
            wLayerStyle.Outline = new Mapsui.Styles.Pen {
                Color = Mapsui.Styles.Color.Red, PenStyle = PenStyle.Solid
            };

            var wLayer = new Layer {
                Name = "Lower 48 States", DataSource = wShapeFile, Style = wLayerStyle, Enabled = true
            };

            this.xMapControl.Map.Layers.Add(wLayer);
            this.xMapControl.Refresh();
        }
예제 #12
0
        void layerRequest_LayerRecived(object sender, EventArgs e)
        {
            isFirstTime = false;

            Polygon poligono;
            Earthwatchers.Models.KmlModels.Layer layer = sender as Earthwatchers.Models.KmlModels.Layer;
            if (layer != null)
            {
                foreach (Earthwatchers.Models.KmlModels.Zone zon in layer.Zones)
                {
                    if (zon.Name == "Zona Amarilla")
                    {
                        #region YellowArea

                        foreach (var p in zon.Polygons)
                        {
                            poligono = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(p.Locations.Select(l => new Location(l.Longitude.Value, l.Latitude.Value)).ToList())) };
                            var feature = new Feature { Geometry = poligono };
                            var vStyle = new VectorStyle
                            {
                                Fill = new Brush { Color = Color.FromArgb(58, 254, 238, 0) },
                                Outline = new Pen { Color = Color.FromArgb(0, 255, 255, 0), Width = 2 },
                            };
                            feature.Styles.Add(vStyle);
                            _source.Features.Add(feature);
                        }
                        #endregion
                    }
                    else if (zon.Name == "Zona Roja")
                    {
                        #region RedArea
                        foreach (var p in zon.Polygons)
                        {
                            poligono = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(p.Locations.Select(l => new Location(l.Longitude.Value, l.Latitude.Value)).ToList())) };
                            var feature = new Feature { Geometry = poligono };
                            var vStyle = new VectorStyle
                            {
                                Fill = new Brush { Color = Color.FromArgb(58, 255, 0, 0) },
                                Outline = new Pen { Color = Color.FromArgb(0, 255, 0, 0), Width = 2 },
                            };
                            feature.Styles.Add(vStyle);
                            _source.Features.Add(feature);
                        }
                        #endregion
                    }
                    else if (zon.Name == "Zona Verde")
                    {
                        #region GreenArea
                        foreach (var p in zon.Polygons)
                        {
                            poligono = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(p.Locations.Select(l => new Location(l.Longitude.Value, l.Latitude.Value)).ToList())) };
                            var feature = new Feature { Geometry = poligono };
                            var vStyle = new VectorStyle
                            {
                                Fill = new Brush { Color = Color.FromArgb(110, 0, 144, 69) },
                                Outline = new Pen { Color = Color.FromArgb(0, 3, 255, 3), Width = 2 },
                            };
                            feature.Styles.Add(vStyle);
                            _source.Features.Add(feature);
                        }
                        #endregion
                    }

                }
                Current.Instance.MapControl.OnViewChanged(true);
            }

            Loaded(this, EventArgs.Empty);
        }
예제 #13
0
        private VectorStyle GetVectorStyle(LandStatus status, bool isOwnLand)
        {
            Brush fill;
            Pen outline;

            switch (status)
            {
                case LandStatus.NotChecked:
                    fill = new Brush { Color = Color.White };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
                case LandStatus.Ok:
                    fill = new Brush { Color = Color.Green };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
                case LandStatus.Alert:
                    fill = new Brush { Color = Color.Red };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
                default:
                    fill = new Brush { Color = Color.Orange };
                    outline = new Pen { Color = Color.Black, Width = 2 };
                    break;
            }

            if (isOwnLand)
            {
                outline = new Pen { Color = Color.Orange, Width = 4 };
            }

            var vStyle = new VectorStyle
            {
                Fill = fill,
                Outline = outline,
            };
            vStyle.SetOpacity(opacity);
            return vStyle;
        }
예제 #14
0
        public static Map InitializeMap()
        {
            //Initialize a new map based on the simple map
            var map = new Map();

            //Layer osm = new Layer("OSM");
            //string url = "http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&amp;request=GetCapabilities&amp;service=wms-c";
            //var tileSources = TileSourceWmsC.TileSourceBuilder(new Uri(url), null);
            //var tileSource = new List<ITileSource>(tileSources).Find(source => source.Schema.Name == "osm-map");
            //osm.DataSource = new TileProvider(tileSource, "OSM");
            //map.Layers.Add(osm);

            //Set up countries layer
            var countryLayer = new Layer("Countries");
            //Set the datasource to a shapefile in the App_data folder
            countryLayer.DataSource = new ShapeFile("GeoData/World/countries.shp", true);
            countryLayer.DataSource.SRID = 4326;
            
            var style = new VectorStyle
            {
                Fill = new Brush { Color = Color.Green },
                Outline = new Pen { Color = Color.Black }
            };
            countryLayer.Styles.Add(style);
            map.Layers.Add(countryLayer);

            //set up cities layer
            var cityLayer = new Layer("Cities");
            //Set the datasource to a shapefile in the App_data folder
            cityLayer.DataSource = new ShapeFile("GeoData/World/cities.shp", true);
            cityLayer.DataSource.SRID = 4326;
            cityLayer.MaxVisible = 0.09;
            map.Layers.Add(cityLayer);

            //Set up a country label layer
            var countryLabelLayer = new LabelLayer("Country labels");
            countryLabelLayer.DataSource = countryLayer.DataSource;
            countryLabelLayer.DataSource.SRID = 4326;
            countryLabelLayer.Enabled = true;
            countryLabelLayer.MaxVisible = 0.18;
            countryLabelLayer.MinVisible = 0.054;
            countryLabelLayer.LabelColumn = "NAME";
            var labelStyle = new LabelStyle();
            labelStyle.ForeColor = Color.Black;
            labelStyle.Font = new Font { FontFamily = "GenericSerif", Size = 12 };
            labelStyle.BackColor = new Brush { Color = new Color { A = 128, R = 255, G = 255, B = 255 } };
            labelStyle.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center;
            countryLabelLayer.MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.Largest;
            countryLabelLayer.Styles.Add(labelStyle);
            map.Layers.Add(countryLabelLayer);

            //Set up a city label layer
            var cityLabelLayer = new LabelLayer("City labels");
            cityLabelLayer.DataSource = cityLayer.DataSource;
            cityLabelLayer.DataSource.SRID = 4326;
            cityLabelLayer.Enabled = true;
            cityLabelLayer.LabelColumn = "NAME";
            cityLabelLayer.MaxVisible = countryLabelLayer.MinVisible;
            cityLabelLayer.MinVisible = 0;
            cityLabelLayer.LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection;
            var cityLabelStyle = new LabelStyle();
            cityLabelStyle.ForeColor = Color.Black;
            cityLabelStyle.Font = new Font { FontFamily = "GenericSerif", Size = 11 };
            cityLabelStyle.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left;
            cityLabelStyle.VerticalAlignment = LabelStyle.VerticalAlignmentEnum.Bottom;
            cityLabelStyle.Offset = new Offset { X = 3, Y = 3 };
            cityLabelStyle.Halo = new Pen { Color = Color.Yellow, Width = 2 };
            cityLabelStyle.CollisionDetection = true;
            cityLabelLayer.Styles.Add(cityLabelStyle);
            map.Layers.Add(cityLabelLayer);

            //Set a gradient theme on the countries layer, based on Population density
            //First create two styles that specify min and max styles
            //In this case we will just use the default values and override the fill-colors
            //using a colorblender. If different line-widths, line- and fill-colors where used
            //in the min and max styles, these would automatically get linearly interpolated.
            IStyle min = new Style();
            IStyle max = new Style();
            //Create theme using a density from 0 (min) to 400 (max)
            var popdens = new GradientTheme("PopDens", 0, 400, min, max);
            //We can make more advanced coloring using the ColorBlend'er.
            //Setting the FillColorBlend will override any fill-style in the min and max fills.
            //In this case we just use the predefined Rainbow colorscale
            popdens.FillColorBlend = ColorBlend.Rainbow5;
            countryLayer.Styles.Add(popdens);

            //Lets scale the labels so that big countries have larger texts as well
            var lblMin = new LabelStyle();
            var lblMax = new LabelStyle();
            lblMin.ForeColor = Color.Black;
            lblMin.Font = new Font { FontFamily = "Sans Serif", Size = 6 };
            lblMax.ForeColor = Color.Black;
            lblMax.BackColor = new Brush { Color = new Color { A = 128, R = 255, G = 255, B = 255 } };
            lblMin.BackColor = lblMax.BackColor;
            lblMax.Font = new Font { FontFamily = "Sans Serif", Size = 9 };
            countryLabelLayer.Styles.Add(new GradientTheme("PopDens", 0, 400, lblMin, lblMax));

            //Lets scale city icons based on city population
            //cities below 1.000.000 gets the smallest symbol, and cities with more than 5.000.000 the largest symbol
            var citymin = new SymbolStyle();
            var citymax = new SymbolStyle();
            const string iconPath = "Images/icon.png";
            if (!File.Exists(iconPath))
            {
                throw new Exception(
                    String.Format("Error file '{0}' could not be found, make sure it is at the expected location",
                                  iconPath));
            }

            citymin.Symbol = new Bitmap { Data = new FileStream(iconPath, FileMode.Open, FileAccess.Read) };
            citymin.SymbolScale = 0.5f;
            citymax.Symbol = new Bitmap { Data = new FileStream(iconPath, FileMode.Open, FileAccess.Read) };
            citymax.SymbolScale = 1f;
            cityLayer.Styles.Add(new GradientTheme("Population", 1000000, 5000000, citymin, citymax));

            var geodanLayer = new Layer("Geodan");
            geodanLayer.DataSource = new MemoryProvider(new Point(4.9130567, 52.3422033));
            geodanLayer.Styles.Add(new SymbolStyle { Symbol = new Bitmap { Data = new FileStream(iconPath, FileMode.Open, FileAccess.Read) } });
            map.Layers.Add(geodanLayer);

            //limit the zoom to 360 degrees width
            map.BackColor = Color.White;

            return map;
        }
예제 #15
0
 private static void DrawPointWithVectorStyle(SKCanvas canvas, VectorStyle vectorStyle,
     Point destination, SymbolType symbolType = SymbolType.Ellipse)
 {
     canvas.Save();
     canvas.Translate((float)destination.X, (float)destination.Y);
     DrawPointWithVectorStyle(canvas, vectorStyle, symbolType);
     canvas.Restore();
 }
예제 #16
0
        private static void DrawPointWithVectorStyle(SKCanvas canvas, VectorStyle vectorStyle,
            SymbolType symbolType = SymbolType.Ellipse)
        {
            var fillPaint = new SKPaint
            {
                Color = vectorStyle.Fill.Color.ToSkia(),
                Style = SKPaintStyle.Fill,
                IsAntialias = true
            };

            var linePaint = (vectorStyle.Outline == null) ? null : new SKPaint
            {
                Color = vectorStyle.Outline.Color.ToSkia(),
                StrokeWidth = (float) vectorStyle.Outline.Width,
                Style = SKPaintStyle.Stroke,
                IsAntialias = true
            };

            if (symbolType == SymbolType.Rectangle)
            {
                var rect = new SKRect(-HalfWidth, -HalfHeight, HalfWidth, HalfHeight);
                DrawRect(canvas, rect, fillPaint, linePaint);
            }
            else if (symbolType == SymbolType.Ellipse)
            {

                DrawCircle(canvas, 0, 0, HalfWidth, fillPaint, linePaint);
            }
        }
예제 #17
0
        private static IThemeStyle CreateCountryTheme()
        {
            //Set a gradient theme on the countries layer, based on Population density
            //First create two styles that specify min and max styles
            //In this case we will just use the default values and override the fill-colors
            //using a colorblender. If different line-widths, line- and fill-colors where used
            //in the min and max styles, these would automatically get linearly interpolated.
            var min = new VectorStyle { Outline = new Pen { Color = Color.Black } };
            var max = new VectorStyle { Outline = new Pen { Color = Color.Black } };

            //Create theme using a density from 0 (min) to 400 (max)
            return new GradientTheme("PopDens", 0, 400, min, max) { FillColorBlend = ColorBlend.Rainbow5 };
        }
예제 #18
0
        private VectorStyle GetVectorStyle(LandStatus status, bool isOwnLand, bool demandAuthorities, bool ischecked, bool isGreenpeaceUser, bool islockedOnly, bool denouncedByMe)
        {
            Brush fill = null;
            Pen outline = null;

            switch (status)
            {
                case LandStatus.NotChecked:  //STATUS 2 SIN CHEQUEAR
                    fill = new Brush { Color = Color.FromArgb(255, 255, 255, 255) };
                    outline = new Pen { Color = Color.Black, Width = 1 };
                    break;
                case LandStatus.Ok: //STATUS 3 SIN DESMONTES
                    fill = new Brush { Color = Color.FromArgb(143, 121, 136, 35) };
                    outline = new Pen { Color = Color.FromArgb(255, 169, 183, 41), Width = 4 };
                    break;
                case LandStatus.Alert:  //STATUS 4 CON DESMONTES
                     fill = new Brush { Color = Color.FromArgb(143, 255, 236, 0) };
                outline = new Pen { Color = Color.FromArgb(255, 255, 242, 0), Width = 4 };
                    
                    break;
                default: //DEFAULT, IDEM SIN CHEQUEAR
                    fill = new Brush { Color = Color.FromArgb(255, 255, 255, 255) };
                    outline = new Pen { Color = Color.Black, Width = 1 };
                    break;
            }

            if (ischecked && (status == LandStatus.Alert || status == LandStatus.Ok)) //VERIFICADA POR MI DESMONTADA O SIN DESMONTE
            {
                outline = new Pen { Color = Color.FromArgb(0, 0, 0, 0), Width = 1 };
            }

            if (isOwnLand && (status != LandStatus.Alert && status != LandStatus.Ok))  //MI PROPIA LAND
            {
                outline = new Pen { Color = Color.White, Width = 4 };
            }

            if (demandAuthorities)  //LISTA PARA DEMANDAR
            {
                 fill = new Brush { Color = Color.FromArgb(143, 167, 11, 10) };
                 outline = new Pen { Color = Color.FromArgb(255, 217, 7, 7), Width = 4 };

                if (denouncedByMe)
                {
                    outline = new Pen { Color = Color.FromArgb(0, 0, 0, 0), Width = 1 };

                }
            }

            if (!demandAuthorities && islockedOnly)
            {
                outline = new Pen { Color = Color.FromArgb(0, 0, 0, 0), Width = 1 };
            }

            var vStyle = new VectorStyle
            {
                Fill = fill,
                Outline = outline,
            };

            if (opacity == 0)
            {
                vStyle.SetOpacity(0);
            }
            else
            {
                if (Current.Instance.MapControl.Viewport.Resolution > 2.4 || Current.Instance.MapControl.Viewport.Resolution == 0)
                {
                        vStyle.SetOpacity(opacity);
                }
                else
                {
                    vStyle.SetOpacity(0);
                }
            } 

            return vStyle;
        }
예제 #19
0
 private static void RenderGeometry(Graphics graphics, IViewport viewport, IGeometry feature, VectorStyle style)
 {
     if (feature is Point)
         GdiGeometryRenderer.DrawPoint(graphics, (Point)feature, style, viewport);
     else if (feature is MultiPoint)
         GdiGeometryRenderer.DrawMultiPoint(graphics, (MultiPoint) feature, style, viewport);
     else if (feature is LineString)
         GdiGeometryRenderer.DrawLineString(graphics, (LineString)feature, style.Line.Convert(), viewport);
     else if (feature is MultiLineString)
         GdiGeometryRenderer.DrawMultiLineString(graphics, (MultiLineString)feature, style.Line.Convert(), viewport);
     else if (feature is Polygon)
         GdiGeometryRenderer.DrawPolygon(graphics, (Polygon)feature, style.Fill.Convert(), style.Outline.Convert(), viewport);
     else if (feature is MultiPolygon)
         GdiGeometryRenderer.DrawMultiPolygon(graphics, (MultiPolygon)feature, style.Fill.Convert(), style.Outline.Convert(), viewport);
     else if (feature is IRaster)
         GdiGeometryRenderer.DrawRaster(graphics, feature as IRaster, viewport);
 }
예제 #20
0
        private static GradientTheme CreateCountryTheme()
        {
            //Set a gradient theme on the countries layer, based on Population density
            //First create two styles that specify min and max styles
            //In this case we will just use the default values and override the fill-colors
            //using a colorblender. If different line-widths, line- and fill-colors where used
            //in the min and max styles, these would automatically get linearly interpolated.
            var min = new VectorStyle();
            min.Outline = new Pen { Color = Color.Black };

            var max = new VectorStyle();
            max.Outline = new Pen { Color = Color.Black };

            //Create theme using a density from 0 (min) to 400 (max)
            var popdens = new GradientTheme("PopDens", 0, 400, min, max);
            //We can make more advanced coloring using the ColorBlend'er.
            //Setting the FillColorBlend will override any fill-style in the min and max fills.
            //In this case we just use the predefined Rainbow colorscale
            popdens.FillColorBlend = ColorBlend.Rainbow5;
            //countries.Styles.Clear(); //remove styles added earlier
            return popdens;
        }
예제 #21
0
 private static XamlShapes.Path CreatePolygonPath(VectorStyle style, double resolution)
 {
     var path = new XamlShapes.Path();
     if (style.Outline != null)
     {
         path.Stroke = new XamlMedia.SolidColorBrush(style.Outline.Color.ToXaml());
         path.StrokeThickness = style.Outline.Width * resolution;
         path.Tag = new double?(style.Outline.Width); // see #outlinehack
     }
     path.Fill = style.Fill.ToXaml();
     path.IsHitTestVisible = false;
     return path;
 }
예제 #22
0
 private static XamlShapes.Path CreateLineStringPath(VectorStyle style)
 {
     var path = new XamlShapes.Path();
     if (style.Outline != null)
     {
         //todo: render an outline around the line. 
     }
     path.Stroke = new XamlMedia.SolidColorBrush(style.Line.Color.ToXaml());
     path.StrokeThickness = style.Line.Width;
     path.Tag = new double?(style.Line.Width); // see #outlinehack
     path.IsHitTestVisible = false;
     return path;
 }
예제 #23
0
        private static XamlShapes.Shape CreateSymbolFromVectorStyle(VectorStyle style, double opacity = 1,
            SymbolType symbolType = SymbolType.Ellipse)
        {
            // The SL StrokeThickness default is 1 which causes blurry bitmaps
            var path = new XamlShapes.Path
            {
                StrokeThickness = 0,
                Fill = ToXaml(style.Fill)
            };

            if (style.Outline != null)
            {
                path.Stroke = new XamlMedia.SolidColorBrush(style.Outline.Color.ToXaml());
                path.StrokeThickness = style.Outline.Width;
                path.StrokeDashArray = style.Outline.PenStyle.ToXaml();
            }

            if (symbolType == SymbolType.Ellipse)
                path.Data = CreateEllipse(SymbolStyle.DefaultWidth, SymbolStyle.DefaultHeight);
            else
                path.Data = CreateRectangle(SymbolStyle.DefaultWidth, SymbolStyle.DefaultHeight);

            path.Opacity = opacity;

            return path;
        }