/// <summary> /// Save control values in parameter stack /// </summary> /// <param name="stack">Parameter stack passed as ref</param> private bool SaveControlValues(ref Pic.Plugin.ParameterStack stack) { if (null == stack) return false; // load some parameters from majorations if (null != _profileLoader) { foreach (Parameter param in stack.ParameterList) { if (_profileLoader.HasParameter(param)) stack.SetDoubleParameter(param.Name, _profileLoader.GetParameterDValue(param.Name)); } } // load other parameters foreach (Control ctrl in Panel2.Controls) { if (ctrl.GetType() == typeof(NumericUpDown)) { NumericUpDown nud = ctrl as NumericUpDown; if (nud.Name.Equals("nudThickness")) { _thickness = Convert.ToDouble(nud.Value); if (stack.HasParameter("ep1")) stack.SetDoubleParameter("ep1", _thickness); if (stack.HasParameter("th1")) stack.SetDoubleParameter("th1", _thickness); } else foreach (Parameter param in stack.ParameterList) { if (nud.Name.Equals("nud" + param.Name)) { if (param.GetType() == typeof(ParameterDouble)) { ParameterDouble paramDouble = param as ParameterDouble; try { paramDouble.Value = Convert.ToDouble(nud.Value); } catch (Exception ex) { _log.Error(ex.ToString()); } } else if (param.GetType() == typeof(ParameterInt)) { ParameterInt paramInt = param as ParameterInt; try { paramInt.Value = Convert.ToInt32(nud.Value); } catch (Exception /*ex*/) { } } } } } else if (ctrl.GetType() == typeof(CheckBox)) { CheckBox chkb = ctrl as CheckBox; foreach (Parameter param in stack.ParameterList) { ParameterBool paramBool = param as ParameterBool; if (null != paramBool && chkb.Name.Equals("chkb" + param.Name)) paramBool.Value = chkb.Checked; } } else if (ctrl.GetType() == typeof(ComboBox)) { ComboBox cb = ctrl as ComboBox; foreach (Parameter param in stack.ParameterList) { ParameterMulti paramMulti = param as ParameterMulti; if (null != paramMulti && cb.Name.Equals("cb" + param.Name)) paramMulti.Value = cb.SelectedIndex; } } } return true; }