/// <summary>
        /// Event handler for layer selection change.
        /// </summary>
        /// <param name="mapViewArgs">An instance of the MapViewEventArgs.</param>
        private async void SelectedLayersChanged(ArcGIS.Desktop.Mapping.Events.MapViewEventArgs mapViewArgs)
        {
            // Check if there is an active map view.
            if (MapView.Active != null)
            {
                // Gets the selected layers from the current Map.
                IReadOnlyList <Layer> selectedLayers = MapView.Active.GetSelectedLayers();

                // The combo box will update only if one layer is selected.
                if (selectedLayers.Count == 1)
                {
                    // Gets the selected layer.
                    Layer firstSelectedLayer = selectedLayers.First();

                    // Make sure the selected layer is an image service layer.
                    if (firstSelectedLayer != null && firstSelectedLayer is ImageServiceLayer)
                    {
                        // Initiates the combox box selected item.
                        //InitializeComboBox();

                        await QueuedTask.Run(() =>
                        {
                            // Get and store the rendering rule of the selected image service layer.
                            renderingRule_default = (firstSelectedLayer as ImageServiceLayer).GetRenderingRule();
                        });
                    }
                }
            }
            else
            {
                MessageBox.Show("There is no active map.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        /// <summary>
        /// Event handler for layer selection changes.
        /// </summary>
        private void SelectedLayersChanged(ArcGIS.Desktop.Mapping.Events.MapViewEventArgs mapViewArgs)
        {
            State state = (FrameworkApplication.Panes.ActivePane != null) ? FrameworkApplication.Panes.ActivePane.State : null;

            if (state != null)
            {
                IReadOnlyList <Layer> selectedLayers = mapViewArgs.MapView.GetSelectedLayers();
                if (selectedLayers.Count == 1)
                {
                    state.Activate("esri_custom_mutipleLayersNotSelectedState");
                }
                else
                {
                    state.Deactivate("esri_custom_mutipleLayersNotSelectedState");
                    return;
                }

                Layer firstSelectedLayer = selectedLayers.First();
                if (firstSelectedLayer != null)
                {
                    if (firstSelectedLayer is ImageServiceLayer && !(firstSelectedLayer is ImageMosaicSubLayer))
                    {
                        state.Activate("esri_custom_imageServiceLayerSelectedState");
                    }
                    else
                    {
                        state.Deactivate("esri_custom_imageServiceLayerSelectedState");
                    }
                }
                else
                {
                    state.Deactivate("esri_custom_imageServiceLayerSelectedState");
                }
            }
        }
        // when selection on the TOC changes, update the SketchLayer
        private void OnTOCSelectionChanged(ArcGIS.Desktop.Mapping.Events.MapViewEventArgs args)
        {
            if (args == null)
            {
                return;
            }

            SetSketchLayer();
        }
Exemple #4
0
 private void OnMapViewIntialized(ArcGIS.Desktop.Mapping.Events.MapViewEventArgs args)
 {
     if (_eventToken != null)
     {
         ArcGIS.Desktop.Mapping.Events.MapViewInitializedEvent.Unsubscribe(_eventToken);
         _eventToken = null;
     }
     GetActiveMapLayerGDBPathAsync();
 }
        /// <summary>
        /// Event handler for layer selection changes.
        /// </summary>
        private async void SelectedLayersChanged(ArcGIS.Desktop.Mapping.Events.MapViewEventArgs mapViewArgs)
        {
            // Clears the combo box items when layer selection changes.
            Clear();

            // Checks the state of the active pane.
            // Returns the active pane state if the active pane is not null, else returns null.
            State state = (FrameworkApplication.Panes.ActivePane != null) ? FrameworkApplication.Panes.ActivePane.State : null;

            if (state != null && mapViewArgs.MapView != null)
            {
                // Gets the selected layers from the current Map.
                IReadOnlyList <Layer> selectedLayers = mapViewArgs.MapView.GetSelectedLayers();

                // The combo box will update only if one layer is selected.
                if (selectedLayers.Count == 1)
                {
                    // Gets the selected layer.
                    Layer firstSelectedLayer = selectedLayers.First();

                    // The combo box will update only if a raster layer is selected.
                    if (firstSelectedLayer != null && (firstSelectedLayer is BasicRasterLayer || firstSelectedLayer is MosaicLayer))
                    {
                        // Gets the basic raster layer from the selected layer.
                        if (firstSelectedLayer is BasicRasterLayer)
                        {
                            basicRasterLayer = (BasicRasterLayer)firstSelectedLayer;
                        }
                        else if (firstSelectedLayer is MosaicLayer)
                        {
                            basicRasterLayer = ((MosaicLayer)firstSelectedLayer).GetImageLayer() as BasicRasterLayer;
                        }

                        // Initiates the combox box selected item.
                        SelectedIndex = -1;

                        // Updates the combo box with the corresponding colorizers for the selected layer.
                        await UpdateCombo(basicRasterLayer);

                        // Sets the combo box to display the first combo box item.
                        SelectedIndex = 0;
                    }
                }
            }
        }