Ejemplo n.º 1
0
        private void InputStretchParamsButton_Click(object sender, EventArgs e)
        {
            // Fire the OnStretchInputsEntered event and provide the stretch parameter input.
            if (OnStretchInputsEntered != null)
            {
                // Create a new StretchParametersEventArgs to contain the input values.
                StretchParameters inputStretchParams = null;

                // Create the right type of stretch parameters defined by the user.
                switch (_stretchParamsType)
                {
                // - Minimum and maximum RGB values.
                case "Min Max RGB":
                    // Get the models that contains the min/max red, green, and blue picker choices.
                    RgbValuePickerModel minRgbModel = _minRgbPicker.Model as RgbValuePickerModel;
                    RgbValuePickerModel maxRgbModel = _maxRgbPicker.Model as RgbValuePickerModel;

                    // Read min/max RGB values that were chosen.
                    double[] minValues = { minRgbModel.SelectedRed, minRgbModel.SelectedGreen, minRgbModel.SelectedBlue };
                    double[] maxValues = { maxRgbModel.SelectedRed, maxRgbModel.SelectedGreen, maxRgbModel.SelectedBlue };

                    // Create a new MinMaxStretchParameters object with the values.
                    inputStretchParams = new MinMaxStretchParameters(minValues, maxValues);

                    break;

                // - Minimum and maximum percent clip values.
                case "% Clip":
                    // Read min/max percent values that were chosen.
                    double minPercent = _minPercentSlider.Value;
                    double maxPercent = _maxPercentSlider.Value;
                    inputStretchParams = new PercentClipStretchParameters(minPercent, maxPercent);

                    break;

                // Standard deviation factor.
                case "Std Dev":
                    // Get the model that contains the standard deviation factor choices.
                    StdDevFactorPickerModel factorModel = _stdDevPicker.Model as StdDevFactorPickerModel;

                    // Get the selected factor.
                    double standardDevFactor = factorModel.SelectedFactor;
                    inputStretchParams = new StandardDeviationStretchParameters(standardDevFactor);

                    break;
                }

                // Create a new StretchParametersEventArgs and provide the stretch parameters.
                StretchParametersEventArgs inputParamsEventArgs = new StretchParametersEventArgs(inputStretchParams);

                // Raise the event with the custom arguments.
                OnStretchInputsEntered(sender, inputParamsEventArgs);
            }
        }
Ejemplo n.º 2
0
        private void UpdateRenderer(object sender, StretchParametersEventArgs e)
        {
            // Create an array to specify the raster bands (red, green, blue).
            int[] bands = { 0, 1, 2 };

            // Create the RgbRenderer with the stretch parameters passed in, then apply it to the raster layer.
            RgbRenderer rasterRenderer = new RgbRenderer(e.StretchParams, bands, null, true);

            _rasterLayer.Renderer = rasterRenderer;

            // Remove the parameter input UI.
            _updateRendererUI.Hide();
            _updateRendererUI = null;
        }