Exemple #1
0
 public SimpleMarkerSymbolDef(Color color, double size,
                              SimpleMarkerStyle style)
 {
     Color = color;
     Size  = size;
     Style = style;
 }
 // Utility: Generate a random simple marker symbol
 private SimpleMarkerSymbol GetRandomSymbol(SimpleMarkerStyle style)
 {
     return(new SimpleMarkerSymbol()
     {
         Size = 12,
         Color = GetRandomColor(),
         Style = style
     });
 }
 // Utility: Generate a random simple marker symbol
 private SimpleMarkerSymbol GetRandomSymbol(SimpleMarkerStyle style)
 {
     return new SimpleMarkerSymbol()
     {
         Size = 12,
         Color = GetRandomColor(),
         Style = style
     };
 }
Exemple #4
0
        public static async Task <BA_ReturnCode> AddPointMarkersAsync(Uri aoiUri, string displayName, CIMColor markerColor,
                                                                      SimpleMarkerStyle markerStyle, double markerSize)
        {
            // parse the uri for the folder and file
            string strFileName   = null;
            string strFolderPath = null;

            if (aoiUri.IsFile)
            {
                strFileName   = System.IO.Path.GetFileName(aoiUri.LocalPath);
                strFolderPath = System.IO.Path.GetDirectoryName(aoiUri.LocalPath);
            }
            BA_ReturnCode success = BA_ReturnCode.UnknownError;
            await QueuedTask.Run(() =>
            {
                FeatureClass fClass = null;
                // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase.
                using (Geodatabase geodatabase =
                           new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(strFolderPath))))
                {
                    // Use the geodatabase.
                    try
                    {
                        fClass = geodatabase.OpenDataset <FeatureClass>(strFileName);
                    }
                    catch (GeodatabaseTableException e)
                    {
                        Debug.WriteLine("DisplayPointMarkersAsync: Unable to open feature class " + strFileName);
                        Debug.WriteLine("DisplayPointMarkersAsync: " + e.Message);
                        success = BA_ReturnCode.ReadError;
                        return;
                    }
                }
                // Create symbology for feature layer
                var flyrCreatnParam = new FeatureLayerCreationParams(fClass)
                {
                    Name               = displayName,
                    IsVisible          = true,
                    RendererDefinition = new SimpleRendererDefinition()
                    {
                        SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(markerColor, markerSize, markerStyle)
                                         .MakeSymbolReference()
                    }
                };

                FeatureLayer fLayer = LayerFactory.Instance.CreateLayer <FeatureLayer>(flyrCreatnParam, MapView.Active.Map);
            });

            success = BA_ReturnCode.Success;
            return(success);
        }
        private async void OnMapPointToolActivated(object obj)
        {
            var addList    = new List <tempProGraphic>();
            var removeList = new List <ProGraphic>();

            foreach (var item in ProGraphicsList)
            {
                if (item.Disposable != null || item.IsTemp == false)
                {
                    continue;
                }

                // re-add graphic to map overlay
                SimpleMarkerStyle ms    = SimpleMarkerStyle.Circle;
                CIMColor          color = ColorFactory.BlueRGB;

                if (item.Tag == "target")
                {
                    ms    = SimpleMarkerStyle.Square;
                    color = ColorFactory.RedRGB;
                }
                addList.Add(new tempProGraphic()
                {
                    GUID        = item.GUID,
                    Geometry    = item.Geometry,
                    Color       = color,
                    IsTemp      = true,
                    Size        = 5.0,
                    MarkerStyle = ms
                });
            }

            foreach (var temp in addList)
            {
                var pgOLD = ProGraphicsList.FirstOrDefault(g => g.GUID == temp.GUID);

                var guid = await AddGraphicToMap(temp.Geometry, temp.Color, temp.IsTemp, temp.Size, markerStyle : temp.MarkerStyle, tag : pgOLD.Tag);

                var pgNew = ProGraphicsList.FirstOrDefault(g => g.GUID == guid);
                pgNew.GUID = pgOLD.GUID;
                removeList.Add(pgOLD);
            }

            foreach (var pg in removeList)
            {
                ProGraphicsList.Remove(pg);
            }
        }
		// Change the graphics layer renderer to a new ClassBreaksRenderer
		private void ChangeRendererButton_Click(object sender, RoutedEventArgs e)
		{
			SimpleMarkerStyle style = (SimpleMarkerStyle)_random.Next(0, 6);

			_cities.Renderer = new ClassBreaksRenderer()
			{
				Field = "pop2000",
				Infos = new ClassBreakInfoCollection() 
				{ 
					new ClassBreakInfo() { Minimum = 0, Maximum = 50000, Symbol = GetRandomSymbol(style) },
					new ClassBreakInfo() { Minimum = 50000, Maximum = 100000, Symbol = GetRandomSymbol(style) },
					new ClassBreakInfo() { Minimum = 100000, Maximum = 250000, Symbol = GetRandomSymbol(style) },
					new ClassBreakInfo() { Minimum = 250000, Maximum = 500000, Symbol = GetRandomSymbol(style) },
					new ClassBreakInfo() { Minimum = 500000, Maximum = 1000000, Symbol = GetRandomSymbol(style) },
					new ClassBreakInfo() { Minimum = 1000000, Maximum = 5000000, Symbol = GetRandomSymbol(style) },
				}
			};
		}
        // Change the graphics layer renderer to a new ClassBreaksRenderer
        private void ChangeRendererButton_Click(object sender, RoutedEventArgs e)
        {
            SimpleMarkerStyle style = (SimpleMarkerStyle)_random.Next(0, 6);

            _earthquakes.Renderer = new ClassBreaksRenderer()
            {
                Field = "magnitude",
                Infos = new ClassBreakInfoCollection()
                {
                    new ClassBreakInfo()
                    {
                        Minimum = 2, Maximum = 3, Symbol = GetRandomSymbol(style)
                    },
                    new ClassBreakInfo()
                    {
                        Minimum = 3, Maximum = 4, Symbol = GetRandomSymbol(style)
                    },
                    new ClassBreakInfo()
                    {
                        Minimum = 4, Maximum = 5, Symbol = GetRandomSymbol(style)
                    },
                    new ClassBreakInfo()
                    {
                        Minimum = 5, Maximum = 6, Symbol = GetRandomSymbol(style)
                    },
                    new ClassBreakInfo()
                    {
                        Minimum = 6, Maximum = 7, Symbol = GetRandomSymbol(style)
                    },
                    new ClassBreakInfo()
                    {
                        Minimum = 7, Maximum = 8, Symbol = GetRandomSymbol(style)
                    },
                }
            };
        }
        internal async Task <string> AddGraphicToMap(Geometry geom, CIMColor color, bool IsTempGraphic = false, double size = 1.0, string text = "", SimpleMarkerStyle markerStyle = SimpleMarkerStyle.Circle, string tag = "")
        {
            if (geom == null || MapView.Active == null)
            {
                return(string.Empty);
            }

            CIMSymbolReference symbol = null;

            if (!string.IsNullOrWhiteSpace(text) && geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    // TODO add text graphic
                    //var tg = new CIMTextGraphic() { Placement = Anchor.CenterPoint, Text = text};
                });
            }
            else if (geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.ConstructPointSymbol(color, size, markerStyle);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polyline)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.ConstructLineSymbol(color, size);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polygon)
            {
                await QueuedTask.Run(() =>
                {
                    var outline = SymbolFactory.ConstructStroke(ColorFactory.Black, 1.0, SimpleLineStyle.Solid);
                    var s       = SymbolFactory.ConstructPolygonSymbol(color, SimpleFillStyle.Solid, outline);
                    symbol      = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }

            var result = await QueuedTask.Run(() =>
            {
                var disposable = MapView.Active.AddOverlay(geom, symbol);
                var guid       = Guid.NewGuid().ToString();
                ProGraphicsList.Add(new ProGraphic(disposable, guid, geom, IsTempGraphic, tag));
                return(guid);
            });

            return(result);
        }
Exemple #9
0
 public SimpleMarkerSymbolDef(Color color, double size,
     SimpleMarkerStyle style)
 {
     Color = color;
     Size = size;
     Style = style;
 }
 public ShapeItem(SimpleMarkerStyle markerStyle)
 {
     Name        = Enum.GetName(typeof(SimpleMarkerStyle), markerStyle).SpaceBetweenWords();
     MarkerStyle = markerStyle;
 }