Exemple #1
0
        private void SetupMap()
        {
            FactLocations = new FeatureDataTable();
            FactLocations.Columns.Add("MapLocation", typeof(MapLocation));
            FactLocations.Columns.Add("ViewPort", typeof(Envelope));
            FactLocations.Columns.Add("Label", typeof(string));

            clusterer = new MarkerClusterer(FactLocations);
            GeometryFeatureProvider factLocationGFP = new GeometryFeatureProvider(clusterer.FeatureDataTable);

            clusterLayer            = new VectorLayer("Clusters");
            clusterLayer.DataSource = factLocationGFP;

            Dictionary <string, IStyle> styles = new Dictionary <string, IStyle>();

            VectorStyle feature = new VectorStyle();

            feature.PointColor   = new SolidBrush(Color.Red);
            feature.PointSize    = 20;
            feature.Symbol       = Image.FromFile(Path.Combine(Application.StartupPath, @"Resources\Icons\teardrop_blue.png"));
            feature.SymbolOffset = new PointF(0.0f, -17.0f);
            styles.Add(MapCluster.FEATURE, feature);

            VectorStyle cluster = new VectorStyle();

            cluster.PointColor = new SolidBrush(Color.ForestGreen);
            cluster.PointSize  = 20;
            cluster.Symbol     = Image.FromFile(Path.Combine(Application.StartupPath, @"Resources\Icons\people35.png"));
            styles.Add(MapCluster.CLUSTER, cluster);

            VectorStyle unknown = new VectorStyle();

            unknown.PointColor = new SolidBrush(Color.Black);
            unknown.PointSize  = 10;
            styles.Add(MapCluster.UNKNOWN, unknown);

            clusterLayer.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme <string>("Cluster", styles, unknown);
            map.Layers.Add(clusterLayer);

            labelLayer            = new LabelLayer("Label");
            labelLayer.DataSource = factLocationGFP;
            labelLayer.Enabled    = true;
            //Specifiy field that contains the label string.
            labelLayer.LabelColumn       = "Label";
            labelLayer.TextRenderingHint = TextRenderingHint.AntiAlias;
            labelLayer.SmoothingMode     = SmoothingMode.AntiAlias;
            LabelStyle style = new LabelStyle();

            style.ForeColor           = Color.Black;
            style.Font                = new Font(FontFamily.GenericSerif, 14, FontStyle.Bold);
            style.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center;
            style.VerticalAlignment   = LabelStyle.VerticalAlignmentEnum.Bottom;
            style.CollisionDetection  = true;
            style.Offset              = new PointF(0, 17);
            style.Halo                = new Pen(Color.Yellow, 3);
            labelLayer.Style          = style;
            map.Layers.Add(labelLayer);
        }
Exemple #2
0
        private LayerCollection CreateGraticuleLayers()
        {
            var layers = new LayerCollection();

            // Graticule Layer
            var graticuleLyr = new VectorLayer("Graticule");

            graticuleLyr.DataSource       = CreateGraticuleDatasource();
            graticuleLyr.Style.Line.Color = Color.DarkSlateGray;
            var majorIntStyle = new VectorStyle()
            {
                Line = new System.Drawing.Pen(Brushes.DarkBlue, 2)
            };

            var minorIntStyle = new VectorStyle()
            {
                Line = new System.Drawing.Pen(Brushes.DarkSlateGray, 1)
                {
                    DashStyle = DashStyle.Dash
                }
            };

            //Create the theme items
            var dictStyles = new Dictionary <bool, SharpMap.Styles.IStyle>();

            dictStyles.Add(true, majorIntStyle);
            dictStyles.Add(false, minorIntStyle);

            //Assign the theme
            graticuleLyr.Theme =
                new SharpMap.Rendering.Thematics.UniqueValuesTheme <bool>("Major", dictStyles, minorIntStyle);
            layers.Add(graticuleLyr);

            // labels
            var labelLyr = new LabelLayer("Graticule Labels");

            labelLyr.DataSource          = graticuleLyr.DataSource;
            labelLyr.LabelColumn         = "Label";
            labelLyr.LabelStringDelegate = row => ((bool)row["Major"] ? (string)row["Label"] : "");

            var labelStyle = (LabelStyle)labelLyr.Style;

            labelStyle.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left;
            labelStyle.VerticalAlignment   = LabelStyle.VerticalAlignmentEnum.Bottom;

//            labelLyr.Style = new LabelStyle();
//            labelLyr.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.SimpleCollisionDetection;
//            labelLyr.Style.CollisionDetection = true;
//            labelLyr.Style.CollisionBuffer = new SizeF(2, 2);
//            labelLyr.Style.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left;
//            labelLyr.Styletyle.VerticalAlignment = LabelStyle.VerticalAlignmentEnum.Bottom;


            layers.Add(labelLyr);

            return(layers);
        }
 public FeatureInteractor(ILayer layer, IFeature feature, VectorStyle vectorStyle, IEditableObject editableObject)
 {
     Layer                  = layer;
     SourceFeature          = feature;
     VectorStyle            = vectorStyle;
     FeatureRelationEditors = new List <IFeatureRelationInteractor>();
     EditableObject         = editableObject;
     CreateTrackers();
 }
Exemple #4
0
        public void KmlFileTest2()
        {
            GeoAPI.GeometryServiceProvider.Instance = NetTopologySuite.NtsGeometryServices.Instance;
            //var kml = KmlProvider.FromKmz(@"C:\Workspace\huas\snotelwithlabels.kmz");
            var kml = KmlProvider.FromKml(@"C:\Workspace\huas\2010上海50KM毅行.kml");

            //var kml = KmlProvider.FromKmz(@"C:\Workspace\huas\test2_MapToKML.kmz");
            //var kml = KmlProvider.FromKmz(@"C:\Workspace\huas\Polygontwo_LayerToKML.kmz");
            Assert.IsNotNull(kml);
            var folder = kml.GetRoot();
            Dictionary <string, TypeAndStyle> dic = new Dictionary <string, TypeAndStyle>();

            kml.GetObjectIDsInViewForSList(kml.GetExtents()).ForEach(x =>
            {
                var dr      = kml.GetFeature(x);
                var style   = kml.GetKmlStyle(dr);
                var styleid = (string)dr["StyleUrl"];
                var place   = (Placemark)dr.ItemArray[2];
                //Console.WriteLine($"styleid:{styleid},{place.StyleUrl.ToString()}");
                if (style != null && !string.IsNullOrEmpty(styleid) && !dic.ContainsKey(styleid))
                {
                    dic.Add(styleid, new TypeAndStyle(kml.GetGeometryType(place?.Id), style));
                }
            });

            Console.WriteLine($"styleCount:{dic.Count}");
            dic.ToList().ForEach(x =>
            {
                VectorStyle style = x.Value.Style;
                Console.WriteLine($"styleid:{x.Key},type:{x.Value.Type}");
                if (x.Value.Type.Equals("esriGeometryPolygon"))
                {
                    var fill    = (SolidBrush)style.Fill;
                    var outline = style.Outline;
                    Console.WriteLine($"color:{fill.Color.R},{fill.Color.G},{fill.Color.B},{fill.Color.A},  " +
                                      $"outline:{outline.Color.R},{outline.Color.G},{outline.Color.B},{outline.Color.A}, width:{outline.Width}");
                }
                else if (x.Value.Type.Equals("esriGeometryPolyline"))
                {
                    var line = style.Line;
                    Console.WriteLine($"linecolor:{line.Color.R},{line.Color.G},{line.Color.B},{line.Color.A}, width:{line.Width}, offset:{style.LineOffset}");
                }
                else if (x.Value.Type.Equals("esriGeometryPoint"))
                {
                    var url = kml.GetIconUrl(x.Key);
                    Console.WriteLine($"url:{url}");
                    if (!string.IsNullOrEmpty(url) && !url.Contains("http"))
                    {
                        var image = kml.GetImageFromKmz(url);
                        if (image != null)
                        {
                            Console.WriteLine($"image height:{image.Height} width:{image.Width} ");
                        }
                    }
                }
            });
        }
Exemple #5
0
 public FeatureEditor(ICoordinateConverter coordinateConverter, ILayer layer, IFeature feature, VectorStyle vectorStyle, IEditableObject editableObject)
 {
     CoordinateConverter = coordinateConverter;
     Layer          = layer;
     SourceFeature  = feature;
     VectorStyle    = vectorStyle;
     TopologyRules  = new List <IFeatureRelationEditor>();
     EditableObject = editableObject;
 }
Exemple #6
0
 protected override void OnInitializeDefaultStyle()
 {
     Style = new VectorStyle
     {
         GeometryType = typeof(ILineString),
         Fill         = new SolidBrush(Color.Tomato),
         Line         = new Pen(Color.SteelBlue, 3)
     };
 }
Exemple #7
0
        /// <summary>
        /// Method to render <paramref name="feature"/> using <paramref name="style"/>
        /// </summary>
        /// <param name="g">The graphics object</param>
        /// <param name="map">The map</param>
        /// <param name="feature">The feature's geometry</param>
        /// <param name="style">The style to apply</param>
        protected void RenderGeometry(IGraphics g, Map map, IGeometry feature, VectorStyle style)
        {
            if (feature == null)
            {
                return;
            }

            Renderer.Draw(map, g, feature, style, ClippingEnabled);
        }
Exemple #8
0
            public WorkingRadiusFeature(AttractorObject attractor)
            {
                Attractor = attractor;

                style = new VectorStyle();
                Styles.Add(style);

                Update();
            }
Exemple #9
0
 public SubEntradaLeyendaTematica(string uid, VectorStyle simb, object valorTematico, object valorOrdenacion, string titulo)
 {
     _uid             = uid;
     _simbLinea       = simb.Outline;
     _simbRelleno     = simb.Fill;
     _valorTematico   = valorTematico;
     _valorOrdenacion = valorOrdenacion;
     _titulo          = titulo;
 }
Exemple #10
0
        public static CategorialTheme CreateCategorialTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
                                                            int numberOfClasses, IList <IComparable> values, List <string> categories, int sizeMin, int sizeMax)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle
                {
                    GeometryType = typeof(IPolygon)
                };
            }

            var categorialTheme = new CategorialTheme(attribute, defaultStyle);

            for (int i = 0; i < numberOfClasses; i++)
            {
                string label = (categories != null)
                                   ? categories[i]
                                   : values[i].ToString();

                Color color = (numberOfClasses > 1)
                                  ? blend.GetColor((float)i / (numberOfClasses - 1))
                                  : ((SolidBrush)defaultStyle.Fill).Color;

                var vectorStyle = (VectorStyle)defaultStyle.Clone();

                var size = sizeMin + (sizeMax - sizeMin) * i / (float)numberOfClasses;

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    vectorStyle.Fill       = new SolidBrush(color);
                    vectorStyle.Line.Width = 16;
                    vectorStyle.Shape      = defaultStyle.Shape;
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                CategorialThemeItem categorialThemeItem = (values[i] != null)
                                                              ? new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol, values[i])
                                                              : new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol);


                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return(categorialTheme);
        }
        private IStyle GetLinkLayerStyle()
        {
            var s = new VectorStyle();

            s.Line          = new Mapsui.Styles.Pen();
            s.Line.PenStyle = PenStyle.Solid;
            s.Line.Color    = Colors.Black.ToMapsui();
            s.Line.Width    = 1.0;
            return(s);
        }
Exemple #12
0
 /// <summary>
 /// Creates a BaseLayer without a name
 /// </summary>
 protected BaseLayer()
 {
     Name       = "Layer";
     Style      = new VectorStyle();
     Enabled    = true;
     MinVisible = 0;
     MaxVisible = double.MaxValue;
     Opacity    = 1;
     Id         = _instanceCounter++;
 }
Exemple #13
0
        public DiscreteGridPointCoverageLayer()
        {
            Name    = "Grid Points";
            Enabled = true;
            Style   = new VectorStyle {
                GeometryType = typeof(IPoint), Shape = ShapeType.Ellipse, ShapeSize = 4
            };

            pen = Pens.LightGreen;
        }
Exemple #14
0
        private void GenerateTheme()
        {
            var minVectorStyle = new VectorStyle();
            var maxVectorStyle = new VectorStyle();

            minVectorStyle.Fill = new SolidBrush(Color.Red);
            maxVectorStyle.Fill = new SolidBrush(Color.Blue);

            Theme = new GradientTheme("Red to Blue", values.Min(), values.Max(), minVectorStyle, maxVectorStyle, null, null, null);
        }
        private VectorStyle GetLinkLayerStyle()
        {
            var s = new VectorStyle();

            s.Line          = new Mapsui.Styles.Pen();
            s.Line.PenStyle = PenStyle.Solid;
            s.Line.Color    = _defaultColor;
            s.Line.Width    = 2;
            return(s);
        }
Exemple #16
0
        protected void RenderInternal(Graphics g, Map map, BoundingBox envelope, RenderType rendertype)
        {
            if (!Style.Enabled)
            {
                return;
            }

            VectorStyle           vStyle = Style.Clone();
            Collection <Geometry> geoms;

            lock (_dataSource)
            {
                bool alreadyOpen = DataSource.IsOpen;

                if (!alreadyOpen)
                {
                    DataSource.Open();
                }

                geoms = DataSource.GetGeometriesInView(envelope);
                Console.Out.WriteLine(string.Format("Layer {0}, NumGeometries {1}", LayerName, geoms.Count));

                if (!alreadyOpen)
                {
                    DataSource.Close();
                }
            }
            if (CoordinateTransformation != null)
            {
                for (int i = 0; i < geoms.Count; i++)
#if !DotSpatialProjections
                { geoms[i] = GeometryTransform.TransformGeometry(geoms[i], CoordinateTransformation.MathTransform); }
            }
#else
                { geoms[i] = GeometryTransform.TransformGeometry(geoms[i], CoordinateTransformation.Source, CoordinateTransformation.Target); }
#endif
            if (vStyle.LineSymbolizer != null)
            {
                vStyle.LineSymbolizer.Begin(g, map, geoms.Count);
            }
            VectorRenderer.width = vStyle.Outline.Width;
            for (int i = 0; i < geoms.Count; i++)
            {
                if (geoms[i] != null)
                {
                    RenderGeometry(g, map, geoms[i], vStyle, rendertype);
                }
            }

            if (vStyle.LineSymbolizer != null)
            {
                vStyle.LineSymbolizer.Symbolize(g, map);
                vStyle.LineSymbolizer.End(g, map);
            }
        }
        private static IStyle GetVectorStyle(ICssStyleDeclaration csd)
        {
            // VectorStyle object rebuild. Deserializes:
            //   border-color     Line.Color
            //   border-width     Line.Width
            //   outline-color    Outline.Color
            //   outline-width    Outline.Width
            //   outline-style    EnableOutline
            //   background-color Fill
            VectorStyle vStyle = new VectorStyle();

            if (csd.GetPropertyValue("border-color") != string.Empty)
            {
                vStyle.Line.Color = GetColorFromCss(csd, "border-color");
            }
            if (csd.GetPropertyValue("border-width") != string.Empty)
            {
                vStyle.Line.Width = float.Parse(csd.GetPropertyValue("border-width"));
            }
            if (csd.GetPropertyValue("outline-color") != string.Empty)
            {
                vStyle.Outline.Color = GetColorFromCss(csd, "outline-color");
            }
            if (csd.GetPropertyValue("outline-width") != string.Empty)
            {
                vStyle.Outline.Width = float.Parse(csd.GetPropertyValue("outline-width"));
            }
            if (csd.GetPropertyValue("outline-style") != string.Empty)
            {
                vStyle.EnableOutline = (csd.GetPropertyValue("outline-style") == "enabled" ? true : false);
            }
            if (csd.GetPropertyValue("background-color") != string.Empty)
            {
                vStyle.Fill = new SolidBrush(GetColorFromCss(csd, "background-color"));
            }

            vStyle.Line.EndCap = (LineCap)Enum.Parse(typeof(LineCap), csd.GetPropertyValue(endcapName));

            if (csd.GetPropertyValue("geometry-type") != string.Empty)
            {
                vStyle.GeometryType = GetGeometryTypeFromCssString(csd);
            }

            if (csd.GetPropertyValue("symbol-shape") != string.Empty)
            {
                vStyle.Shape = (VectorStyle.ShapeType?)Enum.Parse(typeof(VectorStyle.ShapeType), csd.GetPropertyValue("symbol-shape"));
            }
            if (csd.GetPropertyValue("symbol") != string.Empty)
            {
                // From a Codepage 1251-encoded string, convert to bytes and next to a Bitmap representing the symbol
                byte[] bytes = Convert.FromBase64String(csd.GetPropertyValue("symbol"));
                vStyle.Symbol = (Bitmap)TypeDescriptor.GetConverter(typeof(Bitmap)).ConvertFrom(bytes);
            }
            return(vStyle);
        }
Exemple #18
0
        private static VectorStyle ObtenerEstilo(TipoPaleta paleta, SimbBase simb)
        {
            VectorStyle vs = new VectorStyle();

            switch (paleta)
            {
            case (TipoPaleta.predeterminada):
                vs.EnableOutline = simb.contorno;
                vs.Outline       = new Pen(simb.color_ColorContorno, simb.width);

                switch (simb.color_TipoRelleno)
                {
                case (TipoRelleno.solido):
                    vs.Fill = new SolidBrush(simb.color_ColorRelleno);
                    break;

                case (TipoRelleno.trama):
                    vs.Fill = new HatchBrush(simb.color_Trama, simb.color_ColorTrama, simb.color_ColorTramaFondo);
                    break;
                }
                break;

            case (TipoPaleta.tramado):
                vs.EnableOutline = simb.contorno;
                vs.Outline       = new Pen(simb.print_ColorContorno, simb.width);
                switch (simb.print_TipoRelleno)
                {
                case (TipoRelleno.solido):
                    vs.Fill = new SolidBrush(simb.print_ColorRelleno);
                    break;

                case (TipoRelleno.trama):
                    vs.Fill = new HatchBrush(simb.print_Trama, simb.print_ColorTrama, simb.print_ColorTramaFondo);
                    break;
                }
                break;

            default:
                vs.EnableOutline = simb.contorno;
                vs.Outline       = new Pen(simb.color_ColorContorno, simb.width);

                switch (simb.color_TipoRelleno)
                {
                case (TipoRelleno.solido):
                    vs.Fill = new SolidBrush(simb.color_ColorRelleno);
                    break;

                case (TipoRelleno.trama):
                    vs.Fill = new HatchBrush(simb.color_Trama, simb.color_ColorTrama, simb.color_ColorTramaFondo);
                    break;
                }
                break;
            }
            return(vs);
        }
Exemple #19
0
        private void DrawThemeLayer(XGraphics gfx, Map map, double scaleFactor, VectorLayer lyr)
        {
            TransformsProvider tp      = new TransformsProvider(gfx);
            BoundingBox        geombox = map.GetExtents();

            FeatureDataSet fds = new FeatureDataSet();

            try
            {
                lyr.DataSource.ExecuteIntersectionQuery(geombox, fds);
                FeatureDataTable fdt = fds.Tables[0];
                for (int i = 0; i < fdt.Count; i++)
                {
                    FeatureDataRow fdr  = fdt[i];
                    VectorStyle    s    = (VectorStyle)lyr.Theme.GetStyle(fdr);
                    Geometry       geom = fdr.Geometry;
                    XPen           xp   = new XPen(XColor.FromArgb(s.Outline.Color), s.Outline.Width);
                    xp.DashStyle = (XDashStyle)s.Outline.DashStyle;
                    XSolidBrush xb = null;
                    if (geom is MultiLineString)
                    {
                        XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiLineString)geom, geombox);
                        this._geomCache.Add(new PDFGeom(g, xp, null));
                        gfx.DrawPath(xp, g);
                    }
                    if (geom is MultiPolygon)
                    {
                        XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiPolygon)geom, geombox);
                        if (s.Fill != null)
                        {
                            if ((s.Fill) is SolidBrush)
                            {
                                xb = new XSolidBrush(XColor.FromArgb((s.Fill as SolidBrush).Color));
                            }
                            else
                            {
                                xb = new XSolidBrush(XColor.FromKnownColor(KnownColor.Transparent));
                            }
                            this._geomCache.Add(new PDFGeom(g, xp, xb));
                            gfx.DrawPath(xp, xb, g);
                        }
                        else
                        {
                            this._geomCache.Add(new PDFGeom(g, xp, null));
                            gfx.DrawPath(xp, g);
                        }
                    }
                }
            }
            catch
            {
                //Do nothing, no render
            }
        }
Exemple #20
0
        private static IStyle CreateEditLayerBasicStyle()
        {
            var editStyle = new VectorStyle
            {
                Fill    = new Brush(EditModeColor),
                Line    = new Pen(EditModeColor, 3),
                Outline = new Pen(EditModeColor, 3)
            };

            return(editStyle);
        }
Exemple #21
0
        public void TestMap2()
        {
            var m = new Map(_mapSize);

            m.BackgroundLayer.Add(new TileLayer(new OsmTileSource(new OsmRequest(KnownOsmTileServers.MapQuest)), "MapQuest"));

            var codeBase = Path.GetDirectoryName(GetType().Assembly.CodeBase);
            var cn       = string.Format("Data Source={0};",
                                         Path.Combine(new Uri(codeBase).LocalPath, "TestData", "osm_aurich.sqlite"));

            var ct = Wgs84ToWebMercator;
            //Env[7,45731445821406 : 7,53454260528903, 53,4342695512313 : 53,478793942147]
            var box     = new Envelope(7.45731445821406, 7.53454260528903, 53.4342695512313, 53.478793942147);
            var box3857 = GeometryTransform.TransformBox(box, ct.MathTransform);

            m.ZoomToBox(box3857);

            foreach (var msp in ManagedSpatiaLite.GetSpatialTables(cn))
            {
                var l = new VectorLayer(msp.Table, msp);
                switch (msp.Table.Substring(0, 2).ToLower())
                {
                case "pt":
                    l.Style = VectorStyle.CreateRandomPuntalStyle();
                    break;

                case "ln":
                    l.Style = VectorStyle.CreateRandomLinealStyle();
                    break;

                case "pg":
                    l.Style = VectorStyle.CreateRandomPolygonalStyle();
                    break;

                default:
                    l.Style = VectorStyle.CreateRandomStyle();
                    break;
                }

                l.CoordinateTransformation = ct;
                m.Layers.Add(l);
            }

            var f = GetFormatter();

            BruTile.Utility.AddBruTileSurrogates(GetFormatter());

            Map mD = null;

            Assert.DoesNotThrow(() => mD = SandD(m, f));

            TestMaps("Test2", m, mD);
        }
 public WalkedPathLayer(IEnumerable <GeoPosition> path, string name) : base(path, name)
 {
     Style = new VectorStyle
     {
         Enabled = true,
         Line    = new Pen(Color.FromArgb(255, 120, 120, 120))
         {
             PenStyle = PenStyle.Solid,
             Width    = 12d
         }
     };
 }
Exemple #23
0
        public static void SetOpacity(this VectorStyle vectorStyle, double opacity)
        {
            var inColor = vectorStyle.Fill.Color;

            vectorStyle.Fill.Color = new Color()
            {
                A = (int)(255 * opacity),
                R = inColor.R,
                G = inColor.G,
                B = inColor.B
            };
        }
        public TearDropLayer(string title) : base(title)
        {
            TearDropLocations = new FeatureDataTable();
            TearDropLocations.Columns.Add("MapLocation", typeof(MapLocation));
            TearDropLocations.Columns.Add("DisplayFact", typeof(DisplayFact));
            TearDropLocations.Columns.Add("ViewPort", typeof(Envelope));
            TearDropLocations.Columns.Add("Colour", typeof(string));

            GeometryFeatureProvider TearDropLocationGFP = new GeometryFeatureProvider(TearDropLocations);

            this.DataSource = TearDropLocationGFP;

            Dictionary <string, IStyle> styles = new Dictionary <string, IStyle>();
            VectorStyle birth = new VectorStyle
            {
                PointColor   = new SolidBrush(Color.Red),
                PointSize    = 8,
                Symbol       = Image.FromFile(Path.Combine(Application.StartupPath, @"Resources\Icons\", RED)),
                SymbolOffset = new PointF(0.0f, -17.0f)
            };

            styles.Add(RED, birth);

            VectorStyle death = new VectorStyle
            {
                PointColor   = new SolidBrush(Color.Black),
                PointSize    = 8,
                Symbol       = Image.FromFile(Path.Combine(Application.StartupPath, @"Resources\Icons\", BLACK)),
                SymbolOffset = new PointF(0.0f, -17.0f)
            };

            styles.Add(BLACK, death);

            VectorStyle selected = new VectorStyle
            {
                PointColor   = new SolidBrush(Color.LightGreen),
                PointSize    = 8,
                Symbol       = Image.FromFile(Path.Combine(Application.StartupPath, @"Resources\Icons\", LIGHT_GREEN)),
                SymbolOffset = new PointF(0.0f, -17.0f)
            };

            styles.Add(LIGHT_GREEN, selected);

            VectorStyle point = new VectorStyle
            {
                PointColor = new SolidBrush(Color.DarkGray),
                PointSize  = 6
            };

            styles.Add(GREY, point);

            this.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme <string>("Colour", styles, point);
        }
        private static VectorStyle GetStyle()
        {
            var style = new VectorStyle
            {
                Fill          = Brushes.AntiqueWhite,
                Line          = Pens.Red,
                EnableOutline = true,
                Outline       = Pens.Black,
                Symbol        = new Bitmap(10, 10)
            };

            return(style);
        }
Exemple #26
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.Tag              = style.Line.Width; // see #linewidthhack
            path.IsHitTestVisible = false;
            return(path);
        }
Exemple #27
0
        public void TestUniqueValueThemeString()
        {
            var ds = VectorStyle.CreateRandomLinealStyle();

            var tS = new UniqueValuesTheme <string>("Attribute", CreateStylesDictionary(new[] { "Alpha", "Beta", "Gamma" }), ds);
            UniqueValuesTheme <string> tD = null;

            Assert.DoesNotThrow(() => tD = SandD(tS, GetFormatter()));

            Assert.IsNotNull(tD, "Desrialization returned null");

            TestUniqueValuesThemesEqual(tS, tD);
        }
        private static VectorStyle DefaultVectorStyle()
        {
            var vectorStyle = new VectorStyle();

            vectorStyle.Enabled = true;

            vectorStyle.Line          = new Pen(Brushes.DarkGray, 2f);
            vectorStyle.Outline       = new Pen(Brushes.DarkGray, 2f);
            vectorStyle.Fill          = new SolidBrush(Color.LightGray);
            vectorStyle.EnableOutline = true;

            return(vectorStyle);
        }
Exemple #29
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);
        }
Exemple #30
0
        private static IStyle CreateEditLayerBasicStyle()
        {
            // Note: VectorStyle does not function in the current release Mapsui version.
            // You need the package deployed from the build server.
            var editStyle = new VectorStyle
            {
                Fill    = new Brush(EditModeColor),
                Line    = new Pen(EditModeColor, 3),
                Outline = new Pen(EditModeColor, 3)
            };

            return(editStyle);
        }
        public bool Equals(VectorStyle vectorStyle)
        {
            if (!base.Equals(vectorStyle))
            {
                return false;
            }

            if ((Line == null) ^ (vectorStyle.Line == null))
            {
                return false;
            }

            if (Line != null && !Line.Equals(vectorStyle.Line))
            {
                return false;
            }

            if ((Outline == null) ^ (vectorStyle.Outline == null))
            {
                return false;
            }

            if (Outline != null && !Outline.Equals(vectorStyle.Outline))
            {
                return false;
            }

            if ((Fill == null) ^ (vectorStyle.Fill == null))
            {
                return false;
            }

            if (Fill != null && !Fill.Equals(vectorStyle.Fill))
            {
                return false;
            }

            return true;
        }
Exemple #32
0
        private void CalculateVectorStyle(VectorStyle style, VectorStyle min, VectorStyle max, double value)
        {
            double dFrac = Fraction(value);
            double fFrac = Convert.ToSingle(dFrac);
            style.Enabled = (dFrac > 0.5 ? min.Enabled : max.Enabled);
            if (FillColorBlend != null)
                style.Fill = new Brush { Color = FillColorBlend.GetColor(fFrac) };
            else if (min.Fill != null && max.Fill != null)
                style.Fill = InterpolateBrush(min.Fill, max.Fill, value);

            if (min.Line != null && max.Line != null)
                style.Line = InterpolatePen(min.Line, max.Line, value);
            if (LineColorBlend != null)
                style.Line.Color = LineColorBlend.GetColor(fFrac);

            if (min.Outline != null && max.Outline != null)
                style.Outline = InterpolatePen(min.Outline, max.Outline, value);
        }