Inheritance: VectorStyle
Beispiel #1
0
        protected MapItem()
        {
            _points = new List<Point>();
            _pointsInFigures = new List<int>();

            _visible = true;
            _syncronized = false;
            _type = FigureType.Point;
            _opacity = 1.0;
            _outlineVisible = false;
            _color = Colors.Black;
            _borderColor = Colors.Black;
            _borderOpacity = 1.0;
            _size = 0.25;
            _lineWidth = 1;
            _outlineWidth = 1;

            _style = new SymbolStyle
            {
                Symbol = _imageSuorce == null ? null : new Bitmap { Data = _imageSuorce },
                Line = new Pen(GetColor(_color, _opacity), (float)_lineWidth),
                Outline = new Pen(_outlineVisible ? GetColor(_borderColor, _opacity) : System.Drawing.Color.Transparent, OutlineVisible ? 1 : 0),
                Fill = new SolidBrush(GetColor(_color, _opacity)),
                SymbolScale = _size,
            };
        }
Beispiel #2
0
        public static CGRect ConvertPointBoundingBox(SymbolStyle symbolStyle, BoundingBox boundingBox, IViewport viewport)
        {
            var screenMin = viewport.WorldToScreen(boundingBox.Min);
            var screenMax = viewport.WorldToScreen(boundingBox.Max);

            //boundingBox.Offset = symbolStyle.SymbolOffset;
            //var newMin = boundingBox.Min;
            //var newMax = boundingBox.Max;

            if (symbolStyle.SymbolOffset != null)
            {
                screenMin = new Geometries.Point(
                    screenMin.X - symbolStyle.SymbolOffset.X,
                    screenMin.Y - symbolStyle.SymbolOffset.Y);
                screenMax = new Geometries.Point(
                    screenMax.X - symbolStyle.SymbolOffset.X,
                    screenMax.Y - symbolStyle.SymbolOffset.Y);

                var w = viewport.ScreenToWorld(screenMin);

                boundingBox.Offset(new Geometries.Point(w.X - boundingBox.MinX, w.Y - boundingBox.MinY));

                screenMin = viewport.WorldToScreen(boundingBox.Min);
                screenMax = viewport.WorldToScreen(boundingBox.Max);
            }

            var min = new Geometries.Point(screenMin.X - (32 / 2), screenMax.Y - (32 / 2)); //!!!
            var max = new Geometries.Point((min.X + 32), (min.Y + 32)); //!!!

            var frame = RoundToPixel(min, max);
            //if(symbolStyle.SymbolOffset != null)
            //	frame.Offset ((float)symbolStyle.SymbolOffset.X, (float)symbolStyle.SymbolOffset.Y);

            return frame;
        }
        public void DrawMarkers(IEnumerable<Land> landPieces)
        {
            if (landPieces == null) return;

            ClearGraphics();

            if (Current.Instance.MapControl.Viewport.Resolution > 50)
            {
                return;
            }

            foreach (var land in landPieces.Where(x => x.DemandAuthorities))
            {
                var sphericalMid = SphericalMercator.FromLonLat(land.Longitude, land.Latitude);
                var feature = new Feature
                {
                    Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y),
                };
                
                var offset = new Offset();
                offset.X = 100;
                double scale = 19.109256744384766 / Current.Instance.MapControl.Viewport.Resolution;
                //var symbolStyle = new SymbolStyle { Symbol = GetSymbol("demandar.png"), SymbolType = SymbolType.Rectangle, SymbolOffset = offset, SymbolScale = scale };
                var symbolStyle = new SymbolStyle { Symbol = GetSymbol("demandar.png"), SymbolScale = 1 };
                feature.Styles.Add(symbolStyle);

                source.Features.Add(feature);
            }

            Current.Instance.MapControl.OnViewChanged(true);
        }
Beispiel #4
0
 private static IThemeStyle CreateCityTheme()
 {
     // Scaling city icons based on city population.
     // Cities below 1.000.000 gets the smallest symbol.
     // Cities with more than 5.000.000 the largest symbol.
     var localAssembly = Assembly.GetAssembly(typeof(ShapefileSample));
     var bitmapStream = localAssembly.GetManifestResourceStream("Mapsui.Samples.Common.Desktop.Images.icon.png");
     var bitmapId = BitmapRegistry.Instance.Register(bitmapStream);
     var citymin = new SymbolStyle {BitmapId = bitmapId, SymbolScale = 0.5f};
     var citymax = new SymbolStyle {BitmapId = bitmapId, SymbolScale = 1f};
     return new GradientTheme("Population", 1000000, 5000000, citymin, citymax);
 }
        private void DrawNames()
        {
            ClearNames();
            //Cargo los puntos de cada finca
            if (_fincas != null)
            {
                foreach (var f in _fincas)
                {
                    var sphericalMid = SphericalMercator.FromLonLat(f.Longitude, f.Latitude);
                    var feature = new Feature
                    {
                        Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y)
                    };

                    var res = Current.Instance.MapControl.Viewport.Resolution;
                    //Cargo las distintas imagenes a niveles de zoom
                    if (res > 2.79 && res <= 19.21)
                    {
                        var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/"+f.Id.ToString()+"_1.png"), SymbolType = SymbolType.Rectangle };
                        feature.Styles.Add(symbolStyle);
                        _source.Features.Add(feature);
                    }
                    //else if (res > 19.21 && res <= 38.22)
                    else if (res > 19.21 && res <= 305)
                    {
                        var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_2.png"), SymbolType = SymbolType.Rectangle };
                        feature.Styles.Add(symbolStyle);
                        _source.Features.Add(feature);
                    }
                    //else if (res > 38.22 && res <= 76.48)
                    //{
                    //    var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_3.png"), SymbolType = SymbolType.Rectangle };
                    //    feature.Styles.Add(symbolStyle);
                    //    _source.Features.Add(feature);
                    //}
                    //else if (res > 76.48 && res <= 153)
                    //{
                    //    var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_4.png"), SymbolType = SymbolType.Rectangle };
                    //    feature.Styles.Add(symbolStyle);
                    //    _source.Features.Add(feature);
                    //}
                    //else if (res > 153 && res <= 305)
                    //{
                    //    var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_5.png"), SymbolType = SymbolType.Rectangle };
                    //    feature.Styles.Add(symbolStyle);
                    //    _source.Features.Add(feature);
                    //}
                }
            }
            Current.Instance.MapControl.OnViewChanged(true);

        }
Beispiel #6
0
        public bool Equals(SymbolStyle symbolStyle)
        {
            if (!base.Equals(symbolStyle))
            {
                return(false);
            }


            if (BitmapId == symbolStyle.BitmapId)
            {
                return(false);
            }

            if (!SymbolScale.Equals(SymbolScale))
            {
                return(false);
            }

            if ((SymbolOffset == null) ^ (symbolStyle.SymbolOffset == null))
            {
                return(false);
            }

            if ((SymbolOffset != null) && (!SymbolOffset.Equals(symbolStyle.SymbolOffset)))
            {
                return(false);
            }

            if (Math.Abs(SymbolRotation - symbolStyle.SymbolRotation) > Utilities.Constants.Epsilon)
            {
                return(false);
            }

            if (UnitType != symbolStyle.UnitType)
            {
                return(false);
            }

            if (SymbolType != symbolStyle.SymbolType)
            {
                return(false);
            }

            if (Math.Abs(Opacity - symbolStyle.Opacity) > Utilities.Constants.Epsilon)
            {
                return(false);
            }

            return(true);
        }
        private Map CreateMap()
        {
            var map = new Map();
            
            var osmLayer = new TileLayer(new OsmTileSource()) { LayerName = "OSM" };
            map.Layers.Add(osmLayer);

            var pointLayer = PointLayerSample.CreateRandomPointLayer(map.Envelope, 600);
            var bitmapData = System.Reflection.Assembly.GetExecutingAssembly()
              .GetManifestResourceStream("Mapsui.Silverlight.UI.Images.btnBbox.png");
            var symbolStyle = new SymbolStyle { Symbol = new Bitmap { Data = bitmapData } };
            pointLayer.Styles.Add(symbolStyle);
            map.Layers.Add(pointLayer);

            return map;
        }
Beispiel #8
0
        private void DrawJaguar()
        {
            var jaguarGame = Current.Instance.JaguarGame;
            if (jaguarGame != null)
            {
                ClearJaguar();
                var sphericalMid = SphericalMercator.FromLonLat(jaguarGame.Longitude, jaguarGame.Latitude);
                var feature = new Feature
                {
                    Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y)
                };
                var symbolStyle = new SymbolStyle { Symbol = GetSymbol("jaguar.png"), SymbolType = SymbolType.Rectangle };
                feature.Styles.Add(symbolStyle);
                _source.Features.Add(feature);

                Current.Instance.MapControl.OnViewChanged(true);
            }
        }
Beispiel #9
0
        private static XamlMedia.Matrix CreatePointSymbolMatrix(double resolution, SymbolStyle symbolStyle)
        {
            var matrix = XamlMedia.Matrix.Identity;
            MatrixHelper.InvertY(ref matrix);
            var centerX = symbolStyle.SymbolOffset.X;
            var centerY = symbolStyle.SymbolOffset.Y;

            var scale = symbolStyle.SymbolScale;
            MatrixHelper.Translate(ref matrix, centerX, centerY);
            MatrixHelper.ScaleAt(ref matrix, scale, scale);

            //for point symbols we want the size to be independent from the resolution. We do this by counter scaling first.
            if (symbolStyle.UnitType != UnitType.WorldUnit)
                MatrixHelper.ScaleAt(ref matrix, resolution, resolution);
            MatrixHelper.RotateAt(ref matrix, -symbolStyle.SymbolRotation);

            return matrix;
        }
Beispiel #10
0
        private static void DrawPointWithSymbolStyle(SymbolStyle symbolStyle, Point destination, IDictionary<int, TextureInfo> bitmapCache)
        {
            TextureInfo textureInfo;
            if (!bitmapCache.Keys.Contains(symbolStyle.BitmapId))
            {
                textureInfo = TextureHelper.LoadTexture(BitmapRegistry.Instance.Get(symbolStyle.BitmapId));
                bitmapCache[symbolStyle.BitmapId] = textureInfo;
            }
            else
            {
                textureInfo = bitmapCache[symbolStyle.BitmapId];
            }

            TextureHelper.RenderTexture(textureInfo, (float)destination.X, (float)destination.Y, 
                (float)symbolStyle.SymbolRotation, 
                (float)symbolStyle.SymbolOffset.X, (float)symbolStyle.SymbolOffset.Y, 
                opacity:(float)symbolStyle.Opacity, scale:(float)symbolStyle.SymbolScale);
        }
Beispiel #11
0
        private static void RenderBitmapPoint(Graphics graphics, Point point, IViewport viewport, SymbolStyle symbolStyle)
        {
            var symbol = new Bitmap(BitmapRegistry.Instance.Get(symbolStyle.BitmapId));
            var symbolscale = symbolStyle.SymbolScale;
            var offset = symbolStyle.SymbolOffset.ToGdi();
            var rotation = symbolStyle.SymbolRotation;
            var dest = ConvertPoint(viewport.WorldToScreen(point));

            var width = symbol.Width * symbolscale;
            var height = symbol.Height * symbolscale;

            graphics.TranslateTransform(dest.X, dest.Y);
            graphics.RotateTransform((float)rotation);
            graphics.TranslateTransform(offset.X, -offset.Y);
            graphics.TranslateTransform((int)(-width / 2.0), (int)(-height / 2.0));

            graphics.DrawImage(symbol, 0, 0, (float)width, (float)height);
            graphics.ResetTransform();
        }
        private static IThemeStyle CreateCityTheme()
        {
            //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 = "Resources\\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;
            return new GradientTheme("Population", 1000000, 5000000, citymin, citymax);
        }
        private void DrawMarkers(IEnumerable<Land> landPieces)
        {
            if (landPieces == null) return;

            ClearGraphics();

            foreach (var land in landPieces)
            {
                var sphericalMid = SphericalMercator.FromLonLat(land.Longitude, land.Latitude);
                var feature = new Feature
                {
                    Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y)
                };
                var symbolStyle = new SymbolStyle { Symbol = GetSymbol("warning.png"), SymbolType = SymbolType.Rectangle};
                feature.Styles.Add(symbolStyle);

                source.Features.Add(feature);
            }

            Current.Instance.MapControl.OnViewChanged(true);
        }
Beispiel #14
0
        private static void DrawPointWithBitmapStyle(SKCanvas canvas, SymbolStyle symbolStyle, Point destination,
            IDictionary<int, SKBitmapInfo> symbolBitmapCache)
        {
            var stream = BitmapRegistry.Instance.Get(symbolStyle.BitmapId);
            stream.Position = 0;
            SKBitmapInfo textureInfo;
            if (!symbolBitmapCache.Keys.Contains(symbolStyle.BitmapId))
            {
                textureInfo = BitmapHelper.LoadTexture(BitmapRegistry.Instance.Get(symbolStyle.BitmapId));
                symbolBitmapCache[symbolStyle.BitmapId] = textureInfo;
            }
            else
            {
                textureInfo = symbolBitmapCache[symbolStyle.BitmapId];
            }

            BitmapHelper.RenderTexture(canvas, textureInfo.Bitmap,
                (float) destination.X, (float) destination.Y,
                (float) symbolStyle.SymbolRotation,
                (float) symbolStyle.SymbolOffset.X, (float) symbolStyle.SymbolOffset.Y,
                opacity: (float) symbolStyle.Opacity, scale: (float) symbolStyle.SymbolScale);
        }
        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;
        }
Beispiel #16
0
        public bool Equals(SymbolStyle symbolStyle)
        {
            if (!base.Equals(symbolStyle))
            {
                return false;
            }

            if (BitmapId != symbolStyle.BitmapId)
            {
                return false;
            }

            if (!SymbolScale.Equals(SymbolScale))
            {
                return false;
            }

            if ((SymbolOffset == null) ^ (symbolStyle.SymbolOffset == null))
            {
                return false;
            }

            if ((SymbolOffset != null) && (!SymbolOffset.Equals(symbolStyle.SymbolOffset)))
            {
                return false;
            }

            if (Math.Abs(SymbolRotation - symbolStyle.SymbolRotation) > Utilities.Constants.Epsilon)
            {
                return false;
            }

            if (UnitType != symbolStyle.UnitType)
            {
                return false;
            }

            if (SymbolType != symbolStyle.SymbolType)
            {
                return false;
            }

            if (Math.Abs(Opacity - symbolStyle.Opacity) > Utilities.Constants.Epsilon)
            {
                return false;
            }

            return true;
        }
Beispiel #17
0
		private static void SetFeatureOutline(IFeature feature,string layerName, int featureCount)
		{
			var renderedGeometry = feature[layerName];

			if(renderedGeometry != null){
				var caLayer = renderedGeometry as MonoTouch.CoreAnimation.CALayer;

				if (featureCount == 1) {
					caLayer.BorderColor = new MonoTouch.CoreGraphics.CGColor (0, 0, 0, 0);
				} else if(featureCount > 1 && featureCount < 4) {
					caLayer.BorderColor = new MonoTouch.CoreGraphics.CGColor (0, 100, 100, 255);
				} else if(featureCount > 4 && featureCount <= 8) {
					caLayer.BorderColor = new MonoTouch.CoreGraphics.CGColor (0, 0, 255, 255);
				} else if(featureCount > 8 && featureCount <= 16) {
					caLayer.BorderColor = new MonoTouch.CoreGraphics.CGColor (0, 255, 0, 255);
				} else if(featureCount > 16) {
					caLayer.BorderColor = new MonoTouch.CoreGraphics.CGColor (255, 0, 0, 255);
				}
			} else {
				var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
				var style = styles.FirstOrDefault () as SymbolStyle;

				if (style == null)
					style = new SymbolStyle ();

				if(featureCount > 1 && featureCount < 4) {
					style.Outline = new Pen { Width = 2, Color = new Color { A = 255, R = 100, G = 100, B = 0 } };
				} else if(featureCount > 4 && featureCount <= 8) {
					style.Outline = new Pen { Width = 2, Color = new Color { A = 255, R = 0, G = 0, B = 255 } };
				} else if(featureCount > 8 && featureCount <= 16) {
					style.Outline = new Pen { Width = 2, Color = new Color { A = 255, R = 0, G = 255, B = 0 } };
				} else if(featureCount > 16) {
					style.Outline = new Pen { Width = 2, Color = new Color { A = 255, R = 255, G = 0, B = 0 } };
				}
			}
		}
        private static XamlMedia.Geometry ConvertSymbol(Point point, SymbolStyle style, IViewport viewport)
        {
            Point p = viewport.WorldToScreen(point);

            var rect = new XamlMedia.RectangleGeometry();
            if (style.Symbol != null)
            {
                var bitmapImage = CreateBitmapImage(style.Symbol.Data);
                var width = bitmapImage.PixelWidth * style.SymbolScale;
                var height = bitmapImage.PixelHeight * style.SymbolScale;
                rect.Rect = new Rect(p.X - width * 0.5, p.Y - height * 0.5, width, height);
            }

            return rect;
        }
        private static XamlShapes.Path CreatePointPath(SymbolStyle style)
        {
            //todo: use this:
            //style.Symbol.Convert();
            //style.SymbolScale;
            //style.SymbolOffset.Convert();
            //style.SymbolRotation;

            var path = new XamlShapes.Path();

            if (style.Symbol == null)
            {
                path.Fill = new XamlMedia.SolidColorBrush(XamlColors.Gray);
            }
            else
            {
                BitmapImage bitmapImage = CreateBitmapImage(style.Symbol.Data);

                path.Fill = new XamlMedia.ImageBrush { ImageSource = bitmapImage };

                //Changes the rotation of the symbol
                var rotation = new XamlMedia.RotateTransform
                    {
                        Angle = style.SymbolRotation,
                        CenterX = bitmapImage.PixelWidth * style.SymbolScale * 0.5,
                        CenterY = bitmapImage.PixelHeight * style.SymbolScale * 0.5
                    };
                path.RenderTransform = rotation;
            }

            if (style.Outline != null)
            {
                path.Stroke = new XamlMedia.SolidColorBrush(style.Outline.Color.ToXaml());
                path.StrokeThickness = style.Outline.Width;
            }
            path.IsHitTestVisible = false;
            return path;
        }
Beispiel #20
0
 private static SymbolStyle ToSymbolStyle(IStyle style)
 {
     var symbolStyle = style as SymbolStyle;
     if (symbolStyle != null) return symbolStyle;
     var vectorStyle = style as VectorStyle;
     if (vectorStyle == null)
         symbolStyle = new SymbolStyle();
     else
         symbolStyle = new SymbolStyle
         {
             Fill = vectorStyle.Fill,
             Outline = vectorStyle.Outline,
             Line = vectorStyle.Line
         };
     return symbolStyle;
 }
Beispiel #21
0
        private static void DrawSymbol(Graphics graphics, SymbolStyle symbolStyle, StyleContext context)
        {
            using (var fill = symbolStyle.Fill.ToGdi(context))
            {
                if (symbolStyle.SymbolType == SymbolType.Rectangle)
                {
                    graphics.FillRectangle(fill, 0, 0, (int)symbolStyle.Width, (int)symbolStyle.Height);
                }
                else
                {
                    graphics.FillEllipse(fill, 0, 0, (int)symbolStyle.Width, (int)symbolStyle.Height);

                    if (symbolStyle.Outline != null)
                    {
                        using (var outline = symbolStyle.Outline.ToGdi(context))
                        {
                            graphics.DrawEllipse(outline, 0, 0, (int)symbolStyle.Width, (int)symbolStyle.Height);
                        }
                    }
                }
            }
        }
 public AnimatedPointsWithAutoUpdateLayer()
     : base(new DynamicMemoryProvider())
 {
     Style = new SymbolStyle {Fill = {Color = new Color(255, 215, 0, 200)}, SymbolScale = 0.9};
     _timer = new Timer(arg => UpdateData(), this, 0, 2000);
 }
Beispiel #23
0
        private static CALayer CreateSymbolFromBitmap(SymbolStyle style)
        {
            var symbol = new CALayer();
			var image = ToUIImage(BitmapRegistry.Instance.Get(style.BitmapId));

            symbol.Contents = image.CGImage;
            symbol.Frame = new CGRect(-image.Size.Width * 0.5f, -image.Size.Height * 0.5f, image.Size.Width, image.Size.Height);

            symbol.Opacity = (float)style.Opacity;

            return symbol;
        }
 private static XamlMedia.GeometryGroup ConvertMultiPoint(MultiPoint multiPoint, SymbolStyle style, IViewport viewport)
 {
     var group = new XamlMedia.GeometryGroup();
     foreach (Point point in multiPoint)
         group.Children.Add(ConvertSymbol(point, style, viewport));
     return group;
 }
Beispiel #25
0
        private void DrawFlags(IEnumerable<Flag> flags)
        {
            if (flags == null) return;

            ClearGraphics();

            foreach (var flag in flags)
            {
                var bmpName = "flag_shadow.png";
                
                if(Current.Instance.Earthwatcher != null)
                    if(Current.Instance.Earthwatcher.Name.Equals(flag.UserName))
                        bmpName = "flag_shadow_red.png";

                var sphericalMid = SphericalMercator.FromLonLat(flag.Longitude, flag.Latitude);
                var feature = new Feature
                {
                    Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y)
                };
                var symbolStyle = new SymbolStyle { Symbol = GetSymbol(bmpName) ,SymbolType = SymbolType.Rectangle, SymbolOffset = new Offset{X = 9f, Y = 0f}};

                feature.Styles.Add(symbolStyle);
                feature["longitude"] = flag.Longitude;
                feature["latitude"] = flag.Latitude;
                feature["comment"] = flag.Comment;
                feature["flagid"] = flag.Id;
                feature["username"] = flag.UserName;
                _source.Features.Add(feature);
            }

            Current.Instance.MapControl.OnViewChanged(true);
        }
Beispiel #26
0
 private static void DrawPointWithSymbolStyle(SKCanvas canvas, SymbolStyle style,
     Point destination, SymbolType symbolType = SymbolType.Ellipse)
 {
     canvas.Save();
     canvas.Translate((float)destination.X,(float)destination.Y);
     canvas.Scale((float)style.SymbolScale, (float)style.SymbolScale);
     DrawPointWithVectorStyle(canvas, style, symbolType);
     canvas.Restore();
 }