private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e)
        {
            TimeExtent extent = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MaximumValue);

            MyTimeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromDays(500));

            MyTimeSlider.Value = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MinimumValue.AddYears(10));
        }
Пример #2
0
 private void MyTimeSlider_Loaded(object sender, RoutedEventArgs e)
 {
     MyTimeSlider.MinimumValue = DateTime.Now.Subtract(TimeSpan.FromDays(7)).ToUniversalTime();
     MyTimeSlider.MaximumValue = DateTime.Now.ToUniversalTime();
     MyTimeSlider.Value        = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MinimumValue.AddHours(2));
     MyTimeSlider.Intervals    = TimeSlider.CreateTimeStopsByTimeInterval(
         new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MaximumValue), new TimeSpan(0, 2, 0, 0));
 }
Пример #3
0
        public static long CountTimeStopsByTimeInterval(DashboardHelper dashboardHelper, string timeVar)
        {
            List <string> columnNames = new List <string>();

            if (dashboardHelper.IsUsingEpiProject)
            {
                columnNames.Add("UniqueKey");
            }

            if (!string.IsNullOrEmpty(timeVar))
            {
                if (!columnNames.Exists(s => s.Equals(timeVar)))
                {
                    columnNames.Add(timeVar);
                }
            }

            DataTable data = dashboardHelper.GenerateTable(columnNames);

            var minTime = DateTime.MaxValue;
            var maxTime = DateTime.MinValue;
            var minX    = double.MaxValue;
            var maxX    = double.MinValue;
            var minY    = double.MaxValue;
            var maxY    = double.MinValue;

            if (data != null)
            {
                foreach (DataRow row in data.Rows)
                {
                    if (row[timeVar] != DBNull.Value)
                    {
                        DateTime time = (DateTime)row[timeVar];
                        minTime = minTime < time ? minTime : time;
                        maxTime = maxTime > time ? maxTime : time;
                    }
                }
            }

            IEnumerable <DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(
                new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0));

            return(intervals.ToList().Count);
        }
Пример #4
0
        public void OnDateRangeDefined(DateTime start, DateTime end, List <KeyValuePair <DateTime, int> > areaChartDataPoints)
        {
            this.areaChartDataPoints = areaChartDataPoints;

            myMap.TimeExtent = new TimeExtent(start.AddHours(-1), end.AddHours(1));

            slider.MinimumValue = myMap.TimeExtent.Start;
            slider.MaximumValue = myMap.TimeExtent.End;
            slider.Value        = new TimeExtent(slider.MinimumValue, slider.MinimumValue.AddHours(2));
            slider.Intervals    = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(slider.MinimumValue, slider.MaximumValue), new TimeSpan(1, 0, 0, 0));

            DateTimeAxis axis = new DateTimeAxis();

            axis.Orientation           = AxisOrientation.X;
            axis.Visibility            = Visibility.Hidden;
            axis.IntervalType          = DateTimeIntervalType.Days;
            axis.FontSize              = 0.1;
            areaSeries.IndependentAxis = axis;

            areaSeries.DependentValuePath   = "Value";
            areaSeries.IndependentValuePath = "Key";
            areaSeries.ItemsSource          = areaChartDataPoints;
            areaSeries.LegendItems.Clear();
        }
        private void FeatureLayer_Initialized(object sender, EventArgs e)
        {
            TimeExtent extent = new TimeExtent(timeSlider.MinimumValue, timeSlider.MaximumValue);

            timeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, new TimeSpan(0, 6, 0, 0, 0));
        }
Пример #6
0
        private void RenderMap()
        {
            txtLoading.Visibility        = Visibility.Collapsed;
            waitCursor.Visibility        = Visibility.Collapsed;
            LayerTypeSelector.Visibility = Visibility.Visible;

            ESRI.ArcGIS.Client.Bing.TileLayer layer = new TileLayer();
            layer.Token      = "Aua5s8kFcEZMx5lsd8Vkerz3frboU1CwzvOyzX_vgSnzsnbqV7xlQ4WTRUlN19_Q";
            layer.LayerStyle = TileLayer.LayerType.AerialWithLabels;

            GraphicsLayer pointLayer = new GraphicsLayer();

            pointLayer.ID = "pointLayer";

            GraphicsLayer zoneLayer = new GraphicsLayer();

            zoneLayer.ID = "zoneLayer";

            GraphicsLayer textLayer = new GraphicsLayer();

            textLayer.ID = "textLayer";

            GraphicsLayer clusterLayer = new GraphicsLayer();

            clusterLayer.ID = "clusterLayer";

            GraphicsLayer shapeFileLayer = new GraphicsLayer();

            shapeFileLayer.ID = "shapefileGraphicsLayer";

            ContextMenu menu         = new ContextMenu();
            MenuItem    mnuTimeLapse = new MenuItem();

            mnuTimeLapse.Header = "Create Time Lapse...";
            mnuTimeLapse.Click += new RoutedEventHandler(mnuTimeLapse_Click);
            menu.Items.Add(mnuTimeLapse);
            menu.Items.Add(new Separator());
            MenuItem mnuMarker = new MenuItem();

            mnuMarker.Header = "Add marker";
            mnuMarker.Click += new RoutedEventHandler(mnuMarker_Click);
            menu.Items.Add(mnuMarker);
            MenuItem mnuRadius = new MenuItem();

            mnuRadius.Header = "Add zone";
            mnuRadius.Click += new RoutedEventHandler(mnuRadius_Click);
            menu.Items.Add(mnuRadius);
            MenuItem mnuText = new MenuItem();

            mnuText.Header = "Add label";
            mnuText.Click += new RoutedEventHandler(mnuText_Click);
            menu.Items.Add(mnuText);
            MenuItem mnuClear = new MenuItem();

            mnuClear.Header = "Clear graphics";
            mnuClear.Click += new RoutedEventHandler(mnuClear_Click);
            menu.Items.Add(mnuClear);
            menu.Items.Add(new Separator());
            MenuItem mnuSave = new MenuItem();

            mnuSave.Header = "Save map as image...";
            mnuSave.Click += new RoutedEventHandler(mnuSave_Click);
            menu.Items.Add(mnuSave);

            myMap             = new Map();
            myMap.Background  = Brushes.White;
            myMap.Height      = MapContainer.ActualHeight;
            myMap.Width       = MapContainer.ActualWidth;
            myMap.ContextMenu = menu;
            myMap.Layers.Add(layer);
            myMap.Layers.Add(shapeFileLayer);
            myMap.Layers.Add(pointLayer);
            myMap.Layers.Add(textLayer);
            myMap.Layers.Add(zoneLayer);
            myMap.Layers.Add(clusterLayer);
            myMap.MouseMove            += new MouseEventHandler(myMap_MouseMove);
            myMap.MouseRightButtonDown += new MouseButtonEventHandler(myMap_MouseRightButtonDown);
            MapContainer.Children.Add(myMap);

            ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior extentBehavior = new ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior();
            extentBehavior.ConstrainedExtent = new Envelope(new MapPoint(-20000000, -12000000), new MapPoint(20000000, 12000000));
            System.Windows.Interactivity.Interaction.GetBehaviors(myMap).Add(extentBehavior);

            Navigation nav = new Navigation();

            nav.Margin = new Thickness(5);
            nav.HorizontalAlignment = HorizontalAlignment.Left;
            nav.VerticalAlignment   = VerticalAlignment.Top;
            nav.Map = myMap;
            MapContainer.Children.Add(nav);

            slider               = new TimeSlider();
            slider.Name          = "slider";
            slider.PlaySpeed     = new TimeSpan(0, 0, 1);
            slider.Height        = 20;
            slider.TimeMode      = TimeMode.CumulativeFromStart;
            slider.MinimumValue  = DateTime.Now.Subtract(TimeSpan.FromDays(7)).ToUniversalTime();
            slider.MaximumValue  = DateTime.Now.ToUniversalTime();
            slider.Value         = new TimeExtent(slider.MinimumValue, slider.MinimumValue.AddHours(2));
            slider.Intervals     = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(slider.MinimumValue, slider.MaximumValue), new TimeSpan(0, 2, 0, 0));
            slider.Padding       = new Thickness(0, 100, 0, 0);
            slider.ValueChanged += new EventHandler <TimeSlider.ValueChangedEventArgs>(slider_ValueChanged);
            areaSeries.Loaded   += new RoutedEventHandler(areaSeries_Loaded);
            stkTimeLapse.Children.Add(slider);

            //grdMapDef.Background = Brushes.Black;
            //myMap.Background = Brushes.Black;
            SetBackgroundColor(defaultBackgroundColor);

            AddSelectionCriteria();
            AddFormatOptions();
            AddLayerList();

            if (MapLoaded != null)
            {
                MapLoaded(this, new EventArgs());
            }
        }
Пример #7
0
        public void RenderPointMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush pointColor, string timeVar, SimpleMarkerSymbol.SimpleMarkerStyle style, string description)
        {
            this.dashboardHelper = dashboardHelper;
            this.latVar          = latVar;
            this.longVar         = longVar;
            this.timeVar         = timeVar;
            this.style           = style;
            this.description     = description;
            this.pointColor      = (SolidColorBrush)pointColor;

            GraphicsLayer pointLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer;

            if (pointLayer != null)
            {
                pointLayer.Graphics.Clear();
            }
            else
            {
                pointLayer    = new GraphicsLayer();
                pointLayer.ID = layerId.ToString();
                myMap.Layers.Add(pointLayer);
            }

            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);
                pointLayer.Graphics.Add(graphic);
            }

            if (LegendStackPanel == null)
            {
                LegendStackPanel = new StackPanel();
            }

            LegendStackPanel.Children.Clear();

            if (string.IsNullOrEmpty(description))
            {
                description = SharedStrings.CASES;
            }

            if (!string.IsNullOrEmpty(description))
            {
                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);

                TextBlock symbolTextBlock = new TextBlock();
                switch (style)
                {
                case SimpleMarkerSymbol.SimpleMarkerStyle.Circle:
                    symbolTextBlock.Text     = "●";
                    symbolTextBlock.FontSize = 16;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Cross:
                    symbolTextBlock.Text       = "+";
                    symbolTextBlock.FontSize   = 18;
                    symbolTextBlock.FontWeight = FontWeights.Bold;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Diamond:
                    symbolTextBlock.Text     = "♦";
                    symbolTextBlock.FontSize = 17;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Square:
                    symbolTextBlock.Text     = "■";
                    symbolTextBlock.FontSize = 16;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Triangle:
                    symbolTextBlock.Text     = "▲";
                    symbolTextBlock.FontSize = 16;
                    break;

                default:
                    symbolTextBlock.Text     = "▲";
                    symbolTextBlock.FontSize = 16;
                    break;
                }
                symbolTextBlock.FontSize = 28;

                symbolTextBlock.VerticalAlignment = VerticalAlignment.Top;
                symbolTextBlock.Margin            = new Thickness(0, 4, 7, 4);
                symbolTextBlock.Foreground        = this.pointColor;

                StackPanel classStackPanel = new StackPanel();
                classStackPanel.Margin      = new Thickness(10, 0, 10, 10);
                classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                classStackPanel.Children.Add(symbolTextBlock);
                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 = pointLayer.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);
                        }
                    }
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }