Пример #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);
            }
        }
        public override void LoadView()
        {
            View = new UIView()
            {
                BackgroundColor = UIColor.White
            };

            UIScrollView scrollView = new UIScrollView();

            scrollView.TranslatesAutoresizingMaskIntoConstraints = false;

            View.AddSubviews(scrollView);

            scrollView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active           = true;
            scrollView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active   = true;
            scrollView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
            scrollView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active     = true;

            UIStackView formContainer = new UIStackView();

            formContainer.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.Spacing = 8;
            formContainer.LayoutMarginsRelativeArrangement = true;
            formContainer.Alignment     = UIStackViewAlignment.Center;
            formContainer.LayoutMargins = new UIEdgeInsets(8, 8, 8, 8);
            formContainer.Axis          = UILayoutConstraintAxis.Vertical;

            // Add controls here.
            UILabel factorLabel = new UILabel();

            factorLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            factorLabel.Text = "Factor:";
            formContainer.AddArrangedSubview(factorLabel);

            UIPickerView picker = new UIPickerView();

            picker.TranslatesAutoresizingMaskIntoConstraints = false;
            _pickerModel = new StdDevFactorPickerModel();
            picker.Model = _pickerModel;
            picker.HeightAnchor.ConstraintEqualTo(90).Active = true;
            formContainer.AddArrangedSubview(picker);

            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Apply", UIBarButtonItemStyle.Plain, ApplyButton_Clicked);

            scrollView.AddSubview(formContainer);

            formContainer.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor).Active           = true;
            formContainer.LeadingAnchor.ConstraintEqualTo(scrollView.LeadingAnchor).Active   = true;
            formContainer.TrailingAnchor.ConstraintEqualTo(scrollView.TrailingAnchor).Active = true;
            formContainer.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor).Active     = true;
            formContainer.WidthAnchor.ConstraintEqualTo(scrollView.WidthAnchor).Active       = true;
        }