internal void SetData(Dictionary<string, int> v, string[] keys, int d) { Parameter[] p = new Parameter[keys.Length]; for (int i = 0; i < p.Length; i++){ p[i] = new IntParamWf(keys[i], v.ContainsKey(keys[i]) ? v[keys[i]] : d); } parameterPanel1.Init(new Parameters(p)); }
private void AddParameter(Parameter p, int i) { Label txt1 = new Label{Text = p.Name}; //ToolTipService.SetShowDuration(txt1, 400000); //if (!string.IsNullOrEmpty(p.Help)){ //txt1.ToolTip = StringUtils.ReturnAtWhitespace(p.Help); //} object o = p.CreateControl(); if (o is Control){ Control c = (Control)o; c.Dock = DockStyle.Fill; grid.Controls.Add(c, 1, i); } txt1.Dock = DockStyle.Fill; grid.Controls.Add(txt1, 0, i); }
private static Parameter GetRelationsParameter() { const int maxCols = 5; string[] values = new string[maxCols]; Parameters[] subParams = new Parameters[maxCols]; for (int i = 1; i <= maxCols; i++){ values[i - 1] = "" + i; Parameter[] px = new Parameter[i]; for (int j = 0; j < i; j++){ px[j] = new StringParam("Relation " + (j + 1)); } Parameters p = new Parameters(px); subParams[i - 1] = p; } return new SingleChoiceWithSubParams("Number of relations", 0){ Values = values, SubParams = subParams, ParamNameWidth = 120, TotalWidth = 800 }; }
private static Parameter GetColumnSelectionParameter(string[] selection) { const int maxCols = 5; string[] values = new string[maxCols]; Parameters[] subParams = new Parameters[maxCols]; for (int i = 1; i <= maxCols; i++){ values[i - 1] = "" + i; Parameter[] px = new Parameter[i]; for (int j = 0; j < i; j++){ px[j] = new SingleChoiceParam(GetVariableName(j), j){Values = selection}; } Parameters p = new Parameters(px); subParams[i - 1] = p; } return new SingleChoiceWithSubParams("Number of columns", 0){ Values = values, SubParams = subParams, ParamNameWidth = 120, TotalWidth = 800 }; }
/// <summary> /// Convert <see cref="BaseLib.Param"/> to <see cref="BaseLibS.Param"/> /// </summary> /// <param name="p"></param> /// <returns></returns> public static Parameter Convert(Parameter p) { if (p.Type == ParamType.Server){ return p; } if (p is RegexReplaceParamWf){ RegexReplaceParamWf q = (RegexReplaceParamWf) p; RegexReplaceParam b = new RegexReplaceParam(q.Name, q.Value.Item1, q.Value.Item2, q.Previews){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is RegexMatchParamWf){ RegexMatchParamWf q = (RegexMatchParamWf) p; RegexMatchParam b = new RegexMatchParam(q.Name, q.Value, q.Previews){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is BoolParamWf){ BoolParamWf q = (BoolParamWf) p; BoolParam b = new BoolParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is BoolWithSubParamsWf){ BoolWithSubParamsWf q = (BoolWithSubParamsWf) p; q.SubParamsFalse?.Convert(Convert); q.SubParamsTrue?.Convert(Convert); BoolWithSubParams b = new BoolWithSubParams(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, SubParamsFalse = q.SubParamsFalse, SubParamsTrue = q.SubParamsTrue, Default = q.Default, ParamNameWidth = q.ParamNameWidth, TotalWidth = q.TotalWidth, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is DictionaryIntValueParamWf){ DictionaryIntValueParamWf q = (DictionaryIntValueParamWf) p; DictionaryIntValueParam b = new DictionaryIntValueParam(q.Name, q.Value, q.Keys){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is DoubleParamWf){ DoubleParamWf q = (DoubleParamWf) p; DoubleParam b = new DoubleParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is FileParamWf){ FileParamWf q = (FileParamWf) p; FileParam b = new FileParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Filter = q.Filter, ProcessFileName = q.ProcessFileName, Save = q.Save, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is FolderParamWf){ FolderParamWf q = (FolderParamWf) p; FolderParam b = new FolderParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is IntParamWf){ IntParamWf q = (IntParamWf) p; IntParam b = new IntParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is LabelParamWf){ LabelParamWf q = (LabelParamWf) p; LabelParam b = new LabelParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is MultiChoiceMultiBinParamWf){ MultiChoiceMultiBinParamWf q = (MultiChoiceMultiBinParamWf) p; MultiChoiceMultiBinParam b = new MultiChoiceMultiBinParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Values = q.Values, Bins = q.Bins, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is MultiChoiceParamWf){ MultiChoiceParamWf q = (MultiChoiceParamWf) p; MultiChoiceParam b = new MultiChoiceParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Repeats = q.Repeats, Values = q.Values, Default = q.Default, DefaultSelections = q.DefaultSelections, DefaultSelectionNames = q.DefaultSelectionNames, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is MultiFileParamWf){ MultiFileParamWf q = (MultiFileParamWf) p; MultiFileParam b = new MultiFileParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Filter = q.Filter, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is MultiStringParamWf){ MultiStringParamWf q = (MultiStringParamWf) p; MultiStringParam b = new MultiStringParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is SingleChoiceParamWf){ SingleChoiceParamWf q = (SingleChoiceParamWf) p; SingleChoiceParam b = new SingleChoiceParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Values = q.Values, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is SingleChoiceWithSubParamsWf){ SingleChoiceWithSubParamsWf q = (SingleChoiceWithSubParamsWf) p; foreach (Parameters param in q.SubParams){ param?.Convert(Convert); } SingleChoiceWithSubParams b = new SingleChoiceWithSubParams(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Values = q.Values, Default = q.Default, SubParams = new Parameters[q.SubParams.Count], ParamNameWidth = q.ParamNameWidth, TotalWidth = q.TotalWidth, Url = q.Url }; for (int i = 0; i < q.SubParams.Count; i++){ b.SubParams[i] = q.SubParams[i]; } foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is StringParamWf){ StringParamWf q = (StringParamWf) p; StringParam b = new StringParam(q.Name, q.Value){ Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } if (p is Ms1LabelParamWf){ Ms1LabelParamWf q = (Ms1LabelParamWf) p; Ms1LabelParam b = new Ms1LabelParam(q.Name, q.Value){ Values = q.Values, Multiplicity = q.Multiplicity, Help = q.Help, Visible = q.Visible, Default = q.Default, Url = q.Url }; foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){ b.ValueChanged += act; } return b; } throw new Exception("Could not convert ParamWfeter"); }