private void GeneratePreview(ArgsStatistic sel) { if (sel == null) { return; } if (this._previewPeak == null) { return; } this._lblPreview.Text = this._previewPeak.DisplayName + ": "; try { ConfigurationStatistic temp = new ConfigurationStatistic() { Args = sel }; double v = temp.Calculate(this._core, this._previewPeak); this._lblPreview2.Text = v.ToString(); this._lblPreview2.ForeColor = System.Drawing.Color.Gray; } catch (Exception ex) { this._lblPreview2.Text = ex.Message; this._lblPreview2.ForeColor = System.Drawing.Color.Red; } }
private FrmEditConfigurationStatistic(Core core, ArgsStatistic defaultSelection, Peak defaultPeak, bool readOnly) : this() { this._core = core; this._previewPeak = defaultPeak; this._ecbFilter1 = DataSet.ForObsFilter(core).CreateComboBox(this._lstFilter1, this._btnFilter1, EditableComboBox.EFlags.IncludeAll); this._ecbFilter2 = DataSet.ForObsFilter(core).CreateComboBox(this._lstFilter2, this._btnFilter2, EditableComboBox.EFlags.IncludeAll); this._ecbSource = DataSet.ForMatrixProviders(core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.None); this._ecbMeasure = DataSet.ForStatisticsAlgorithms(core).CreateComboBox(this._lstMethod, this._btnNewStatistic, EditableComboBox.EFlags.None); this._ecbDiffPeak = DataSet.ForPeaks(core).CreateComboBox(this._lstDiffPeak, this._btnSelectDiffPeak, EditableComboBox.EFlags.None); this._ecbDiffPeak.SelectedItem = defaultPeak; if (defaultSelection != null) { this._txtName.Text = defaultSelection.OverrideDisplayName; this.ctlTitleBar1.SubText = defaultSelection.AlgoName; this._comments = defaultSelection.Comment; this._ecbMeasure.SelectedItem = (StatisticBase)defaultSelection.GetAlgorithmOrNull(); this._txtParams.Text = AlgoParameterCollection.ParamsToReversableString(defaultSelection.Parameters, this._core); this._ecbSource.SelectedItem = defaultSelection.SourceProvider; this._radBCorTime.Checked = defaultSelection.VectorBSource == EAlgoInputBSource.Time; this._radBDiffPeak.Checked = defaultSelection.VectorBSource == EAlgoInputBSource.AltPeak; this._radSamePeak.Checked = defaultSelection.VectorBSource == EAlgoInputBSource.SamePeak; this._ecbFilter1.SelectedItem = defaultSelection.VectorAConstraint; this._ecbFilter2.SelectedItem = defaultSelection.VectorBConstraint; if (defaultSelection.VectorBPeak != null) { this._ecbDiffPeak.SelectedItem = defaultSelection.VectorBPeak; } } this.SetStatuses(); this._readOnly = readOnly; if (readOnly) { UiControls.MakeReadOnly(this, this._tlpPreivew); this._btnComment.Enabled = true; this.ctlTitleBar1.Text = "View Statistic"; } else if (defaultSelection != null) { this.ctlTitleBar1.Text = "Edit Statistic"; } else { this.ctlTitleBar1.Text = "New Statistic"; } // UiControls.CompensateForVisualStyles(this); }
public readonly ArgsStatistic Args; // configuration public InputStatistic(Core core, Peak a, Peak b, ArgsStatistic args) { this.Core = core; this.PeakA = a; this.PeakB = b; this.Args = args; }
internal static ArgsStatistic Show(Form owner, ArgsStatistic def, Core core, bool readOnly) { if (ShowCannotEditError(owner, def)) { return(null); } using (FrmEditConfigurationStatistic frm = new FrmEditConfigurationStatistic(core, def, FrmMain.SearchForSelectedPeak(owner), readOnly)) { if (UiControls.ShowWithDim(owner, frm) == DialogResult.OK) { return(frm.GetSelection()); } return(null); } }
private void Validate(object sender, EventArgs e) { bool previewSucceeded; try { ArgsStatistic sel = this.GetSelection(); this.GeneratePreview(sel); previewSucceeded = sel != null; this._txtName.Watermark = sel != null ? sel.DefaultDisplayName : Resx.Texts.default_name; } catch { previewSucceeded = false; } this._btnOk.Enabled = previewSucceeded; this._tlpPreivew.Visible = previewSucceeded; }
private ArgsStatistic GetSelection() { StatisticBase sel = this._ecbMeasure.SelectedItem; IMatrixProvider src; EAlgoInputBSource bsrc; ObsFilter filter1; ObsFilter filter2; Peak bpeak; string title; this._checker.Clear(); // Title / comments title = string.IsNullOrWhiteSpace(this._txtName.Text) ? null : this._txtName.Text; // Parameters object[] parameters; if (sel != null) { if (sel.Parameters.HasCustomisableParams) { string error; parameters = sel.Parameters.TryStringToParams(this._core, this._txtParams.Text, out error); this._checker.Check(this._txtParams, parameters != null, error ?? "error"); } else { parameters = null; } } else { parameters = null; this._checker.Check(this._ecbMeasure.ComboBox, false, "Select a method"); } // Obs source src = this._ecbSource.SelectedItem; this._checker.Check(this._ecbSource.ComboBox, src != null, "Select a source"); if (sel == null || !sel.SupportsInputFilters) { filter1 = null; filter2 = null; bsrc = EAlgoInputBSource.None; bpeak = null; } else { // Vector A filter1 = this._ecbFilter1.SelectedItem; this._checker.Check(this._ecbFilter1.ComboBox, this._ecbFilter1.HasSelection, "Select a filter"); // Vector B if (sel == null || !sel.IsMetric) { // If the stat isn't comparing anything there is nothing to set bsrc = EAlgoInputBSource.None; filter2 = null; bpeak = null; } else if (this._radBCorTime.Checked) { // Use time is checked then we are comparing against time - but use the same X points bsrc = EAlgoInputBSource.Time; filter2 = filter1; bpeak = null; } else if (this._radBDiffPeak.Checked) { // Use alt peak is checked then we are comparing against another peak - use the same X points bsrc = EAlgoInputBSource.AltPeak; bpeak = this._ecbDiffPeak.SelectedItem; this._checker.Check(this._lstDiffPeak, bpeak != null, "Select a peak"); filter2 = filter1; } else if (this._radSamePeak.Checked) { // Otherwise we are comparing against the same peak, get what we are comparing against bsrc = EAlgoInputBSource.SamePeak; bpeak = null; filter2 = this._ecbFilter2.SelectedItem; this._checker.Check(this._ecbFilter2.ComboBox, this._ecbFilter2.HasSelection, "Select a peak"); } else { // What are we comparing against? this._checker.Check(this._radBCorTime, false, "Select a comparison"); this._checker.Check(this._radBDiffPeak, false, "Select a comparison"); this._checker.Check(this._radSamePeak, false, "Select a comparison"); bsrc = default(EAlgoInputBSource); bpeak = default(Peak); filter2 = default(ObsFilter); } } if (this._checker.HasErrors) { return(null); } // Result ArgsStatistic args = new ArgsStatistic(sel.Id, src, filter1, bsrc, filter2, bpeak, parameters); args.OverrideDisplayName = title; args.Comment = this._comments; return(args); }