private void bindUI() { if (graphicsLayer == null) { this.IsEnabled = false; return; } GeometryType goemType = LayerExtensions.GetGeometryType(graphicsLayer); //Point layers only if (goemType != GeometryType.Point) { this.IsEnabled = false; return; } this.IsEnabled = true; FlareClusterer clusterer = graphicsLayer.Clusterer as FlareClusterer; if (clusterer == null) { bindClustererToUI(new FlareClusterer());//bind to defaults from new clusterer } else { bindClustererToUI(clusterer); } }
/// <summary> /// Check graphics count /// </summary> /// <param name="clusterGraphic">Cluster graphic to expand</param> /// <returns>True if exceeded</returns> private bool _MaxGraphicsToExpandExceeded(ClusterGraphicObject clusterGraphic) { IList <object> clusterData = GetClusteredData(clusterGraphic); ObjectLayer objectLayer = MapHelpers.GetLayerWithData(clusterData[0], _mapctrl.ObjectLayers); FlareClusterer clusterer = (FlareClusterer)objectLayer.MapLayer.Clusterer; int objectsInCluster = (int)clusterGraphic.Attributes[ALClusterer.COUNT_PROPERTY_NAME]; bool exceeded = objectsInCluster > clusterer.MaximumFlareCount; return(exceeded); }
private void ForegroundColorPicker_ColorChanged(object sender, EventArgs e) { FlareClusterer clusterer = DataContext as FlareClusterer; if (clusterer == null) { return; } ColorPicker picker = (ColorPicker)sender; (clusterer.FlareForeground as SolidColorBrush).Color = picker.Color; }
/// <summary> /// Returns layer's clusterer's Radius. If not available, returns default /// </summary> /// <param name="layer"></param> /// <returns></returns> public static int GetClusterRadius(this GraphicsLayer layer) { if (layer != null && layer.Clusterer is FlareClusterer) { FlareClusterer clusterer = layer.Clusterer as FlareClusterer; return(clusterer.Radius); } else { return((new FlareClusterer()).Radius); } }
/// <summary> /// Returns layer's clusterer's MaximumFlareCount. If not available, returns default /// </summary> /// <param name="layer"></param> /// <returns></returns> public static int GetClusterMaxPoints(this GraphicsLayer layer) { if (layer != null && layer.Clusterer is FlareClusterer) { FlareClusterer clusterer = layer.Clusterer as FlareClusterer; return(clusterer.MaximumFlareCount); } else { return((new FlareClusterer()).MaximumFlareCount); } }
public static void ChangeClusterMaxPoints(this GraphicsLayer layer, int newValue) { if (layer == null) { return; } FlareClusterer clusterer = layer.Clusterer as FlareClusterer; if (clusterer != null) { clusterer.MaximumFlareCount = newValue; } }
public static void ChangeClusterFlareBackground(this GraphicsLayer layer, Brush brush) { if (layer == null) { return; } FlareClusterer clusterer = layer.Clusterer as FlareClusterer; if (clusterer != null) { clusterer.FlareBackground = brush; } }
public static Color GetClusterFlareForeground(this GraphicsLayer layer) { if (layer == null) { return(Colors.Transparent); } FlareClusterer clusterer = layer.Clusterer as FlareClusterer; if (clusterer != null && clusterer.FlareForeground is SolidColorBrush) { return((clusterer.FlareForeground as SolidColorBrush).Color); } return(Colors.Transparent); }
public static void ChangeClusterRadius(this GraphicsLayer layer, int newValue) { if (layer == null) { return; } FlareClusterer clusterer = layer.Clusterer as FlareClusterer; if (clusterer != null) { clusterer.Radius = newValue; layer.Refresh(); } }
private void loadBackgroundColorPicker() { FlareClusterer clusterer = DataContext as FlareClusterer; if (clusterer == null) { return; } if (BackgroundColorPicker != null) { BackgroundColorPicker.Color = (clusterer.FlareBackground as SolidColorBrush).Color; BackgroundColorPicker.Hsv = BackgroundColorPicker.Color.ToHsv(); } }
protected void WriteFlareClusterer(FlareClusterer flareClusterer) { writer.WriteStartElement("GraphicsLayer.Clusterer", Namespaces[Constants.esriPrefix]); writer.WriteStartElement("FlareClusterer", Namespaces[Constants.esriPrefix]); //Attributes... if (flareClusterer.Radius != 20) { WriteAttribute("Radius", flareClusterer.Radius); } if (flareClusterer.MaximumFlareCount != 10) { WriteAttribute("MaximumFlareCount", flareClusterer.MaximumFlareCount); } if (flareClusterer.FlareBackground is SolidColorBrush) { if ((flareClusterer.FlareBackground as SolidColorBrush).Color != Colors.Red) { WriteAttribute("FlareBackground", (flareClusterer.FlareBackground as SolidColorBrush).Color); } } if (flareClusterer.FlareForeground is SolidColorBrush) { if ((flareClusterer.FlareForeground as SolidColorBrush).Color != Colors.White) { WriteAttribute("FlareForeground", (flareClusterer.FlareForeground as SolidColorBrush).Color); } } //Elements... if (!(flareClusterer.FlareBackground is SolidColorBrush)) { writer.WriteStartElement("FlareClusterer.FlareBackground", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(flareClusterer.FlareBackground); writer.WriteEndElement(); } if (!(flareClusterer.FlareForeground is SolidColorBrush)) { writer.WriteStartElement("FlareClusterer.FlareForeground", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(flareClusterer.FlareForeground); writer.WriteEndElement(); } if (flareClusterer.Gradient != null) { writer.WriteStartElement("FlareClusterer.Gradient", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(flareClusterer.Gradient); writer.WriteEndElement(); } writer.WriteEndElement(); //FlareClusterer writer.WriteEndElement(); //GraphicsLayer.Clusterer }
private void AdvancedClusterProperties_Click(object sender, RoutedEventArgs e) { GraphicsLayer layerInfo = DataContext as GraphicsLayer; if (layerInfo == null) { return; } FlareClusterer flareCluster = layerInfo.Clusterer as FlareClusterer; if (flareCluster == null) { return; } ChildWindow fw = new ChildWindow(); //fw.ResizeMode = ResizeMode.NoResize; TextBlock title = new TextBlock { Foreground = new SolidColorBrush(Colors.White), FontSize = 12, FontWeight = FontWeights.Bold, Text = "Advanced Cluster Properties" }; fw.Title = title; fw.Height = 235; fw.Width = 290; currentClusterInfo = flareCluster; // TODO nik (refactor) flareCluster. flareClusterer..ClusterInfo != null ? layerInfo.ClusterInfo.Clone() : new ClusterInfo(); ClusterPropertiesConfigWindow configWindow = new ClusterPropertiesConfigWindow(); configWindow.OkClicked += (o, args) => { fw.DialogResult = true; }; configWindow.CancelClicked += (o, args) => { fw.DialogResult = false; // automatically calls close }; fw.Closed += (o, args) => { if (fw.DialogResult != true) // && !fw.IsAppExit) { restoreClusterProperties(); } }; configWindow.DataContext = flareCluster; fw.Content = configWindow; fw.DialogResult = null; //fw.ShowDialog(); fw.Show(); }
private void bindClustererToUI(FlareClusterer clusterer) { if (MaxPointsUpDown != null) { MaxPointsUpDown.Value = Convert.ToDouble(clusterer.MaximumFlareCount); } if (BackgroundColorSelector != null) { BackgroundColorSelector.ColorBrush = clusterer.FlareBackground as SolidColorBrush; } if (RadiusUpDown != null) { RadiusUpDown.Value = Convert.ToDouble(clusterer.Radius); } if (ForegroundColorSelector != null) { ForegroundColorSelector.ColorBrush = clusterer.FlareForeground as SolidColorBrush; } }
void MaxPointsUpDown_ValueChanged(object sender, EventArgs e) { if (graphicsLayer == null) { return; } int newValue = Convert.ToInt32(MaxPointsUpDown.Value); if (newValue > 0) { graphicsLayer.ChangeClusterMaxPoints(newValue); } else { FlareClusterer clusterer = graphicsLayer.Clusterer as FlareClusterer; if (clusterer != null) { MaxPointsUpDown.Value = Convert.ToDouble(clusterer.MaximumFlareCount); } } }
void RadiusUpDown_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (graphicsLayer == null) { return; } int newValue = Convert.ToInt32(RadiusUpDown.Value); if (newValue > 0) { graphicsLayer.ChangeClusterRadius(newValue); } else { FlareClusterer clusterer = graphicsLayer.Clusterer as FlareClusterer; if (clusterer != null) { RadiusUpDown.Value = Convert.ToDouble(clusterer.Radius); } } }
private void AdvancedClusterProperties_Click(object sender, RoutedEventArgs e) { GraphicsLayer layerInfo = DataContext as GraphicsLayer; if (layerInfo == null) return; FlareClusterer flareCluster = layerInfo.Clusterer as FlareClusterer; if (flareCluster == null) return; ChildWindow fw = new ChildWindow(); //fw.ResizeMode = ResizeMode.NoResize; TextBlock title = new TextBlock { Foreground = new SolidColorBrush(Colors.White), FontSize = 12, FontWeight = FontWeights.Bold, Text = "Advanced Cluster Properties" }; fw.Title = title; fw.Height = 235; fw.Width = 290; currentClusterInfo = flareCluster; // TODO nik (refactor) flareCluster. flareClusterer..ClusterInfo != null ? layerInfo.ClusterInfo.Clone() : new ClusterInfo(); ClusterPropertiesConfigWindow configWindow = new ClusterPropertiesConfigWindow(); configWindow.OkClicked += (o, args) => { fw.DialogResult = true; }; configWindow.CancelClicked += (o, args) => { fw.DialogResult = false; // automatically calls close }; fw.Closed += (o, args) => { if (fw.DialogResult != true) // && !fw.IsAppExit) restoreClusterProperties(); }; configWindow.DataContext = flareCluster; fw.Content = configWindow; fw.DialogResult = null; //fw.ShowDialog(); fw.Show(); }
public void AddPointsAsManyGraphicsLayers(List <PointDTOCollection> pointDTOList) { try { Queue <SimpleMarkerSymbol> mQueue = this.CreateSimpleMarkerSymbolQueue(); Queue <SimpleMarkerSymbol> markerSymbolQueue = new Queue <SimpleMarkerSymbol>(mQueue.Reverse <SimpleMarkerSymbol>()); this.map.Layers.Clear(); ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer openStreetMapLayer = new ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer(); if (this.useRoads) { openStreetMapLayer.Initialized += myOpenStreetMapLayer_Initialized; map.Layers.Add(openStreetMapLayer); } foreach (PointDTOCollection pointDTOClass in pointDTOList) { SimpleMarkerSymbol simpleMarkerSymbol; // Pick a symbol for this class if (markerSymbolQueue.Count == 0) { mQueue = this.CreateSimpleMarkerSymbolQueue(); markerSymbolQueue = new Queue <SimpleMarkerSymbol>(mQueue.Reverse <SimpleMarkerSymbol>()); } simpleMarkerSymbol = markerSymbolQueue.Dequeue(); // Create a graphics layer GraphicsLayer graphicsLayer = new GraphicsLayer(); if (pointDTOClass.Collection.Count > 1) { if (pointDTOList.Count > 1 && pointDTOClass.Collection.Count > 1) { if (pointDTOClass.Collection[0].StrataValue.Contains("\'")) { // [Age] = '25' graphicsLayer.ID = pointDTOClass.Collection[0].StrataValue; int startPos = graphicsLayer.ID.IndexOf("=") + 3; int endPos = graphicsLayer.ID.LastIndexOf("\'"); graphicsLayer.ID = graphicsLayer.ID.Substring(startPos, endPos - startPos); } else // maybe the strata value is a # example // [Age] = 25 { graphicsLayer.ID = pointDTOClass.Collection[0].StrataValue; int startPos = graphicsLayer.ID.IndexOf("=") + 1; int endPos = graphicsLayer.ID.Length; graphicsLayer.ID = graphicsLayer.ID.Substring(startPos, endPos - startPos); } } else { graphicsLayer.ID = pointDTOClass.Collection[0].StrataValue; } } EwavLegendItemData eli = new EwavLegendItemData(); eli.Color = simpleMarkerSymbol.Color; eli.Description = graphicsLayer.ID; this.ewavLegendItemList.Add(eli); // Create a clusterer with a flare FlareClusterer fc = new FlareClusterer(); fc.FlareBackground = simpleMarkerSymbol.Color; fc.MaximumFlareCount = this.maximumFlareCount; // 20 fc.Radius = this.flareClusterRadius; // += fc.Radius / 10; // Add clusterer to graphics layer graphicsLayer.Clusterer = fc; // Add graphics to graphics layer with foreach (PointDTO pointDTO in pointDTOClass.Collection) { Graphic graphic = this.createGraphic(pointDTO, simpleMarkerSymbol); Border brdmaptip = new Border(); brdmaptip.Background = new SolidColorBrush(Colors.White); brdmaptip.BorderBrush = simpleMarkerSymbol.Color; brdmaptip.BorderThickness = new Thickness(1, 1, 1, 1); // Create a map tip TextBlock tb = new TextBlock(); // if multiple cols are required for map tips later, // use of pointDTO.MapTip will facilitate it. tb.Text = graphicsLayer.ID; // pointDTO.MapTip; tb.Margin = new Thickness(5, 5, 5, 5); brdmaptip.Child = tb; graphic.MapTip = brdmaptip; graphic.MapTip.VerticalAlignment = VerticalAlignment.Top; graphic.MapTip.HorizontalAlignment = HorizontalAlignment.Right; graphicsLayer.Graphics.Add(graphic); } // Add graphics layer to map this.map.Layers.Add(graphicsLayer); this.map.Extent = graphicsLayer.FullExtent; this.map.Zoom(.9); } } catch (Exception ex) { throw new Exception(string.Format("{0} == {1}", ex.Message, ex.StackTrace)); } }
public void RenderClusterMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush clusterColor, string timeVar, string description) { this.dashboardHelper = dashboardHelper; this.latVar = latVar; this.longVar = longVar; this.timeVar = timeVar; this.description = description; this.clusterColor = (SolidColorBrush)clusterColor; GraphicsLayer clusterLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (clusterLayer != null) { clusterLayer.Graphics.Clear(); } else { clusterLayer = new GraphicsLayer(); clusterLayer.ID = layerId.ToString(); myMap.Layers.Add(clusterLayer); } CustomCoordinateList coordinateList = GetCoordinates(dashboardHelper, latVar, longVar, timeVar); for (int i = 0; i < coordinateList.Coordinates.Count; i++) { ExtendedGraphic graphic = new ExtendedGraphic() { Geometry = new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y, geoReference), RecordId = coordinateList.Coordinates[i].RecordId, Symbol = MarkerSymbol }; if (coordinateList.Coordinates[i].TimeSpan.HasValue) { graphic.TimeExtent = new TimeExtent(coordinateList.Coordinates[i].TimeSpan.Value); } else { graphic.TimeExtent = new TimeExtent(DateTime.MinValue, DateTime.MaxValue); } graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp); clusterLayer.Graphics.Add(graphic); } Brush flareForeground; if (System.Drawing.Color.FromArgb(this.clusterColor.Color.A, this.clusterColor.Color.R, this.clusterColor.Color.G, this.clusterColor.Color.B).GetBrightness() > 0.5) { flareForeground = new SolidColorBrush(Colors.Black); } else { flareForeground = new SolidColorBrush(Colors.White); } FlareClusterer clusterer = new FlareClusterer() { FlareBackground = clusterColor, FlareForeground = flareForeground, MaximumFlareCount = 10, Radius = 15, Gradient = ClustererGradient }; clusterLayer.Clusterer = clusterer; if (LegendStackPanel == null) { LegendStackPanel = new StackPanel(); } LegendStackPanel.Children.Clear(); if (string.IsNullOrEmpty(description)) { description = SharedStrings.CASES; } System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox(); legendList.Padding = new Thickness(0, 10, 0, 0); legendList.Background = Brushes.White; legendList.BorderBrush = Brushes.Black; legendList.BorderThickness = new Thickness(0); legendList.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); TextBlock classTextBlock = new TextBlock(); classTextBlock.Text = description; classTextBlock.FontFamily = new FontFamily("Segoe"); classTextBlock.FontSize = 12; classTextBlock.MaxWidth = 256; classTextBlock.TextWrapping = TextWrapping.Wrap; classTextBlock.HorizontalAlignment = HorizontalAlignment.Center; classTextBlock.VerticalAlignment = VerticalAlignment.Center; classTextBlock.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); Ellipse circle = new Ellipse(); circle.Width = 14; circle.Height = 14; circle.VerticalAlignment = VerticalAlignment.Top; circle.Margin = new Thickness(0, 4, 7, 4); circle.Fill = this.clusterColor; StackPanel classStackPanel = new StackPanel(); classStackPanel.Margin = new Thickness(10, 0, 10, 10); classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; classStackPanel.Children.Add(circle); classStackPanel.Children.Add(classTextBlock); legendList.Items.Add(classStackPanel); LegendStackPanel.Children.Add(legendList); if (coordinateList.Coordinates.Count > 0) { myMap.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(minX - 0.01, minY - 0.01, geoReference)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(maxX + 0.01, maxY + 0.01, geoReference))); if (!string.IsNullOrEmpty(timeVar)) { if (minTime != null && maxTime != null) { intervalCounts = new List <KeyValuePair <DateTime, int> >(); DateTime previousInterval = DateTime.MinValue; IEnumerable <DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0)); foreach (DateTime interval in intervals) { int count = clusterLayer.Graphics.Count(x => x.TimeExtent.Start <= interval && x.TimeExtent.Start >= previousInterval); intervalCounts.Add(new KeyValuePair <DateTime, int>(interval.Date, count)); previousInterval = interval; } if (DateRangeDefined != null) { DateRangeDefined(minTime, maxTime, intervalCounts); } } } } }
protected void WriteFlareClusterer(FlareClusterer flareClusterer) { writer.WriteStartElement("GraphicsLayer.Clusterer", Namespaces[Constants.esriPrefix]); writer.WriteStartElement("FlareClusterer", Namespaces[Constants.esriPrefix]); //Attributes... if (flareClusterer.Radius != 20) WriteAttribute("Radius", flareClusterer.Radius); if (flareClusterer.MaximumFlareCount != 10) WriteAttribute("MaximumFlareCount", flareClusterer.MaximumFlareCount); if (flareClusterer.FlareBackground is SolidColorBrush) { if ((flareClusterer.FlareBackground as SolidColorBrush).Color != Colors.Red) { WriteAttribute("FlareBackground", (flareClusterer.FlareBackground as SolidColorBrush).Color); } } if (flareClusterer.FlareForeground is SolidColorBrush) { if ((flareClusterer.FlareForeground as SolidColorBrush).Color != Colors.White) { WriteAttribute("FlareForeground", (flareClusterer.FlareForeground as SolidColorBrush).Color); } } //Elements... if (!(flareClusterer.FlareBackground is SolidColorBrush)) { writer.WriteStartElement("FlareClusterer.FlareBackground", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(flareClusterer.FlareBackground); writer.WriteEndElement(); } if (!(flareClusterer.FlareForeground is SolidColorBrush)) { writer.WriteStartElement("FlareClusterer.FlareForeground", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(flareClusterer.FlareForeground); writer.WriteEndElement(); } if (flareClusterer.Gradient != null) { writer.WriteStartElement("FlareClusterer.Gradient", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(flareClusterer.Gradient); writer.WriteEndElement(); } writer.WriteEndElement(); //FlareClusterer writer.WriteEndElement(); //GraphicsLayer.Clusterer }
public MainPage() { InitializeComponent(); Client = new ServiceClient(); Client.GetKeyWordsCompleted += client_GetKeyWordsCompleted; Client.GetAllSitesCompleted += Client_GetAllSitesCompleted; Client.GetSitesCompleted += client_GetSitesCompleted; Client.GetDoubleTimeSeriesCompleted += client_GetDoubleTimeSeriesCompleted; Client.GetGridCompleted += Client_GetGridCompleted; Client.GetTimeRangeCompleted += Client_GetTimeRangeCompleted; Client.GetPointProfileCompleted += Client_GetPointProfileCompleted; Client.DownloadImageCompleted += Client_DownloadImageCompleted; Client.DownloadLegendCompleted += Client_DownloadLegendCompleted; Client.GetSensorImageRecordCompleted += Client_GetSensorImageRecordCompleted; _GraphicsLayers = new Dictionary <string, GraphicsLayer>(); _MarkerSymbols = new Dictionary <string, MarkerSymbol>(); _MarkerSymbols.Add("Buoy", BuoyMarkerSymbol); _MarkerSymbols.Add("Tide", TideMarkerSymbol); _MarkerSymbols.Add("Water Quality", WQMarkerSymbol); _MarkerSymbols.Add("Hydrology", HydrologyMarkerSymbol); _GraphicsLayers.Add("Buoy", Map.Layers["Buoys"] as GraphicsLayer); _GraphicsLayers.Add("Tide", Map.Layers["Tide Stations"] as GraphicsLayer); _GraphicsLayers.Add("Water Quality", Map.Layers["Water Quality Stations"] as GraphicsLayer); _GraphicsLayers.Add("Hydrology", Map.Layers["Hydrological Stations"] as GraphicsLayer); _GraphicsLayers.Add("Weather", Map.Layers["Weather Stations"] as GraphicsLayer); _GraphicsLayers.Add("General", Map.Layers["General Stations"] as GraphicsLayer); _GeneralStationLayer = Map.Layers["General Stations"] as GraphicsLayer; _GridLayer = Map.Layers["Model Grid"] as GraphicsLayer; foreach (GraphicsLayer layer in _GraphicsLayers.Values) { layer.MouseLeftButtonDown += GraphicsLayer_MouseLeftButtonDown; layer.Clusterer = null; } ClustererOfStation = new FlareClusterer() { FlareBackground = new SolidColorBrush(Colors.Yellow), FlareForeground = new SolidColorBrush(Colors.Black), MaximumFlareCount = 100, Radius = 40, }; _ImageSeries = new ImageSeries(); _QueryCriteria = new QueryCriteria(); _Timer = new Storyboard(); _Timer.Duration = TimeSpan.FromMilliseconds(10000); _Timer.Completed += _timer_Completed; StatusBar.Visibility = System.Windows.Visibility.Collapsed; _Box = new BBox(); _IsDownloadingTimeSeries = false; _GridRender = new GridRender(); GridRender.Instance = _GridRender; animationPlayer.ServiceClient = Client; coastalWatch.ServiceClient = Client; coastalWatch.Map = this.Map; }
private void bindClustererToUI(FlareClusterer clusterer) { if (MaxPointsUpDown != null) MaxPointsUpDown.Value = Convert.ToDouble(clusterer.MaximumFlareCount); if (BackgroundColorSelector != null) BackgroundColorSelector.ColorBrush = clusterer.FlareBackground as SolidColorBrush; if (RadiusUpDown != null) RadiusUpDown.Value = Convert.ToDouble(clusterer.Radius); if (ForegroundColorSelector != null) ForegroundColorSelector.ColorBrush = clusterer.FlareForeground as SolidColorBrush; }
public void RenderClusterMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush clusterColor, string timeVar, string description) { this.dashboardHelper = dashboardHelper; this.latVar = latVar; this.longVar = longVar; this.timeVar = timeVar; this.description = description; this.clusterColor = (SolidColorBrush)clusterColor; GraphicsLayer clusterLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (clusterLayer != null) { clusterLayer.Graphics.Clear(); } else { clusterLayer = new GraphicsLayer(); clusterLayer.ID = layerId.ToString(); myMap.Layers.Add(clusterLayer); } CustomCoordinateList coordinateList = GetCoordinates(dashboardHelper, latVar, longVar, timeVar); for (int i = 0; i < coordinateList.Coordinates.Count; i++) { ExtendedGraphic graphic = new ExtendedGraphic() { Geometry = new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y, geoReference), RecordId = coordinateList.Coordinates[i].RecordId, Symbol = MarkerSymbol }; if (coordinateList.Coordinates[i].TimeSpan.HasValue) graphic.TimeExtent = new TimeExtent(coordinateList.Coordinates[i].TimeSpan.Value); else graphic.TimeExtent = new TimeExtent(DateTime.MinValue, DateTime.MaxValue); graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp); clusterLayer.Graphics.Add(graphic); } Brush flareForeground; if (System.Drawing.Color.FromArgb(this.clusterColor.Color.A, this.clusterColor.Color.R, this.clusterColor.Color.G, this.clusterColor.Color.B).GetBrightness() > 0.5) { flareForeground = new SolidColorBrush(Colors.Black); } else { flareForeground = new SolidColorBrush(Colors.White); } FlareClusterer clusterer = new FlareClusterer() { FlareBackground = clusterColor, FlareForeground = flareForeground, MaximumFlareCount = 10, Radius = 15, Gradient = ClustererGradient }; clusterLayer.Clusterer = clusterer; if (LegendStackPanel == null) { LegendStackPanel = new StackPanel(); } LegendStackPanel.Children.Clear(); if (!string.IsNullOrEmpty(description)) { System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox(); legendList.Margin = new Thickness(5); legendList.Background = Brushes.White;// new LinearGradientBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), Color.FromArgb(0x7F, 0xFF, 0xFF, 0xFF), 45); legendList.BorderBrush = Brushes.Black; legendList.BorderThickness = new Thickness(3); //LegendTitle.Text = thematicItem.Description; TextBlock classTextBlock = new TextBlock(); classTextBlock.Text = " " + description; classTextBlock.FontSize = 15; Ellipse circle = new Ellipse(); circle.Width = 14; circle.Height = 14; circle.Fill = this.clusterColor; StackPanel classStackPanel = new StackPanel(); classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; classStackPanel.Children.Add(circle); classStackPanel.Children.Add(classTextBlock); legendList.Items.Add(classStackPanel); LegendStackPanel.Children.Add(legendList); } if (coordinateList.Coordinates.Count > 0) { myMap.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(minX - 0.01, minY - 0.01, geoReference)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(maxX + 0.01, maxY + 0.01, geoReference))); if (!string.IsNullOrEmpty(timeVar)) { if (minTime != null && maxTime != null) { intervalCounts = new List<KeyValuePair<DateTime, int>>(); DateTime previousInterval = DateTime.MinValue; IEnumerable<DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0)); foreach (DateTime interval in intervals) { int count = clusterLayer.Graphics.Count(x => x.TimeExtent.Start <= interval && x.TimeExtent.Start >= previousInterval); intervalCounts.Add(new KeyValuePair<DateTime, int>(interval.Date, count)); previousInterval = interval; } if (DateRangeDefined != null) { DateRangeDefined(minTime, maxTime, intervalCounts); } } } } }