private bool canNavigateToLayer()
        {
            ICustomGraphicsLayer customGraphicsLayer = Layer as ICustomGraphicsLayer;

            if (customGraphicsLayer != null)
            {
                return(customGraphicsLayer.SupportsNavigateToServiceDetailsUrl());
            }
            return(false);
        }
        public override void Execute(object parameter)
        {
            FeatureLayer fl = Layer as FeatureLayer;

            if (fl != null)
            {
                navigateToUrl(Utility.CreateUriWithProxy(fl.ProxyUrl, fl.Url));
                return;
            }

            ArcGISDynamicMapServiceLayer dynLayer = Layer as ArcGISDynamicMapServiceLayer;

            if (dynLayer != null)
            {
                navigateToUrl(Utility.CreateUriWithProxy(dynLayer.ProxyURL, dynLayer.Url));
                return;
            }

            ArcGISImageServiceLayer imageLayer = Layer as ArcGISImageServiceLayer;

            if (imageLayer != null)
            {
                navigateToUrl(Utility.CreateUriWithProxy(imageLayer.ProxyURL, imageLayer.Url));
                return;
            }

            ArcGISTiledMapServiceLayer tiledLayer = Layer as ArcGISTiledMapServiceLayer;

            if (tiledLayer != null)
            {
                navigateToUrl(Utility.CreateUriWithProxy(tiledLayer.ProxyURL, tiledLayer.Url));
                return;
            }

            GeoRssLayer geoRssLayer = Layer as GeoRssLayer;

            if (geoRssLayer != null)
            {
                if (geoRssLayer.Source != null)
                {
                    navigateToUrl(geoRssLayer.Source.AbsoluteUri);
                }
                return;
            }

            WmsLayer wmsLayer = Layer as WmsLayer;

            if (wmsLayer != null)
            {
                string url = wmsLayer.Url;
                if (!string.IsNullOrEmpty(url))
                {
                    if (!url.Contains("?"))
                    {
                        url += "?";
                    }
                    else
                    {
                        url += "&";
                    }
                    if (url.IndexOf("request=GetCapabilities", StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        url += "request=GetCapabilities";
                    }
                    if (!string.IsNullOrEmpty(wmsLayer.Version) && url.IndexOf("version=", StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        url += "&version=" + wmsLayer.Version;
                    }
                    navigateToUrl(Utility.CreateUriWithProxy(wmsLayer.ProxyUrl, url));
                }
                return;
            }

            OpenStreetMapLayer osmLayer = Layer as OpenStreetMapLayer;

            if (osmLayer != null)
            {
                navigateToUrl("http://www.openstreetmap.org");
                return;
            }

            ESRI.ArcGIS.Client.Bing.TileLayer bingLayer = Layer as ESRI.ArcGIS.Client.Bing.TileLayer;
            if (bingLayer != null)
            {
                navigateToUrl("http://www.bing.com/maps/");
                return;
            }

            ICustomGraphicsLayer customGraphicsLayer = Layer as ICustomGraphicsLayer;

            if (customGraphicsLayer != null && customGraphicsLayer.SupportsNavigateToServiceDetailsUrl())
            {
                Uri uri = customGraphicsLayer.GetServiceDetailsUrl();
                if (uri != null)
                {
                    navigateToUrl(uri.AbsoluteUri);
                }
                return;
            }
        }
        private void RefreshLayer(Layer layer, EventHandler refreshCompletedHander, EventHandler <TaskFailedEventArgs> refreshFailedHandler)
        {
            _isRefreshing = true;
            FeatureLayer featureLayer = layer as FeatureLayer;

            if (featureLayer != null && !string.IsNullOrEmpty(featureLayer.Url))
            {
                // temporarly unhook the AttributeDisplay's layer while we refresh feature layer
                if (View.Instance != null && View.Instance.AttributeDisplay != null && View.Instance.AttributeDisplay.FeatureDataGrid != null)
                {
                    ToggleTableCommand.SetTableVisibility(Visibility.Collapsed);

                    // Set FeatureDataGrid layer to null so that we don't incur the overhead
                    // of all the UpdateItemSource calls as the AttributeTable Graphics layer is
                    // being set to null.
                    View.Instance.AttributeDisplay.FeatureDataGrid.GraphicsLayer = null;
                    // Set the FilterSource to null to prevent potential GraphicsLayer reference exceptions
                    View.Instance.AttributeDisplay.FeatureDataGrid.FilterSource = null;
                    // Now set the AttributeDisplay GraphicsLayer to null so that it
                    // unhooks all the bindings and events
                    View.Instance.AttributeDisplay.GraphicsLayer = null;

                    // Hook up to the UpdateCompleted/UpdateFailed events so that the layer
                    // can be reset to the SelectedLayer
                    featureLayer.UpdateCompleted -= OnFeatureLayerUpdateCompleted;
                    featureLayer.UpdateCompleted += OnFeatureLayerUpdateCompleted;
                    featureLayer.UpdateFailed    -= OnFeatureLayerUpdateFailed;
                    featureLayer.UpdateFailed    += OnFeatureLayerUpdateFailed;
                }

                if (refreshCompletedHander != null)
                {
                    featureLayer.UpdateCompleted -= refreshCompletedHander;
                    featureLayer.UpdateCompleted += refreshCompletedHander;
                }
                if (refreshFailedHandler != null)
                {
                    featureLayer.UpdateFailed -= refreshFailedHandler;
                    featureLayer.UpdateFailed += refreshFailedHandler;
                }
                featureLayer.Update();
                return;
            }

            ArcGISDynamicMapServiceLayer dynamicLayer = layer as ArcGISDynamicMapServiceLayer;

            if (dynamicLayer != null)
            {
                dynamicLayer.Refresh();
                if (refreshCompletedHander != null)
                {
                    refreshCompletedHander.Invoke(layer, EventArgs.Empty);
                }
                return;
            }

            ArcGISTiledMapServiceLayer tiledLayer = layer as ArcGISTiledMapServiceLayer;

            if (tiledLayer != null)
            {
                // Tiled layers do not support refreshing
                if (refreshCompletedHander != null)
                {
                    refreshCompletedHander.Invoke(layer, EventArgs.Empty);
                }
                return;
            }

            ArcGISImageServiceLayer imageServiceLayer = layer as ArcGISImageServiceLayer;

            if (imageServiceLayer != null)
            {
                imageServiceLayer.Refresh();
                if (refreshCompletedHander != null)
                {
                    refreshCompletedHander.Invoke(layer, EventArgs.Empty);
                }
                return;
            }

            ICustomGraphicsLayer customGraphicsLayer = layer as ICustomGraphicsLayer;

            if (customGraphicsLayer != null)
            {
                customGraphicsLayer.ForceRefresh(refreshCompletedHander, refreshFailedHandler);
                return;
            }


            HeatMapLayerBase heatMapLayer = layer as HeatMapLayerBase;

            if (heatMapLayer != null)
            {
                heatMapLayer.Update();
                if (refreshCompletedHander != null)
                {
                    refreshCompletedHander.Invoke(layer, EventArgs.Empty);
                }
                return;
            }

            GeoRssLayer geoRssLayer = Layer as GeoRssLayer;

            if (geoRssLayer != null)
            {
                geoRssLayer.Update();
                return;
            }

            WmsLayer wmsLayer = Layer as WmsLayer;

            if (wmsLayer != null)
            {
                wmsLayer.Refresh();
                return;
            }

            GraphicsLayer graphicsLayer = layer as GraphicsLayer;

            if (graphicsLayer != null)
            {
                graphicsLayer.Refresh();
                if (refreshCompletedHander != null)
                {
                    refreshCompletedHander.Invoke(layer, EventArgs.Empty);
                }
                return;
            }
        }