Beispiel #1
0
        private void TextBox_TextChanged(object sender, EventArgs e)
        {
            TextBox textBox = (TextBox)sender;
            int     index   = (int)textBox.Tag;
            var     param   = this._parameters[index];

            var    args  = new FromStringArgs(this._core, textBox.Text);
            object value = param.Type.FromString(args);

            this.ctlError1.Check(textBox, value != null, args.Error);
            this._btnOk.Enabled = !this.ctlError1.HasErrors;
        }
Beispiel #2
0
        private void _btnOk_Click(object sender, EventArgs e)
        {
            object[] results = new object[this._parameters.Count];

            for (int index = 0; index < this._parameters.Count; index++)
            {
                var param = this._parameters[index];
                var args  = new FromStringArgs(this._core, this._textBoxes[index].Text);

                results[index] = param.Type.FromString(args);

                Debug.Assert(results[index] != null, $"The {{{param.Name}}} parameter is invalid (the OK button should have been disabled).\r\n" + args.Error);
            }

            this._result      = AlgoParameterCollection.ParamsToReversableString(results, this._core);
            this.DialogResult = DialogResult.OK;
        }
Beispiel #3
0
        private ClusterEvaluationPointer GetSelection()
        {
            this._checker.Clear();

            this._checker.Check(this._txtAlgorithm, this.SelectedAlgorithm != null, "An algorithm is required");

            int p = this._lstParameters.SelectedIndex;

            this._checker.Check(this._lstParameters, p == -1, "Requires parameter");

            AlgoParameter pa = (AlgoParameter)this._lstParameters.SelectedItem;

            string[] lines      = this._txtValues.Text.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            object[] opts       = new object[lines.Length];
            bool     inputError = false;

            for (int n = 0; n < lines.Length; ++n)
            {
                var args = new FromStringArgs(this._core, lines[n]);
                opts[n] = pa.Type.FromString(args);

                if (opts[n] == null && !inputError)
                {
                    this._checker.Check(this._txtValues, false, args.Error ?? "error");
                    inputError = true;
                }
            }

            int num = (int)this._numNumTimes.Value;

            this._txtNumberOfValues.Text = opts.Length.ToString();

            this._checker.Check(this._txtValues, opts.Length != 0 || inputError, "Enter a valid list of parameters");
            this._checker.Check(this._numNumTimes, num > 0 && num < 100, "Repeat count is invalid");

            if (this._checker.HasErrors)
            {
                return(null);
            }

            return(new ClusterEvaluationPointer(new ClusterEvaluationConfiguration(this.SelectedAlgorithm, p, opts, num)));
        }