예제 #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
     {
         client.Geometry.MapPoint clickPoint = e.MapPoint;
         WebMercator mercator        = new ESRI.ArcGIS.Client.Projection.WebMercator();
         client.Geometry.MapPoint pt = null;
         pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
         if (_graphicsLayer == null)
         {
             _graphicsLayer    = new client.GraphicsLayer();
             _graphicsLayer.ID = "ComputedPoints";
             client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
             if (aclyrs.Count() > 0)
             {
                 aclyrs.ChildLayers.Add(_graphicsLayer);
             }
         }
         ResourceDictionary mydictionary = new ResourceDictionary();
         mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
         client.Graphic graphic = new client.Graphic();
         graphic.Geometry = pt;
         graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
         _graphicsLayer.Graphics.Add(graphic);
         RunButton.IsEnabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in map mouseclick: " + ex.Message);
     }
 }
        private void setupGraphicsLayers()
        {
            try
            {
                _acLayers = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;

                _bufferPolygonLayer = new client.GraphicsLayer()
                {
                    ID = "bufferPolygonLayer"
                };
                _bufferPointLayer = new ESRI.ArcGIS.Client.GraphicsLayer()
                {
                    ID = "bufferPointLayer"
                };

                if (_acLayers.Count() > 0)
                {
                    _acLayers.ChildLayers.Add(_bufferPolygonLayer);
                    _acLayers.ChildLayers.Add(_bufferPointLayer);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }
        }
예제 #3
0
        /// <summary>
        /// Instantiate the properties
        /// </summary>
        /// <param name="mapWidget"></param>
        public FlickrMapToolbar(MapWidget mapWidget)
        {
            InitializeComponent();

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;

            //Set the Tags property so the UIs can be updated
            Tags = new List <string>()
            {
                "Weather", "Trails", "Flood", "Fire", "Wildlife"
            };

            //Get the FlickrManager and create a search options object. They help us talk to the Flickr API
            flickr    = FlickrManager.GetInstance();
            searchOps = new PhotoSearchOptions();

            //The graphic layer which contains the pushpin graphics for the retrieved photos
            pushpinsLayer = new client.GraphicsLayer()
            {
                ID = "pushpinLyr"
            };

            //Info of the retrieved photos (for updating the photo info window)
            photoInfos = new List <PhotoInfo>();

            DataContext = this;
        }
        /// <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
            {
                client.Geometry.MapPoint clickPoint = e.MapPoint;
                if (_graphicsLayer == null)
                {
                    _graphicsLayer    = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphicsLayer.ID = "FarthestOnCircleGraphics";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayer);
                    }
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/FarthestOnCircleAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                client.Graphic graphic = new client.Graphic();
                graphic.Geometry = clickPoint;
                graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.Graphics.Add(graphic);

                RunButton.IsEnabled = true;
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
예제 #5
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)
        {
            client.Geometry.MapPoint clickPoint = e.MapPoint;
            //WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
            ///client.Geometry.MapPoint pt = null;
            //pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
            if (_graphicsLayer == null)
            {
                _graphicsLayer = new client.GraphicsLayer();

                _graphicsLayer.ID = "AircraftCommunicationGraphics";
                client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                if (aclyrs.Count() > 0)
                {
                    aclyrs.ChildLayers.Add(_graphicsLayer);
                }
            }
            ResourceDictionary mydictionary = new ResourceDictionary();

            mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
            client.Graphic graphic = new client.Graphic();
            //graphic.Geometry = pt;
            graphic.Geometry = clickPoint;
            graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
            _graphicsLayer.Graphics.Add(graphic);

            if (_graphicsLayer != null && _graphicsLayerPoly != null)
            {
                if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0)
                {
                    RunButton.IsEnabled = true;
                }
            }
        }
예제 #6
0
        void gp_GetResultDataCompleted(object sender, GPParameterEventArgs e)
        {
            _graphicsLayer.Graphics.Clear();
            ResourceDictionary mydictionary = new ResourceDictionary();

            mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
            //client.SimpleRenderer simRen = mydictionary["RouteRenderer"] as client.SimpleRenderer;

            client.GraphicsLayer gLayer = _mapWidget.Map.Layers["ComputedLine"] as client.GraphicsLayer;
            if (gLayer == null)
            {
                gLayer    = new client.GraphicsLayer();
                gLayer.ID = "ComputedLine";
                //gLayer.Renderer = simRen;
                //client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                //if (aclyrs.Count() > 0)
                _mapWidget.Map.Layers.Add(gLayer);
            }
            GPFeatureRecordSetLayer gpFLayer = e.Parameter as GPFeatureRecordSetLayer;

            if (gpFLayer.FeatureSet.Features.Count > 0)
            {
                foreach (client.Graphic g in gpFLayer.FeatureSet.Features)
                {
                    g.Symbol = mydictionary["BasicLineSymbol_Green_3"] as client.Symbols.LineSymbol;
                    gLayer.Graphics.Add(g);
                }
            }
        }
예제 #7
0
        private void gpSateEphemeris_JobCompleted(object sender, JobInfoEventArgs e)
        {
            try
            {
                if (_graphicsLayerPoly == null)
                {
                    _graphicsLayerPoly    = new client.GraphicsLayer();
                    _graphicsLayerPoly.ID = "SensorFootprints";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayerPoly);
                    }
                }
                else
                {
                    _graphicsLayerPoly.Graphics.Clear();
                }
                if (_graphicsLayerLine == null)
                {
                    _graphicsLayerLine    = new client.GraphicsLayer();
                    _graphicsLayerLine.ID = "EphemerisLines";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayerLine);
                    }
                }
                else
                {
                    _graphicsLayerLine.Graphics.Clear();
                }
                if (_graphicsLayerPoint == null)
                {
                    _graphicsLayerPoint    = new client.GraphicsLayer();
                    _graphicsLayerPoint.ID = "EphemerisPoints";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayerPoint);
                    }
                }
                else
                {
                    _graphicsLayerPoint.Graphics.Clear();
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/SatelliteEphemerisGenerationAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                gp     = sender as Geoprocessor;
                _jobid = e.JobInfo.JobId;
                gp.GetResultDataAsync(e.JobInfo.JobId, "SensorFootprints", "Footprints");
                gp.GetResultDataCompleted += gp_GetResultDataCompleted;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
예제 #8
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);
            }
        }
예제 #9
0
        }         // private ESRI.ArcGIS.Client.GraphicsLayer setContent(string id, string xmlContent)

        public static ESRI.ArcGIS.Client.GraphicsLayer setContent(
            ESRI.ArcGIS.Client.GraphicsLayer gl, string xmlContent)
        {
            var sr = new StringReader(xmlContent);
            var xr = XmlReader.Create(sr);

            //gl.Graphics.Clear();
            gl.DeserializeGraphics(xr);
            xr.Close();
            sr.Close();
            return(gl);
        }         // public static ESRI.ArcGIS.Client.GraphicsLayer setContent(ESRI.ArcGIS.Client.GraphicsLayer gl, string xmlContent)
예제 #10
0
 private void ClearButton_Click(object sender, RoutedEventArgs e)
 {
     if (_graphicsLayer != null)
     {
         _graphicsLayer.Graphics.Clear();
     }
     client.GraphicsLayer gLayer = _mapWidget.Map.Layers["ComputedLine"] as client.GraphicsLayer;
     if (gLayer != null)
     {
         gLayer.Graphics.Clear();
     }
     RunButton.IsEnabled = false;
 }
예제 #11
0
        /// <summary>
        /// Called when a DataSource found in the DataSourceIds property is updated.
        /// </summary>
        /// <param name="dataSource">The DataSource being updated.</param>
        public async void OnRefresh(DataSource dataSource)
        {
            try
            {
                int[] oIds  = new int[_rfFeatures.Count];
                int   count = 0;
                foreach (Feature f in _rfFeatures)
                {
                    oIds[count] = System.Convert.ToInt32(f.Graphic.Attributes[dataSource.ObjectIdFieldName].ToString());
                    System.Diagnostics.Debug.WriteLine("Refresh:  " + oIds[count].ToString());
                    count++;
                }
                Query q = new Query();
                q.ReturnGeometry = true;

                var result = await dataSource.ExecuteQueryObjectIdsAsync(oIds, q);

                if (result == null || result.Features == null)
                {
                    return;
                }


                client.GraphicsLayer gLayer = _map.Layers["RangeFanGraphics"] as client.GraphicsLayer;
                if (gLayer != null)
                {
                    if (gLayer.Graphics.Count == result.Features.Count)
                    {
                        foreach (client.Graphic g in result.Features)
                        {
                            client.Graphic pFan = CreateFan(g);
                            if (pFan != null)
                            {
                                foreach (client.Graphic graphic in gLayer.Graphics)
                                {
                                    if (graphic.Attributes["Name"].ToString() == g.Attributes[_datasource.ObjectIdFieldName].ToString())
                                    {
                                        graphic.Geometry = pFan.Geometry;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
예제 #12
0
        public bool addToList(client.Graphic pGraphic)
        {
            try
            {
                if (_map == null)
                {
                    GetMapFromWidget();
                }

                if (_graphics == null)
                {
                    _graphics    = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphics.ID = "RangeFanGraphics";
                    _map.Layers.Add(_graphics);
                }

                string oID      = _datasource.ObjectIdFieldName;
                bool   contains = false;
                foreach (Feature p in _rfFeatures)
                {
                    if (p.Graphic.Attributes[oID].ToString() == pGraphic.Attributes[oID].ToString())
                    {
                        contains = true;
                    }
                }
                if (contains == false)
                {
                    Feature pFeature = new Feature(pGraphic, Field);


                    client.Graphic cFan = CreateFan(pGraphic);
                    if (cFan != null)
                    {
                        _graphics.Graphics.Add(cFan);
                    }

                    _rfFeatures.Add(pFeature);

                    FeatureListBox.ItemsSource = null;
                    FeatureListBox.ItemsSource = _rfFeatures;
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #13
0
        /// <summary>
        ///  OnDeactivated is called before the toolbar is uninstalled from the map widget.
        /// </summary>
        public void OnDeactivated()
        {
            if (_mapWidget == null)
            {
                return;
            }

            //Unregister the events
            _mapWidget.Map.MouseLeftButtonDown -= Map_MouseLeftButtonDown;
            _mapWidget.Map.MouseMove           -= Map_MouseMove;
            _mapWidget.Map.MouseLeftButtonUp   -= Map_MouseLeftButtonUp;

            //Discard the sketch layer
            _mapWidget.Map.Layers.Remove(sketchLayer);
            sketchLayer = null;
        }
예제 #14
0
        public ProfileGraphFromMap()
        {
            InitializeComponent();

            selecteDataPointLyr = new client.GraphicsLayer()
            {
                ID = "selecteDataPointLyr"
            };
            mapSketchLyr = new client.GraphicsLayer()
            {
                ID = "mapSketchLyr"
            };

            Caption = "Profile Graph Widget";

            IsGraphVisible = Visibility.Collapsed;

            DataContext = this;
        }
예제 #15
0
 private void DoneButton_Click(object sender, RoutedEventArgs e)
 {
     // When the user is finished with the toolbar, revert to the configured toolbar.
     if (_mapWidget != null)
     {
         _mapWidget.Map.MouseClick -= Map_MouseClick;
         _mapWidget.SetToolbar(null);
         if (_graphicsLayer != null)
         {
             _graphicsLayer.Graphics.Clear();
         }
         client.GraphicsLayer gLayer = _mapWidget.Map.Layers["ComputedLine"] as client.GraphicsLayer;
         if (gLayer != null)
         {
             gLayer.Graphics.Clear();
         }
         RunButton.IsEnabled = false;
     }
 }
예제 #16
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);
        }
예제 #17
0
        } // public string getContent()

        private ESRI.ArcGIS.Client.GraphicsLayer setContent(
            string id,
            string xmlContent)
        {
            // create and deserialize GraphicsLayer
            var gl = new ESRI.ArcGIS.Client.GraphicsLayer()
            {
                ID       = id,
                Renderer = new SimpleRenderer()
                {
                    Symbol = new SimpleMarkerSymbol()
                }
            };

            gl.RendererTakesPrecedence = false;
            // Set layer name in Map Contents
            gl.SetValue(MapApplication.LayerNameProperty, lyrName);

            gl = setContent(gl, xmlContent);
            return(gl);
        } // private ESRI.ArcGIS.Client.GraphicsLayer setContent(string id, string xmlContent)
        void myQueryTask_ExecuteCompleted(object sender, QueryEventArgs queryArgs)
        {
            if (queryArgs.FeatureSet == null)
            {
                return;
            }

            FeatureSet resultFeatureSet = queryArgs.FeatureSet;

            ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer =
                MyMap.Layers["MyGraphicsLayer"] as ESRI.ArcGIS.Client.GraphicsLayer;

            if (resultFeatureSet != null && resultFeatureSet.Features.Count > 0)
            {
                foreach (ESRI.ArcGIS.Client.Graphic graphicFeature in resultFeatureSet.Features)
                {
                    graphicFeature.Symbol = LayoutRoot.Resources["TransparentFillSymbol"] as Symbol;
                    graphicsLayer.Graphics.Add(graphicFeature);
                }
            }
        }
예제 #19
0
        void targetAreaDraw_DrawComplete(object sender, client.DrawEventArgs e)
        {
            try
            {
                if (_graphicsLayerPoly == null)
                {
                    _graphicsLayerPoly    = new client.GraphicsLayer();
                    _graphicsLayerPoly.ID = "AircraftCommunicationGraphicsPoly";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayerPoly);
                    }
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                WebMercator    mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
                client.Graphic g        = new client.Graphic();
                //g.Geometry = mercator.ToGeographic(e.Geometry) as client.Geometry.Polygon;
                //g.Symbol = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol;
                g.Geometry = e.Geometry as client.Geometry.Polygon;
                g.Symbol   = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol;
                _graphicsLayerPoly.Graphics.Add(g);
                targetAreaDraw.DrawMode = client.DrawMode.None;
                if (_graphicsLayer != null && _graphicsLayerPoly != null)
                {
                    if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0)
                    {
                        RunButton.IsEnabled = true;
                    }
                }

                targetAreaDraw.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in draw complete: " + ex.Message);
            }
        }
예제 #20
0
        // ***********************************************************************************
        // * add graphicslayers to the AcceleratedDisplayLayers group layer
        // ***********************************************************************************
        private void setupGraphicsLayers()
        {
            try
            {
                client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;

                _ergZoneGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer()
                {
                    ID = "ergZoneGraphicsLayer"
                };
                if (aclyrs.Count() > 0)
                {
                    aclyrs.ChildLayers.Add(_ergZoneGraphicsLayer);
                }

                _spillLocationGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer()
                {
                    ID = "spillLocationGraphicsLayer"
                };
                if (aclyrs.Count() > 0)
                {
                    aclyrs.ChildLayers.Add(_spillLocationGraphicsLayer);
                }

                _facilitiesGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer()
                {
                    ID = "facilitiesGraphicsLayer"
                };
                if (aclyrs.Count() > 0)
                {
                    aclyrs.ChildLayers.Add(_facilitiesGraphicsLayer);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }
        }
예제 #21
0
        /// <summary>
        /// OnActivated is called when the toolbar is installed into the map widget.
        /// </summary>
        public void OnActivated()
        {
            if (_mapWidget == null)
            {
                return;
            }

            //Register left button down i.e. sketch begins
            //Register mouse move i.e. sketch continues
            //Register left button up i.e. sketch finishes
            _mapWidget.Map.MouseLeftButtonDown += Map_MouseLeftButtonDown;
            _mapWidget.Map.MouseMove           += Map_MouseMove;
            _mapWidget.Map.MouseLeftButtonUp   += Map_MouseLeftButtonUp;

            //Crate the sketch layer and add it to the map
            sketchLayer = new client.GraphicsLayer();
            _mapWidget.Map.Layers.Add(sketchLayer);

            //Set the default color and width of the sketch
            SelectedColor     = (Color)ColorConverter.ConvertFromString("#000000");
            SelectedLineWidth = LineWidth.Thin;
        }
예제 #22
0
        /// <summary>
        /// Extracts earthquake information from the feed and turns this into a graphics layer in the map.
        /// </summary>
        private void AddEarthquakesToMap()
        {
            if ((_map == null) || (_xmlData == null) || (_xmlData.Document == null))
            {
                return;
            }

            //XmlDocument doc = _xmlData.Document as XmlDocument;
            if (_xmlData.Document.ChildNodes == null)
            {
                return;
            }

            // extract earthquake nodes.
            XmlNodeList entries = _xmlData.Document.SelectNodes("//d:feed//d:entry", _xmlData.XmlNamespaceManager);

            // Create new graphics container object, or fill existing one, with the entries from the feed.
            var itmsSource = _xmlData.Document.ChildNodes;

            if (_rssGraphics == null)
            {
                _rssGraphics = new GraphicsRssSource(entries, _sym);
            }
            else
            {
                _rssGraphics.Fill(entries);
            }

            // If the graphics layer is not already created, then create it and bind to the collection of earthquake graphics,
            // and add the layer to the map.
            if (_allQuakes == null)
            {
                _allQuakes                = new client.GraphicsLayer();
                _allQuakes.ID             = "EarthquakeWidget.AllQuakesGraphicsLayer";
                _allQuakes.GraphicsSource = _rssGraphics;
                _map.Layers.Add(_allQuakes);
            }
        }
예제 #23
0
        /// <summary>
        ///  OnDeactivated is called before the toolbar is uninstalled from the map widget.
        /// </summary>
        public void OnDeactivated()
        {
            if (_mapWidget == null || _mapWidget.Map == null)
            {
                return;
            }

            //Discard the graphicsLayer
            pushpinsLayer.MouseEnter -= graphicsLayer_MouseEnter;
            pushpinsLayer.MouseLeave -= graphicsLayer_MouseLeave;

            if (_mapWidget.Map.Layers.Contains(pushpinsLayer))
            {
                try
                {
                    _mapWidget.Map.Layers.Remove(pushpinsLayer);
                }
                catch
                {
                }
                pushpinsLayer = null;
            }
        }
        void myQueryTask_ExecuteCompleted(object sender, QueryEventArgs queryArgs)
        {
            if (queryArgs.FeatureSet == null)
            {
                return;
            }

            FeatureSet resultFeatureSet = queryArgs.FeatureSet;

            ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer =
                MyMap.Layers["MyGraphicsLayer"] as ESRI.ArcGIS.Client.GraphicsLayer;

            if (resultFeatureSet != null && resultFeatureSet.Features.Count > 0)
            {
                foreach (ESRI.ArcGIS.Client.Graphic graphicFeature in resultFeatureSet.Features)
                {
                    //graphicFeature.Symbol = LayoutRoot.Resources["TransparentFillSymbol"] as Symbol;
                    graphicFeature.Symbol = LayoutRoot.Resources["videoFill"] as Symbol;
                    string stateName = Convert.ToString(graphicFeature.Attributes["STATE_NAME"]);
                    graphicFeature.Attributes.Add("VideoSource", String.Format("http://serverapps.esri.com/media/{0}_small.wmv", stateName));
                    graphicsLayer.Graphics.Add(graphicFeature);
                }
            }
        }
        /// <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);
            }
        }
        public bool addToList(client.Graphic pGraphic)
        {
            try
            {
                if (_map == null)
                    GetMapFromWidget();

                if (_graphics == null)
                {
                    _graphics = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphics.ID = "RangeFanGraphics";
                    _map.Layers.Add(_graphics);
                }
                
                string oID = _datasource.ObjectIdFieldName;
                bool contains = false;
                foreach (Feature p in _rfFeatures)
                {
                    if (p.Graphic.Attributes[oID].ToString() == pGraphic.Attributes[oID].ToString())
                        contains = true;
                }
                if (contains == false)
                {
                    Feature pFeature = new Feature(pGraphic, Field);


                    client.Graphic cFan = CreateFan(pGraphic);
                    if (cFan != null)
                        _graphics.Graphics.Add(cFan);

                    _rfFeatures.Add(pFeature);

                    FeatureListBox.ItemsSource = null;
                    FeatureListBox.ItemsSource = _rfFeatures;
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
        // ***********************************************************************************
        // * add graphicslayers to the AcceleratedDisplayLayers group layer
        // ***********************************************************************************
        private void setupGraphicsLayers()
        {
            try
            {
                client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;

                _ergZoneGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "ergZoneGraphicsLayer" };
                if (aclyrs.Count() > 0)
                    aclyrs.ChildLayers.Add(_ergZoneGraphicsLayer);

                _spillLocationGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "spillLocationGraphicsLayer" };
                if (aclyrs.Count() > 0)
                    aclyrs.ChildLayers.Add(_spillLocationGraphicsLayer);

                _facilitiesGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "facilitiesGraphicsLayer" };
                if (aclyrs.Count() > 0)
                    aclyrs.ChildLayers.Add(_facilitiesGraphicsLayer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }
        }
예제 #28
0
        }         // public void initRelations()

        private Layer createLayer(string id, bool vis)
        {
            // create Layer according to its Type
            string typ = lyrType;

            ESRI.ArcGIS.Client.Layer res = new ESRI.ArcGIS.Client.GraphicsLayer();

            if (typ == "ArcGISTiledMapServiceLayer")
            {
                var lr = new ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer();
                lr.Url      = lyrUrl;
                lr.ProxyURL = proxy;
                res         = lr;
            }
            else if (typ == "OpenStreetMapLayer")
            {
                var lr = new ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer();
                res = lr;
            }
            else if (typ == "ArcGISDynamicMapServiceLayer")
            {
                var lr = new ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer();
                lr.Url         = lyrUrl;
                lr.ProxyURL    = proxy;
                lr.ImageFormat = imageFormat;
                res            = lr;
            }
            else if (typ == "FeatureLayer")
            {
                var lr = new ESRI.ArcGIS.Client.FeatureLayer()
                {
                    Url = lyrUrl, ProxyUrl = proxy
                };
                lr.OutFields.Add("*");
                lr.Mode = FeatureLayer.QueryMode.OnDemand;
                lr.Initialize();                 // retrieve attribs from server
                var rr = rendererFromJson(renderer);
                if (rr != null)
                {
                    lr.Renderer = rr;
                }
                res = lr;
            }
            else if (typ == "GraphicsLayer")
            {
                var gl = setContent(id, lyrUrl);
                var rr = rendererFromJson(renderer);
                if (rr != null)
                {
                    gl.Renderer = rr;
                }
                res = gl;
            }

            if (res != null)
            {
                ESRI.ArcGIS.Client.Extensibility.LayerProperties.SetIsPopupEnabled(res, popupOn);

                // sublayers popups on/off
                if (identifyLayerIds.Length <= 3)
                {
                    ;
                }
                else
                {
                    var xmlszn = new System.Xml.Serialization.XmlSerializer(typeof(System.Collections.ObjectModel.Collection <int>));
                    var sr     = new StringReader(identifyLayerIds);
                    var ids    = xmlszn.Deserialize(sr) as System.Collections.ObjectModel.Collection <int>;
                    ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetIdentifyLayerIds(res, ids);
                }
            }

            return(res);
        }         // private Layer createLayer(string id, bool vis)
예제 #29
0
        void locatorTask_AddressToLocationsCompleted(object sender, AddressToLocationsEventArgs e)
        {
            try
            {
                List <AddressCandidate> returnedCandidates = e.Results;
                int BuildingEvacDistance = 0;
                int OutdoorEvacDistance  = 0;

                if (bombType.Text == "Pipe bomb")
                {
                    BuildingEvacDistance = 70;
                    OutdoorEvacDistance  = 1200;
                }
                else if (bombType.Text == "Suicide vest")
                {
                    BuildingEvacDistance = 110;
                    OutdoorEvacDistance  = 1750;
                }
                else if (bombType.Text == "Briefcase/suitcase bomb")
                {
                    BuildingEvacDistance = 150;
                    OutdoorEvacDistance  = 1850;
                }
                else if (bombType.Text == "Sedan")
                {
                    BuildingEvacDistance = 320;
                    OutdoorEvacDistance  = 1900;
                }
                else if (bombType.Text == "SUV/van")
                {
                    BuildingEvacDistance = 400;
                    OutdoorEvacDistance  = 2400;
                }
                else if (bombType.Text == "Small delivery truck")
                {
                    BuildingEvacDistance = 640;
                    OutdoorEvacDistance  = 3800;
                }
                else if (bombType.Text == "Container/water truck")
                {
                    BuildingEvacDistance = 860;
                    OutdoorEvacDistance  = 5100;
                }
                else if (bombType.Text == "Semi-trailer")
                {
                    BuildingEvacDistance = 1570;
                    OutdoorEvacDistance  = 9300;
                }

                if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                {
                    return;
                }

                if (e.Results.Count > 0)
                {
                    AddressCandidate candidate = returnedCandidates[0];

                    ResourceDictionary mydictionary = new ResourceDictionary();
                    mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = candidate.Location;
                    graphic.Symbol   = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;

                    location = candidate.Location;
                    graphic.SetZIndex(1);
                    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.Graphics.Add(graphic);

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url     = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"; geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference    = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);
                }
                else
                {
                    MessageBox.Show("No address found.  Example schema: 380 New York Ave., Redlands, CA or click on the map");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Address location complete: " + ex.Message);
            }
        }
        /// <summary>
        /// Draw the features on map using a temporary GraphicsLayer
        /// </summary>
        private void AddFeaturesToMap()
        {
            if (FieldHeadersInfo == null || Features == null || Features.Count == 0)
            return;

              //note: we will use the first map widget in the view
              //developers can update the logic to pick another map widget to display the layer
              MapWidget mapWidget = OperationsDashboard.Instance.Widgets.FirstOrDefault(w => w.GetType() == typeof(MapWidget)) as MapWidget;
              if (mapWidget == null || mapWidget.Map == null || !mapWidget.Map.IsInitialized)
            return;

              //Get the lat field, long field and display field to help us create the graphics
              FieldInfo latField = FieldHeadersInfo.SelectedLatField;
              FieldInfo longField = FieldHeadersInfo.SelectedLongField;
              FieldInfo displayField = FieldHeadersInfo.SelectedDisplayField;

              //Create a Graphics object which will contain the graphics representing the records
              Graphics graphics = new Graphics();
              graphics.ConvertFeaturesToGraphics(Features, latField, longField, displayField);

              //Create a GraphicsLayer which point the GraphicsSource to the graphics object
              graphicsLayers = new client.GraphicsLayer();
              graphicsLayers.ID = "tempGraphicsLyr" + System.Guid.NewGuid();
              graphicsLayers.GraphicsSource = graphics;
              graphicsLayers.Visible = true;

              //Add the GraphicsLayer to the map
              mapWidget.Map.Layers.Add(graphicsLayers);
        }
        // ***********************************************************************************
        // * Setup all graphicslayers that will be used by the map tool
        // ***********************************************************************************
        private void setupGraphicsLayer()
        {
            //Check if the graphicslayers are in the map if so then skip adding the layers...
            //... barriers ...
            //create and add barrier graphicslayer to the map
            // Find the AcceleratedDisplayLayers collection from the Map and add the barrier graphics layer
            client.AcceleratedDisplayLayers acLayers = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
            if (acLayers.ChildLayers[_polylineBarriersGraphicsLayerID] == null)
            {
                _polylineBarriersGraphicLayer = new client.GraphicsLayer()
                {
                    ID = _polylineBarriersGraphicsLayerID,
                };
                acLayers.ChildLayers.Add(_polylineBarriersGraphicLayer);
            }
            else
            {
                _polylineBarriersGraphicLayer = (GraphicsLayer)acLayers.ChildLayers[_polylineBarriersGraphicsLayerID];
            }

            //set up polygon barriers
            if (acLayers.ChildLayers[_polygonBarriersGraphicsLayerID] == null)
            {
                _polygonBarriersGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _polygonBarriersGraphicsLayerID
                };

                acLayers.ChildLayers.Add(_polygonBarriersGraphicsLayer);
            }
            else
            {
                _polygonBarriersGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_polygonBarriersGraphicsLayerID];
            }

            //set up routes graphics layer
            //this layer will contain find closest facility results
            if (acLayers.ChildLayers[_routesGraphicsLayerID] == null)
            {
                _routesGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _routesGraphicsLayerID,
                };
                acLayers.ChildLayers.Add(_routesGraphicsLayer);
            }
            else
            {
                _routesGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_routesGraphicsLayerID];
            }

            if (acLayers.ChildLayers[_highlightRouteLayerID] == null)
            {
                HiglightRouteLayer = new client.GraphicsLayer()
                {
                    ID = _highlightRouteLayerID
                };
                acLayers.ChildLayers.Add(HiglightRouteLayer);
            }
            else
            {
                HiglightRouteLayer = (GraphicsLayer)acLayers.ChildLayers[_highlightRouteLayerID];
            }

            if (acLayers.ChildLayers[_routeLabelsGraphicsLayerID] == null)
            {
                _routeLabelsGraphicsLayer = new GraphicsLayer()
                {
                    ID = _routeLabelsGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_routeLabelsGraphicsLayer);
            }
            else
            {
                _routeLabelsGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_routeLabelsGraphicsLayerID];
            }


            // create and add incidentGraphicsLayer to the map
            if (acLayers.ChildLayers[_incidentsGraphicsLayerID] == null)
            {
                _incidentsGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _incidentsGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_incidentsGraphicsLayer);
            }
            else
            {
                _incidentsGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_incidentsGraphicsLayerID];
            }

            //set up facilities graphicsLayer
            if (acLayers.ChildLayers[_facilitiesGraphicsLayerID] == null)
            {
                _facilitiesGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _facilitiesGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_facilitiesGraphicsLayer);
            }
            else
            {
                _facilitiesGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_facilitiesGraphicsLayerID];
            }

            //set up point barrier geometries
            if (acLayers.ChildLayers[_pointBarriersGraphicsLayerID] == null)
            {
                _pointBarriersGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _pointBarriersGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_pointBarriersGraphicsLayer);
            }
            else
            {
                _pointBarriersGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_pointBarriersGraphicsLayerID];
            }
        }
        // ***********************************************************************************
        // * Setup all graphicslayers that will be used by the map tool 
        // ***********************************************************************************
        private void setupGraphicsLayer()
        {
            //Check if the graphicslayers are in the map if so then skip adding the layers... 
            //... barriers ... 
            //create and add barrier graphicslayer to the map
            // Find the AcceleratedDisplayLayers collection from the Map and add the barrier graphics layer
            client.AcceleratedDisplayLayers acLayers = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
            if (acLayers.ChildLayers[_polylineBarriersGraphicsLayerID] == null)
            {
                _polylineBarriersGraphicLayer = new client.GraphicsLayer()
                {
                    ID = _polylineBarriersGraphicsLayerID,
                };
                acLayers.ChildLayers.Add(_polylineBarriersGraphicLayer);
            }
            else
                _polylineBarriersGraphicLayer = (GraphicsLayer)acLayers.ChildLayers[_polylineBarriersGraphicsLayerID];

            //set up polygon barriers
            if (acLayers.ChildLayers[_polygonBarriersGraphicsLayerID] == null)
            {
                _polygonBarriersGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _polygonBarriersGraphicsLayerID
                };

                acLayers.ChildLayers.Add(_polygonBarriersGraphicsLayer);
            }
            else
                _polygonBarriersGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_polygonBarriersGraphicsLayerID];

            //set up routes graphics layer 
            //this layer will contain find closest facility results 
            if (acLayers.ChildLayers[_routesGraphicsLayerID] == null)
            {
                _routesGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _routesGraphicsLayerID,
                };
                acLayers.ChildLayers.Add(_routesGraphicsLayer);
            }
            else
                _routesGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_routesGraphicsLayerID];

            if (acLayers.ChildLayers[_highlightRouteLayerID] == null)
            {
                HiglightRouteLayer = new client.GraphicsLayer()
                {
                    ID = _highlightRouteLayerID
                };
                acLayers.ChildLayers.Add(HiglightRouteLayer);
            }
            else
                HiglightRouteLayer = (GraphicsLayer)acLayers.ChildLayers[_highlightRouteLayerID];

            if (acLayers.ChildLayers[_routeLabelsGraphicsLayerID] == null)
            {
                _routeLabelsGraphicsLayer = new GraphicsLayer()
                {
                    ID = _routeLabelsGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_routeLabelsGraphicsLayer);
            }
            else
                _routeLabelsGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_routeLabelsGraphicsLayerID];


            // create and add incidentGraphicsLayer to the map
            if (acLayers.ChildLayers[_incidentsGraphicsLayerID] == null)
            {
                _incidentsGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _incidentsGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_incidentsGraphicsLayer);
            }
            else
                _incidentsGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_incidentsGraphicsLayerID];

            //set up facilities graphicsLayer 
            if (acLayers.ChildLayers[_facilitiesGraphicsLayerID] == null)
            {
                _facilitiesGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _facilitiesGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_facilitiesGraphicsLayer);
            }
            else
                _facilitiesGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_facilitiesGraphicsLayerID];

            //set up point barrier geometries 
            if (acLayers.ChildLayers[_pointBarriersGraphicsLayerID] == null)
            {
                _pointBarriersGraphicsLayer = new client.GraphicsLayer()
                {
                    ID = _pointBarriersGraphicsLayerID
                };
                acLayers.ChildLayers.Add(_pointBarriersGraphicsLayer);
            }
            else
                _pointBarriersGraphicsLayer = (GraphicsLayer)acLayers.ChildLayers[_pointBarriersGraphicsLayerID];

        }
        /// <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
            {
                client.Geometry.MapPoint clickPoint = e.MapPoint;
                if (_graphicsLayer == null)
                {
                    _graphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphicsLayer.ID = "FarthestOnCircleGraphics";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayer);
                    }
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/FarthestOnCircleAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                client.Graphic graphic = new client.Graphic();
                graphic.Geometry = clickPoint;
                graphic.Symbol = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.Graphics.Add(graphic);

                RunButton.IsEnabled = true;
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
 /// <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
     {
         client.Geometry.MapPoint clickPoint = e.MapPoint;
         WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
         client.Geometry.MapPoint pt = null;
         pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
         if (_graphicsLayer == null)
         {
             _graphicsLayer = new client.GraphicsLayer();
             _graphicsLayer.ID = "ComputedPoints";
             client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
             if (aclyrs.Count() > 0)
                 aclyrs.ChildLayers.Add(_graphicsLayer);
         }
         ResourceDictionary mydictionary = new ResourceDictionary();
         mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
         client.Graphic graphic = new client.Graphic();
         graphic.Geometry = pt;
         graphic.Symbol = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
         _graphicsLayer.Graphics.Add(graphic);
         RunButton.IsEnabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in map mouseclick: " + ex.Message);
     }
 }
        void gp_GetResultDataCompleted(object sender, GPParameterEventArgs e)
        {
            _graphicsLayer.Graphics.Clear();
            ResourceDictionary mydictionary = new ResourceDictionary();
            mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
            //client.SimpleRenderer simRen = mydictionary["RouteRenderer"] as client.SimpleRenderer;

            client.GraphicsLayer gLayer = _mapWidget.Map.Layers["ComputedLine"] as client.GraphicsLayer;
            if (gLayer == null)
            {
                gLayer = new client.GraphicsLayer();
                gLayer.ID = "ComputedLine";
                //gLayer.Renderer = simRen;
                //client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                //if (aclyrs.Count() > 0)
                _mapWidget.Map.Layers.Add(gLayer);
            }
            GPFeatureRecordSetLayer gpFLayer = e.Parameter as GPFeatureRecordSetLayer;
            if (gpFLayer.FeatureSet.Features.Count > 0)
            {
                foreach (client.Graphic g in gpFLayer.FeatureSet.Features)
                {
                    g.Symbol = mydictionary["BasicLineSymbol_Green_3"] as client.Symbols.LineSymbol;
                    gLayer.Graphics.Add(g);
                }
            }
        }
        /// <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)
        {
            client.Geometry.MapPoint clickPoint = e.MapPoint;
            //WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
            ///client.Geometry.MapPoint pt = null;
            //pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
            if (_graphicsLayer == null)
            {
                _graphicsLayer = new client.GraphicsLayer();

                _graphicsLayer.ID = "AircraftCommunicationGraphics";
                client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                if (aclyrs.Count() > 0)
                    aclyrs.ChildLayers.Add(_graphicsLayer);
            }
            ResourceDictionary mydictionary = new ResourceDictionary();
            mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
            client.Graphic graphic = new client.Graphic();
            //graphic.Geometry = pt;
            graphic.Geometry = clickPoint;
            graphic.Symbol = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
            _graphicsLayer.Graphics.Add(graphic);

            if (_graphicsLayer != null && _graphicsLayerPoly != null)
                if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0)
                    RunButton.IsEnabled = true;
        }
        void targetAreaDraw_DrawComplete(object sender, client.DrawEventArgs e)
        {
            try
            {
                if (_graphicsLayerPoly == null)
                {
                    _graphicsLayerPoly = new client.GraphicsLayer();
                    _graphicsLayerPoly.ID = "AircraftCommunicationGraphicsPoly";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                        aclyrs.ChildLayers.Add(_graphicsLayerPoly);
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
                client.Graphic g = new client.Graphic();
                //g.Geometry = mercator.ToGeographic(e.Geometry) as client.Geometry.Polygon;
                //g.Symbol = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol;
                g.Geometry = e.Geometry as client.Geometry.Polygon;
                g.Symbol = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol;
                _graphicsLayerPoly.Graphics.Add(g);
                targetAreaDraw.DrawMode = client.DrawMode.None;
                if (_graphicsLayer != null && _graphicsLayerPoly != null)
                    if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0)
                        RunButton.IsEnabled = true;

                targetAreaDraw.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in draw complete: " + ex.Message);
            }
        }
        /// <summary>
        /// Extracts earthquake information from the feed and turns this into a graphics layer in the map. 
        /// </summary>
        private void AddEarthquakesToMap()
        {
            if ((_map == null) || (_xmlData == null) || (_xmlData.Document == null)) return;

             //XmlDocument doc = _xmlData.Document as XmlDocument;
             if (_xmlData.Document.ChildNodes == null) return;

             // extract earthquake nodes.
             XmlNodeList entries = _xmlData.Document.SelectNodes("//d:feed//d:entry", _xmlData.XmlNamespaceManager);

             // Create new graphics container object, or fill existing one, with the entries from the feed.
             var itmsSource = _xmlData.Document.ChildNodes;
             if (_rssGraphics == null)
             {
            _rssGraphics = new GraphicsRssSource(entries, _sym);
             }
             else
             {
            _rssGraphics.Fill(entries);
             }

             // If the graphics layer is not already created, then create it and bind to the collection of earthquake graphics,
             // and add the layer to the map.
             if (_allQuakes == null)
             {
            _allQuakes = new client.GraphicsLayer();
            _allQuakes.ID = "EarthquakeWidget.AllQuakesGraphicsLayer";
            _allQuakes.GraphicsSource = _rssGraphics;
            _map.Layers.Add(_allQuakes);
             }
        }
        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;
        }
        void locatorTask_AddressToLocationsCompleted(object sender, AddressToLocationsEventArgs e)
        {
            try
            {
                List<AddressCandidate> returnedCandidates = e.Results;
                int BuildingEvacDistance = 0;
                int OutdoorEvacDistance = 0;

                if (bombType.Text == "Pipe bomb")
                {
                    BuildingEvacDistance = 70;
                    OutdoorEvacDistance = 1200;
                }
                else if (bombType.Text == "Suicide vest")
                {
                    BuildingEvacDistance = 110;
                    OutdoorEvacDistance = 1750;
                }
                else if (bombType.Text == "Briefcase/suitcase bomb")
                {
                    BuildingEvacDistance = 150;
                    OutdoorEvacDistance = 1850;
                }
                else if (bombType.Text == "Sedan")
                {
                    BuildingEvacDistance = 320;
                    OutdoorEvacDistance = 1900;
                }
                else if (bombType.Text == "SUV/van")
                {
                    BuildingEvacDistance = 400;
                    OutdoorEvacDistance = 2400;
                }
                else if (bombType.Text == "Small delivery truck")
                {
                    BuildingEvacDistance = 640;
                    OutdoorEvacDistance = 3800;
                }
                else if (bombType.Text == "Container/water truck")
                {
                    BuildingEvacDistance = 860;
                    OutdoorEvacDistance = 5100;
                }
                else if (bombType.Text == "Semi-trailer")
                {
                    BuildingEvacDistance = 1570;
                    OutdoorEvacDistance = 9300;
                }

                if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                    return;

                if (e.Results.Count > 0)
                {
                    AddressCandidate candidate = returnedCandidates[0];

                    ResourceDictionary mydictionary = new ResourceDictionary();
                    mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = candidate.Location;
                    graphic.Symbol = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;

                    location = candidate.Location;
                    graphic.SetZIndex(1);
                    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.Graphics.Add(graphic);

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"; geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);

                }
                else
                {
                    MessageBox.Show("No address found.  Example schema: 380 New York Ave., Redlands, CA or click on the map");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Address location complete: " + ex.Message);
            }
        }
        private void setupGraphicsLayers()
        {
            try
            {
                _acLayers = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;

                _bufferPolygonLayer = new client.GraphicsLayer() { ID = "bufferPolygonLayer" };
                _bufferPointLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "bufferPointLayer" };
              
                if (_acLayers.Count() > 0)
                {
                    _acLayers.ChildLayers.Add(_bufferPolygonLayer);
                    _acLayers.ChildLayers.Add(_bufferPointLayer);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return;
            }
        }