Esempio n. 1
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
                // Find the map layer in the map widget that contains the data source.
                IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    if (_mapWidget != null && d.IsSelectable == true)
                    {
                        // Get the feature layer in the map for the data source.
                        client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d);

                        //Clear Selection on Feature Layers in map
                        featureL.ClearSelection();
                    }
                }
                location = e.MapPoint;
                if (_graphicsLayer == null)
                {
                    _graphicsLayer    = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphicsLayer.ID = "BombThreatGraphics";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayer);
                    }
                }

                _graphicsLayer.ClearGraphics();
                Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                graphic.Geometry = location;
                graphic.Attributes.Add("Evac", bombType.Text);
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                graphic.Symbol        = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.MapTip = new ContentControl()
                {
                    ContentTemplate = (DataTemplate)Resources["kymaptip"]
                };
                _graphicsLayer.MapTip.SetBinding(ContentControl.ContentProperty, new Binding());
                graphic.SetZIndex(1);
                _graphicsLayer.Graphics.Add(graphic);

                if (location != null)
                {
                    RunButton.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message);
            }
        }
        // ***********************************************************************************
        // * ...Set the map mouseclick event so that user can enter the incident
        // ***********************************************************************************
        private void btnSolve_Click(object sender, RoutedEventArgs e)
        {
            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            _bufferParams      = new BufferParameters();
            _bufferParams.Unit = currentLinearUnit();
            _bufferParams.BufferSpatialReference = new SpatialReference(4326);
            _bufferParams.OutSpatialReference    = _mapWidget.Map.SpatialReference;

            _bufferParams.Features.Clear();
            if (_selectedRadioButtonName == "rbDrawPoints" || _selectedRadioButtonName == "rbSelectedFeaturesFromLayer")
            {
                _bufferParams.Features.AddRange(_bufferPointLayer.Graphics);
            }
            else if (_selectedRadioButtonName == "rbSelectedFeaturesOnMap")
            {
                _bufferPointLayer.ClearGraphics();

                IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d);
                    if (featureL.SelectionCount > 0)
                    {
                        _bufferParams.Features.AddRange(featureL.SelectedGraphics);
                    }
                }
            }

            if (_bufferParams.Features.Count == 0)
            {
                MessageBox.Show("Please select features on the map first", "Error");
                return;
            }

            var bufferDistance = Convert.ToDouble(ringInterval.Text);
            var ringDistance   = bufferDistance;

            var numRings = Convert.ToInt32(numberOfRings.Text);

            for (var i = 0; i < numRings; i++)
            {
                _bufferParams.Distances.Add(ringDistance);
                ringDistance = ringDistance + bufferDistance;
            }

            _geometryService.BufferAsync(_bufferParams);
        }
Esempio n. 3
0
        // ***********************************************************************************
        // * ...Let user enter the incident location on the map
        // ***********************************************************************************
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                _spillLocationGraphicsLayer.ClearGraphics();
                client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                graphic.Geometry = e.MapPoint;

                graphic.Symbol = _mydictionary["spillSymbol"] as client.Symbols.MarkerSymbol;
                graphic.SetZIndex(1);
                _spillLocationGraphicsLayer.Graphics.Add(graphic);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message);
            }
            _mapWidget.Map.MouseClick -= Map_MouseClick;
        }
Esempio n. 4
0
        public bool Configure(Window owner, IList <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources)
        {
            // Allow author to configure the map widget that the earthquakes are shown in.

            // Get a list of all map widgets.
            IEnumerable <MapWidget> mapWidgets = ESRI.ArcGIS.OperationsDashboard.OperationsDashboard.Instance.Widgets.OfType <MapWidget>();

            // Show the configuration dialog, passing in reference to find current MapWidgetId, if set.
            Config.EarthquakeWidgetDialog dialog = new Config.EarthquakeWidgetDialog(mapWidgets, this)
            {
                Owner = owner
            };

            // If the user cancels the configuation dialog, indicate that configuration failed and the widget should not
            // be added to the current confirguration.
            if (dialog.ShowDialog() != true)
            {
                return(false);
            }

            // Retrieve the selected values for the properties from the configuration dialog.
            Caption     = dialog.Caption;
            MapWidgetId = dialog.MapWidget.Id;

            // If re-configuring, then ensure any graphics previously added to either map are removed.
            if (_map != null)
            {
                if ((_graphics != null) && (_map.Layers.Contains(_graphics)))
                {
                    _graphics.ClearGraphics();
                    _map.Layers.Remove(_graphics);
                    _graphics = null;
                }
            }

            // Get the map from the selected widget.
            GetMapAndAddEarthquakes();

            // Indicate that configuration was successful and the widget can be added to the configuration.
            return(true);
        }