예제 #1
0
        /// <summary>
        /// Shows the form.
        /// </summary>
        /// <param name="autoSave">Controls whether to apply to core.DefaultStatistics</param>
        internal static PeakFilter.Condition Show(Form owner, Core core, PeakFilter.Condition defaults, bool readOnly)
        {
            using (FrmEditPeakFilterCondition frm = new FrmEditPeakFilterCondition(owner, core, defaults, readOnly))
            {
                if (UiControls.ShowWithDim(owner, frm) == DialogResult.OK)
                {
                    string err;
                    var    r = frm.GetSelection(out err);
                    UiControls.Assert(r != null, err);

                    return(r);
                }

                return(null);
            }
        }
예제 #2
0
 private void UpdatePreview(PeakFilter.Condition r)
 {
     if (r != null)
     {
         int passed = this._core.Peaks.Count(r.Preview);
         int failed = this._core.Peaks.Count - passed;
         this._lblSigPeaks.Text        = "True: " + passed;
         this._lblInsigPeaks.Text      = "False: " + failed;
         this._lblSigPeaks.ForeColor   = (failed < passed) ? Color.Blue : this.ForeColor;
         this._lblInsigPeaks.ForeColor = (failed > passed) ? Color.Blue : this.ForeColor;
         this._lblSigPeaks.Visible     = true;
         this._lblInsigPeaks.Visible   = true;
     }
     else
     {
         this._lblSigPeaks.Visible   = false;
         this._lblInsigPeaks.Visible = false;
     }
 }
예제 #3
0
        /// <summary>
        /// CONSTRUCTOR
        /// </summary>
        private FrmEditPeakFilterCondition(Form owner, Core core, PeakFilter.Condition defaults, bool readOnly)
            : this()
        {
            this._core     = core;
            this._readOnly = readOnly;

            this.ctlTitleBar1.Text = readOnly ? "View Condition" : "Edit Condition";

            // Setup boxes
            this._cbPeaks    = DataSet.ForPeaks(core).CreateConditionBox(this._txtIsInSet, this._btnIsInSet);
            this._cbFlags    = DataSet.ForUserFlags(core).CreateConditionBox(this._txtIsFlaggedWith, this._btnIsFlaggedWith);
            this._cbClusters = DataSet.ForClusters(core).CreateConditionBox(this._txtIsInCluster, this._btnIsInCluster);

            this._lsoFlags  = EnumComboBox.Create(this._lstFlagComparator, Filter.ESetOperator.Any);
            this._lsoPats   = EnumComboBox.Create(this._lstClusterComparator, Filter.ELimitedSetOperator.Any);
            this._lsoPeaks  = EnumComboBox.Create(this._lstPeakComparator, Filter.EElementOperator.Is);
            this._lsoFilter = EnumComboBox.Create(this._lstFilterOp, Filter.EElementOperator.Is);
            this._lsoStats  = EnumComboBox.Create(this._lstStatisticComparator, Filter.EStatOperator.LessThan);
            this._lstIsStatistic.Items.AddRange(IVisualisableExtensions.WhereEnabled(core.Statistics).ToArray());

            this._ecbFilter = DataSet.ForPeakFilter(core).CreateComboBox(this._lstFilter, null, EditableComboBox.EFlags.IncludeAll);

            this._isInitialised = true;

            if (defaults == null)
            {
                this.checkBox1.Checked = false;
                this._radAnd.Checked   = true;
                this._txtComp_TextChanged(null, null);
            }
            else
            {
                // Not
                this.checkBox1.Checked = defaults.Negate;
                this._radAnd.Checked   = defaults.CombiningOperator == Filter.ELogicOperator.And;
                this._radOr.Checked    = defaults.CombiningOperator == Filter.ELogicOperator.Or;

                if (defaults is PeakFilter.ConditionCluster)
                {
                    PeakFilter.ConditionCluster def = (PeakFilter.ConditionCluster)defaults;

                    List <Cluster> strong;

                    if (!def.Clusters.TryGetStrong(out strong))
                    {
                        this.ShowWeakFailureMessage("clusters");
                    }

                    this._chkIsInCluster.Checked   = true;
                    this._lsoPats.SelectedItem     = def.ClustersOp;
                    this._cbClusters.SelectedItems = strong;
                }
                else if (defaults is PeakFilter.ConditionPeak)
                {
                    PeakFilter.ConditionPeak def = (PeakFilter.ConditionPeak)defaults;

                    List <Peak> strong;

                    if (!def.Peaks.TryGetStrong(out strong))
                    {
                        this.ShowWeakFailureMessage("peaks");
                    }

                    this._chkIsInSet.Checked    = true;
                    this._lsoPeaks.SelectedItem = def.PeaksOp;
                    this._cbPeaks.SelectedItems = strong;
                }
                else if (defaults is PeakFilter.ConditionFlags)
                {
                    PeakFilter.ConditionFlags def = (PeakFilter.ConditionFlags)defaults;

                    List <UserFlag> strong;

                    if (!def.Flags.TryGetStrong(out strong))
                    {
                        this.ShowWeakFailureMessage("peaks");
                    }

                    this._chkIsFlaggedWith.Checked = true;
                    this._lsoFlags.SelectedItem    = def.FlagsOp;
                    this._cbFlags.SelectedItems    = strong;
                }
                else if (defaults is PeakFilter.ConditionStatistic)
                {
                    PeakFilter.ConditionStatistic def = (PeakFilter.ConditionStatistic)defaults;

                    ConfigurationStatistic strong;

                    if (!def.Statistic.TryGetTarget(out strong))
                    {
                        this.ShowWeakFailureMessage("statistics");
                    }

                    ConfigurationStatistic stat = def.Statistic.GetTarget();

                    if (stat == null)
                    {
                        FrmMsgBox.ShowError(this, "The statistic specified when this condition was created has since been removed. Please select a different statistic.");
                    }

                    this._chkIsStatistic.Checked      = true;
                    this._lsoStats.SelectedItem       = def.StatisticOp;
                    this._lstIsStatistic.SelectedItem = stat;
                    this._txtStatisticValue.Text      = def.StatisticValue.ToString();
                }
                else if (defaults is PeakFilter.ConditionFilter)
                {
                    PeakFilter.ConditionFilter def = (PeakFilter.ConditionFilter)defaults;

                    this._radFilter.Checked      = true;
                    this._lsoFilter.SelectedItem = def.FilterOp ? Filter.EElementOperator.Is : Filter.EElementOperator.IsNot;
                    this._ecbFilter.SelectedItem = def.Filter;
                }
                else
                {
                    throw new SwitchException(defaults.GetType());
                }
            }

            if (readOnly)
            {
                UiControls.MakeReadOnly(this);
            }
        }