private void _btnSelectDiffPeak_Click(object sender, EventArgs e) { var def = NamedItem <Peak> .Extract(this._lstDiffPeak.SelectedItem); var newPeak = DataSet.ForPeaks(this._core).ShowList(this, def); if (newPeak != null) { this._lstDiffPeak.SelectedItem = newPeak; } }
void wizard_OkClicked(object sender, EventArgs e) { // Check if (!this._wizard.RevalidateAll()) { FrmMsgBox.ShowError(this, "Not all options have been selected."); return; } int param1_numClusters = this._radStopN.Checked ? int.Parse(this._txtStopN.Text) : int.MinValue; double param2_distanceLimit = this._radStopD.Checked ? double.Parse(this._txtStopD.Text) : double.MinValue; Debug.Assert(this._ecbSeedPeak.HasSelection, "Expected a seed peak to be selected"); WeakReference <Peak> param3_seedPeak = new WeakReference <Peak>(this._ecbSeedPeak.SelectedItem); GroupInfo param4_seedGroup = NamedItem <GroupInfo> .Extract(this._lstGroups.SelectedItem); int param5_doKMeans = this._radFinishK.Checked ? 1 : 0; IMatrixProvider source = this._ecbSource.SelectedItem; object[] parameters = { param1_numClusters, param2_distanceLimit, param3_seedPeak, param4_seedGroup, param5_doKMeans }; string name = "DK"; // Create a constraint that only allows overlapping timepoints HashSet <int> overlappingPoints = new HashSet <int>(); var fil = this._ecbFilter.SelectedItem ?? ObsFilter.Empty; var passed = fil.Test(source.Provide.Columns.Select(z => z.Observation)).Passed; HashSet <GroupInfo> groups = new HashSet <GroupInfo>(passed.Select(z => z.Group)); bool needsExFilter = false; foreach (int ctp in this._core.Times) { bool trueInAny = false; bool falseInAny = false; foreach (GroupInfo g in groups) { if (passed.Any(z => z.Group == g && z.Time == ctp)) { trueInAny = true; } else { falseInAny = true; } } if (trueInAny && !falseInAny) // i.e. true in all TT { overlappingPoints.Add(ctp); } else if (trueInAny) // i.e. true in one but not all TF { needsExFilter = true; } //else if (falseInAny) // False in all (accptable) FT // else // No groups FF } ObsFilter trueFilter; if (needsExFilter) { List <ObsFilter.Condition> conditions = new List <ObsFilter.Condition> { new ObsFilter.ConditionFilter(Filter.ELogicOperator.And, false, this._ecbFilter.SelectedItem, true), new ObsFilter.ConditionTime(Filter.ELogicOperator.And, false, Filter.EElementOperator.Is, overlappingPoints) }; trueFilter = new ObsFilter(null, null, conditions); this._core.AddObsFilter(trueFilter); } else { trueFilter = this._ecbFilter.SelectedItem; } ArgsClusterer args = new ArgsClusterer( Algo.ID_DKMEANSPPWIZ, this._ecbSource.SelectedItem, this._ecbPeakFilter.SelectedItem, new ConfigurationMetric() { Args = new ArgsMetric(this._ecbDistance.SelectedItem.Id, this._ecbSource.SelectedItem, this._ecbDistance.SelectedItem.Parameters.StringToParams(this._core, this._txtDistanceParams.Text)) }, trueFilter, this._chkClusterIndividually.Checked, EClustererStatistics.None, parameters, "DK") { OverrideDisplayName = name, Comment = "Generated using wizard" }; ConfigurationClusterer config = new ConfigurationClusterer() { Args = args }; FrmWait.Show(this, "Clustering", null, z => this._core.AddClusterer(config, z)); this.DialogResult = DialogResult.OK; }