コード例 #1
0
        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);
        }
コード例 #2
0
        internal FrmEditConfigurationCorrection(Core core, ArgsCorrection def, bool readOnly, Peak previewPeak)
        {
            this.InitializeComponent();
            UiControls.SetIcon(this);

            this._lblPreviewTitle.BackColor   = UiControls.PreviewBackColour;
            this._lblPreviewTitle.ForeColor   = UiControls.PreviewForeColour;
            this._flpPreviewButtons.BackColor = UiControls.PreviewBackColour;
            this._flpPreviewButtons.ForeColor = UiControls.PreviewForeColour;

            this._core         = core;
            this._readOnly     = readOnly;
            this._selectedPeak = previewPeak;

            // Charts
            this._chartOrig    = new ChartHelperForPeaks(null, this._core, this.panel1);
            this._chartChanged = new ChartHelperForPeaks(null, this._core, this.panel2);

            // Choicelists
            this._ecbFilter = DataSet.ForObsFilter(core).CreateComboBox(this._lstFilter, this._btnFilter, EditableComboBox.EFlags.IncludeAll);
            this._ecbMethod = DataSet.ForTrendAndCorrectionAlgorithms(core).CreateComboBox(this._lstMethod, this._btnNewStatistic, EditableComboBox.EFlags.None);
            this._ecbTypes  = DataSet.ForGroups(this._core).CreateComboBox(this._lstTypes, this._btnEditTypes, EditableComboBox.EFlags.None);
            this._ecbSource = DataSet.ForMatrixProviders(this._core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.None);

            // Buttons
            this.GenerateTypeButtons();

            // Default
            if (def != null)
            {
                this._txtName.Text           = def.OverrideDisplayName;
                this._txtParameters.Text     = AlgoParameterCollection.ParamsToReversableString(def.Parameters, core);
                this._ecbMethod.SelectedItem = def.GetAlgorithmOrNull();
                this._comments = def.Comment;

                if (def.IsUsingTrend)
                {
                    this._radBatch.Checked       = def.Mode == ECorrectionMode.Batch;
                    this._radType.Checked        = def.Mode == ECorrectionMode.Control;
                    this._radDivide.Checked      = def.Method == ECorrectionMethod.Divide;
                    this._radSubtract.Checked    = def.Method == ECorrectionMethod.Subtract;
                    this._ecbTypes.SelectedItem  = def.ControlGroup;
                    this._ecbFilter.SelectedItem = def.Constraint;
                }
            }

            this.CheckAndChange();

            if (readOnly)
            {
                UiControls.MakeReadOnly(this, this._tlpPreview);
            }
        }
コード例 #3
0
        internal static string Show(Form owner, Core core, AlgoParameterCollection algo, string defaults, bool readOnly)
        {
            using (FrmEditParameters frm = new FrmEditParameters(core, algo, defaults, readOnly))
            {
                if (frm.ShowDialog(owner) == DialogResult.OK)
                {
                    return(frm._result);
                }
            }

            return(null);
        }
コード例 #4
0
        /// <summary>
        /// CONSTRUCTOR
        /// Remembers the data specified by <paramref name="source"/>.
        /// </summary>
        public SourceTracker(ArgsBase source)
        {
            var prov = source.SourceProvider?.Provide;

            this._sourceMatrix = prov != null ? new WeakReference(prov) : null;

            AlgoParameterCollection para = source.GetAlgorithmOrThrow().Parameters;

            this._parameters = new WeakReference[para.Count][];

            for (int n = 0; n < para.Count; ++n)
            {
                this._parameters[n] = para[n].Type.TrackChanges(source.Parameters[n]);
            }
        }
コード例 #5
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;
        }
コード例 #6
0
        void button_Click(object sender, EventArgs e)
        {
            int     index   = (int)((Button)sender).Tag;
            TextBox textBox = this._textBoxes[index];
            var     param   = this._parameters[index];

            object value = param.Type.FromString(new FromStringArgs(this._core, textBox.Text));   // error ignored

            value = param.Type.Browse(this, this._core, value);

            if (value == null)
            {
                return;
            }

            textBox.Text = AlgoParameterCollection.ParamToString(value);
        }
コード例 #7
0
        internal FrmEditConfigurationTrend(Core core, Peak previewPeak, ArgsTrend def, bool readOnly)
            : this()
        {
            this._core        = core;
            this._previewPeak = previewPeak;

            this._ecbMethod = DataSet.ForTrendAlgorithms(core).CreateComboBox(this._lstMethod, this._btnNewStatistic, EditableComboBox.EFlags.None);
            this._ecbSource = DataSet.ForMatrixProviders(core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.None);

            this._chart1 = new ChartHelperForPeaks(null, core, this.panel1);

            if (def != null)
            {
                this._txtName.Text           = def.OverrideDisplayName;
                this._ecbMethod.SelectedItem = (TrendBase)def.GetAlgorithmOrNull();
                this._comments               = def.Comment;
                this._txtParams.Text         = AlgoParameterCollection.ParamsToReversableString(def.Parameters, core);
                this._ecbSource.SelectedItem = def.SourceProvider;
            }

            this.CheckAndChange(null, null);

            this._readOnly = readOnly;

            if (readOnly)
            {
                UiControls.MakeReadOnly(this, this._tlpPreview);

                this._btnComment.Enabled = true;

                this.ctlTitleBar1.Text = "View Trend";
            }
            else if (def != null)
            {
                this.ctlTitleBar1.Text = "Edit Trend";
            }
            else
            {
                this.ctlTitleBar1.Text = "New Trend";
            }

            // UiControls.CompensateForVisualStyles(this);
        }
コード例 #8
0
ファイル: FrmActEvaluate.cs プロジェクト: mjr129/metaboclust
        /// <summary>
        /// Actual test running
        /// </summary>
        private static ClusterEvaluationPointer RunTest(Core core, ClusterEvaluationPointer origPointer, ClusterEvaluationConfiguration test, ProgressReporter proggy, bool paranoid, int index, int of)
        {
            UiControls.Assert(core.FileNames.Session != null, "Didn't expect the session filename to be null for cluster evaluation.");

            List <ClusterEvaluationParameterResult> results = new List <ClusterEvaluationParameterResult>();

            // Iterate over parameters
            for (int valueIndex = 0; valueIndex < test.ParameterValues.Length; valueIndex++)
            {
                object value = test.ParameterValues[valueIndex];

                List <ResultClusterer> repetitions = new List <ResultClusterer>();

                // Iterate over repetitions
                for (int repetition = 0; repetition < test.NumberOfRepeats; repetition++)
                {
                    proggy.Enter("Test " + index + "/" + of + ", parameter " + valueIndex + "/" + test.ParameterValues.Length + ", repetition " + repetition + "/" + test.NumberOfRepeats);

                    // Create config
                    string   newName          = AlgoParameterCollection.ParamToString(value) + " " + StringHelper.Circle(repetition + 1);
                    object[] copyOfParameters = test.ClustererConfiguration.Parameters.ToArray();
                    copyOfParameters[test.ParameterIndex] = value;
                    ArgsClusterer copyOfArgs = new ArgsClusterer(
                        test.ClustererConfiguration.Id,
                        test.ClustererConfiguration.SourceProvider,
                        test.ClustererConfiguration.PeakFilter,
                        test.ClustererConfiguration.Distance,
                        test.ClustererConfiguration.ObsFilter,
                        test.ClustererConfiguration.SplitGroups,
                        test.ClustererConfiguration.Statistics,
                        copyOfParameters,
                        test.ClustererConfiguration.OverrideShortName)
                    {
                        OverrideDisplayName = newName,
                        Comment             = test.ClustererConfiguration.Comment
                    };
                    var copyOfConfig = new ConfigurationClusterer()
                    {
                        Args = copyOfArgs
                    };

                    // Try load previus result
                    ResultClusterer result = null;

                    if (paranoid)
                    {
                        result = TryLoadIntermediateResult(core, test.Guid, valueIndex, repetition, proggy);
                    }

                    if (result == null)
                    {
                        // DO CLUSTERING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                        proggy.Enter("Clustering");
                        result = copyOfConfig.Cluster(core, 0, proggy);
                        proggy.Leave();

                        if (paranoid)
                        {
                            SaveIntermediateResult(core, test.Guid, valueIndex, repetition, result, proggy);
                        }
                    }

                    // Add result
                    repetitions.Add(result);

                    string name = AlgoParameterCollection.ParamToString(value);

                    results.Add(new ClusterEvaluationParameterResult(name, test, valueIndex, repetitions));

                    proggy.Leave();
                }
            }

            ClusterEvaluationResults final = new ClusterEvaluationResults(core, test, results);

            string folder      = UiControls.GetOrCreateFixedFolder(UiControls.EInitialFolder.Evaluations);
            string sessionName = Path.GetFileNameWithoutExtension(core.FileNames.Session);
            string fileName    = core.Options.ClusteringEvaluationResultsFileName;

            fileName = fileName.Replace("{SESSION}", sessionName);
            fileName = fileName.Replace("{RESULTS}", folder + "\\");
            fileName = UiControls.GetNewFile(fileName);

            return(SaveResults(core, fileName, origPointer, final, proggy));
        }
コード例 #9
0
        private FrmEditConfigurationCluster(Core core, ArgsClusterer def, bool readOnly, bool hideOptimise)
            : this()
        {
            this._core          = core;
            this._ecbPeakFilter = DataSet.ForPeakFilter(core).CreateComboBox(this._lstPeakFilter, this._btnPeakFilter, EditableComboBox.EFlags.IncludeAll);
            this._ecbObsFilter  = DataSet.ForObsFilter(core).CreateComboBox(this._lstObsFilter, this._btnObsFilter, EditableComboBox.EFlags.IncludeAll);
            this._ecbMethod     = DataSet.ForClustererAlgorithms(core).CreateComboBox(this._lstMethod, this._btnNewStatistic, EditableComboBox.EFlags.CreateSelection);
            this._ecbMeasure    = DataSet.ForMetricAlgorithms(core).CreateComboBox(this._lstMeasure, this._btnNewDistance, EditableComboBox.EFlags.IncludeNone);
            this._ecbSource     = DataSet.ForMatrixProviders(core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.None);
            this._cbStatistics  = DataSet.ForFlagsEnum <EClustererStatistics>(this._core, "Cluster Statistics").CreateConditionBox(this._txtStatistics, this._btnSetStatistics);
            this._readOnly      = readOnly;

            if (def != null)
            {
                // Name
                this._txtName.Text      = def.OverrideDisplayName;
                this._txtShortName.Text = def.OverrideShortName;

                // Comment
                this._comment = def.Comment;

                // Method
                this._ecbMethod.SelectedItem = (ClustererBase)def.GetAlgorithmOrNull();

                // Params
                this._txtParams.Text = AlgoParameterCollection.ParamsToReversableString(def.Parameters, core);

                // PeakFilter
                this._ecbPeakFilter.SelectedItem = def.PeakFilter;

                // Distance
                this._ecbMeasure.SelectedItem = def.Distance != null ? (MetricBase)def.Distance.Args.GetAlgorithmOrNull() : null;

                // Distance params
                this._txtMeasureParams.Text = StringHelper.ArrayToString(def.Distance?.Args.Parameters);

                // Suppress distance
                this._cbStatistics.SelectedItems = EnumHelper.SplitEnum <EClustererStatistics>(def.Statistics);

                // Input vector
                this._ecbSource.SelectedItem = def.SourceProvider;

                // ObsFilter
                this._ecbObsFilter.SelectedItem = def.ObsFilter;

                // Seperate groups
                this._chkSepGroups.Checked = def.SplitGroups;
            }

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

                this._btnParameterOptimiser.Visible = false;
                this._btnComment.Enabled            = true;
                this.ctlTitleBar1.Text = "View Clustering Algorithm";
            }
            else if (def != null)
            {
                this.ctlTitleBar1.Text = "Edit Clustering Algorithm";
            }
            else
            {
                this.ctlTitleBar1.Text = "New Clustering Algorithm";
            }

            this.CheckAndChange(null, null);

            // UiControls.CompensateForVisualStyles(this);

            if (hideOptimise)
            {
                this._btnParameterOptimiser.Visible = false;
                this._btnOk.Text = "Continue";
            }
        }
コード例 #10
0
        private FrmEditParameters(Core core, AlgoParameterCollection algo, string defaults, bool readOnly)
            : this()
        {
            this._core             = core;
            this._parameters       = algo;
            this.ctlTitleBar1.Text = readOnly ? "View parameters" : "Edit Parameters";

            string[] elements = AlgoParameterTypes.ExternalConvertor.ReadFields(defaults);

            if (algo.HasCustomisableParams)
            {
                for (int index = 0; index < algo.Count; index++)
                {
                    var param = algo[index];
                    int row   = index + 1;

                    this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize, 0f));

                    Label label = new Label()
                    {
                        Text     = param.Name,
                        AutoSize = true,
                        Visible  = true,
                        Margin   = new Padding(8, 8, 8, 8),
                    };
                    this.tableLayoutPanel1.Controls.Add(label, 0, row);

                    Label label2 = new Label()
                    {
                        Text     = param.Type.ToString(),
                        AutoSize = true,
                        Visible  = true,
                        Margin   = new Padding(8, 8, 8, 8),
                    };
                    this.tableLayoutPanel1.Controls.Add(label2, 1, row);

                    TextBox textBox = new TextBox()
                    {
                        Dock     = DockStyle.Top,
                        Visible  = true,
                        Margin   = new Padding(8, 8, 8, 8),
                        Text     = elements.Length > index ? elements[index] : "",
                        ReadOnly = readOnly,
                        Tag      = index,
                    };
                    textBox.TextChanged += this.TextBox_TextChanged;
                    this.tableLayoutPanel1.Controls.Add(textBox, 2, row);
                    this._textBoxes.Add(textBox);

                    CtlButton button = new CtlButton()
                    {
                        Image          = Resources.MnuEnlargeList,
                        Visible        = true,
                        UseDefaultSize = true,
                        Margin         = new Padding(8, 8, 8, 8),
                        Tag            = index,
                        Enabled        = !readOnly,
                    };
                    button.Click += this.button_Click;
                    this.tableLayoutPanel1.Controls.Add(button, 3, row);

                    this.TextBox_TextChanged(textBox, EventArgs.Empty);

                    this.toolTip1.SetToolTip(label, param.Description);
                    this.toolTip1.SetToolTip(label2, param.Description);
                    this.toolTip1.SetToolTip(textBox, param.Description);
                    this.toolTip1.SetToolTip(button, param.Description);
                }
            }

            if (readOnly)
            {
                this._btnOk.Visible  = false;
                this._btnCancel.Text = "Close";
            }

            ctlContextHelp1.Bind(this, ctlTitleBar1, toolTip1, CtlContextHelp.EFlags.HelpOnClick | CtlContextHelp.EFlags.HelpOnFocus);
        }