コード例 #1
0
        /// <summary>
        /// Happens if the tool is activated.
        /// </summary>
        /// <param name="active"></param>
        /// <returns></returns>
        protected override Task OnToolActivateAsync(bool active)
        {
            // get the first selected raster layer
            var selectedRasterLayer = ActiveMapView.GetSelectedLayers().OfType <BasicRasterLayer>().FirstOrDefault();

            QueuedTask.Run(() =>
            {
                // get the raster from layer
                _selectedRaster = selectedRasterLayer?.GetRaster();


                if (selectedRasterLayer?.GetColorizer() is CIMRasterRGBColorizer)
                {
                    // if the rgb renderer is used get the index of the band used to render the reb color component
                    var rgbColorizer = selectedRasterLayer?.GetColorizer() as CIMRasterRGBColorizer;
                    _bandindex       = rgbColorizer.RedBandIndex;
                }
                else if (selectedRasterLayer?.GetColorizer() is CIMRasterStretchColorizer)
                {
                    // if the stretch renderer is used get the selected band index
                    var stretchColorizer = selectedRasterLayer?.GetColorizer() as CIMRasterStretchColorizer;
                    _bandindex           = stretchColorizer.BandIndex;
                }
            });


            RasterValuesPaneViewModel.Show();

            return(base.OnToolActivateAsync(active));
        }
コード例 #2
0
        /// <summary>
        /// Happens if the tool is activated.
        /// </summary>
        /// <param name="active"></param>
        /// <returns></returns>
        protected async override Task OnToolActivateAsync(bool active)
        {
            // get the first selected raster layer
            var selectedRasterLayer = ActiveMapView.GetSelectedLayers().OfType <BasicRasterLayer>().FirstOrDefault();

            _bandindex = await QueuedTask.Run(() =>
            {
                // get the raster from layer
                _selectedRaster = selectedRasterLayer?.GetRaster();

                var colorizer = selectedRasterLayer?.GetColorizer();
                var str       = colorizer.ToJson();

                if (selectedRasterLayer?.GetColorizer() is CIMRasterRGBColorizer)
                {
                    // if the rgb renderer is used get the index of the band used to render the reb color component
                    var rgbColorizer = selectedRasterLayer?.GetColorizer() as CIMRasterRGBColorizer;
                    return(rgbColorizer.RedBandIndex);
                }
                else if (selectedRasterLayer?.GetColorizer() is CIMRasterStretchColorizer)
                {
                    // if the stretch renderer is used get the selected band index
                    var stretchColorizer = selectedRasterLayer?.GetColorizer() as CIMRasterStretchColorizer;
                    return(stretchColorizer.BandIndex);
                }
                return(-1);
            });

            if (_bandindex > -1)
            {
                RasterValuesPaneViewModel.Show();
            }
            else
            {
                MessageBox.Show("For pixel insp. sample, please use either a stretch or RGB colorizer",
                                "Pixel Inspector");
            }
        }