/// <summary> /// Private helper method: Checks script editability /// </summary> private static void _ScriptReplace(Form owner, AlgoBase find, AlgoBase replace) { if (find == null || find == replace) { // Nothing removed or item reinserted return; } if (find.Script == null) { FrmMsgBox.ShowInfo(owner, "Unavailable", "This algorithm is stored in binary format and cannot be viewed or modified."); return; } if (find.Script.FileName == null) { FrmMsgBox.ShowInfo(owner, "Unavailable", "This script is inbuilt. Make a copy if you wish to modify it."); return; } if (replace == null) // Direct delete { if (FrmMsgBox.ShowYesNo(owner, "Delete script file from disk?", find.Script.FileName, Resources.MsgWarning)) { File.Delete(find.Script.FileName); Algo.Instance.Rebuild(); } } }
internal static void Show(AlgoBase algo, TextBox paramBox, Core core, bool readOnly) { string newText = Show(paramBox.FindForm(), core, algo.Parameters, paramBox.Text, readOnly); if (newText != null) { paramBox.Text = newText; } }
void CheckAndChange() { AlgoBase trend = (AlgoBase)this._ecbMethod.SelectedItem; bool paramsVisible = trend != null && trend.Parameters.HasCustomisableParams; this._lblParams.Visible = paramsVisible; this._txtParameters.Visible = paramsVisible; this._btnEditParameters.Visible = paramsVisible; this._lblParams.Text = paramsVisible ? trend.Parameters.ParamNames() : "Parameters"; bool usingTrend = trend is TrendBase; bool correctorVisible = usingTrend; this._lblCorrector.Visible = correctorVisible; this.tableLayoutPanel3.Visible = correctorVisible; this._lstTypes.Visible = correctorVisible && this._radType.Checked; this._btnEditTypes.Visible = correctorVisible; this._btnBatchInfo2.Visible = correctorVisible; bool filterVisible = correctorVisible && this._radBatch.Checked; this._lblSepFilter.Visible = filterVisible; this._lblAVec.Visible = filterVisible; this._ecbFilter.Visible = filterVisible; bool operatorVisible = correctorVisible && ((this._radType.Checked && this._ecbTypes.HasSelection) || this._radBatch.Checked); this._lblCorrector2.Visible = operatorVisible; this.tableLayoutPanel4.Visible = operatorVisible; bool readyToGo = (usingTrend && operatorVisible && (this._radDivide.Checked || this._radSubtract.Checked)) || (!usingTrend); ArgsCorrection sel = this.GetSelection(); this._txtName.Watermark = sel != null ? sel.DefaultDisplayName : Resx.Texts.default_name; bool valid = sel != null; this._tlpPreview.Visible = valid; this._btnOk.Enabled = valid; this._flpGroupButtons.Visible = (!usingTrend || this._radType.Checked); this._flpBatchButtons.Visible = (usingTrend && this._radBatch.Checked); if (valid) { this.GeneratePreview(sel); } }
private static string ParamsToString(AlgoBase algorithm, object[] parameters, bool reversable, Core core) { if (parameters == null) { return(string.Empty); } var fieldsAsStrings = parameters.Select(z => ParamToString(z)); if (reversable || algorithm == null) { return(AlgoParameterTypes.ExternalConvertor.WriteFields(fieldsAsStrings)); } else { return(string.Join(", ", algorithm.Parameters.Zip(fieldsAsStrings).Select(z => z.Item1.Name + " = " + AlgoParameterTypes.ExternalConvertor.WriteField(z.Item2)))); } }
private void _btnEditParameters_Click(object sender, EventArgs e) { AlgoBase trend = (AlgoBase)this._ecbMethod.SelectedItem; FrmEditParameters.Show(trend, this._txtParameters, this._core, this._readOnly); }
private ArgsCorrection GetSelection() { this._checker.Clear(); IMatrixProvider source = this._ecbSource.SelectedItem; this._checker.Check(this._ecbSource.ComboBox, source != null, "Select a source"); // Algo AlgoBase algo = this._ecbMethod.SelectedItem; // Params object[] parameters; if (algo != null) { string error; parameters = algo.Parameters.TryStringToParams(this._core, this._txtParameters.Text, out error); this._checker.Check(this._txtParameters, parameters != null, error ?? "error"); } else { parameters = null; this._checker.Check(this._ecbMethod.ComboBox, false, "Select a correction method"); } if (algo is TrendBase) { // Method ECorrectionMethod met; if (this._radSubtract.Checked) { met = ECorrectionMethod.Subtract; } else if (this._radDivide.Checked) { met = ECorrectionMethod.Divide; } else { this._checker.Check(this._radSubtract, false, "Select a method"); this._checker.Check(this._radDivide, false, "Select a method"); met = default(ECorrectionMethod); } // Mode ECorrectionMode mode; GroupInfo controlGroup; ObsFilter filter; if (this._radBatch.Checked) { mode = ECorrectionMode.Batch; controlGroup = null; this._checker.Check(this._ecbFilter.ComboBox, this._ecbFilter.HasSelection, "Select a filter"); filter = this._ecbFilter.SelectedItem; } else if (this._radType.Checked) { mode = ECorrectionMode.Control; controlGroup = this._ecbTypes.SelectedItem; filter = null; } else { this._checker.Check(this._radBatch, false, "Select a mode"); this._checker.Check(this._radType, false, "Select a mode"); controlGroup = default(GroupInfo); filter = default(ObsFilter); mode = default(ECorrectionMode); } if (this._checker.HasErrors) { return(null); } ArgsCorrection args = new ArgsCorrection(((TrendBase)algo).Id, source, parameters, mode, met, controlGroup, filter) { OverrideDisplayName = this._txtName.Text, Comment = this._comments }; return(args); } else if (algo is CorrectionBase) { if (this._checker.HasErrors) { return(null); } ArgsCorrection args = new ArgsCorrection(((CorrectionBase)algo).Id, source, parameters, ECorrectionMode.None, ECorrectionMethod.None, null, null) { OverrideDisplayName = this._txtName.Text, Comment = this._comments }; return(args); } else { return(null); } }
/// <summary> /// Converts the specified customisable parameters [parameters] to a human readable string. /// </summary> public static string ParamsToHumanReadableString(object[] parameters, AlgoBase algorithm) { return(ParamsToString(algorithm, parameters, false, null)); }