public override string ToString() { StringBuilder sb = new StringBuilder(); foreach (Parameter p in this) { string sValue = string.Empty; ParameterBool pBool = p as ParameterBool; if (null != pBool) { sValue = pBool.Value.ToString(); } ParameterInt pInt = p as ParameterInt; if (null != pInt) { sValue = pInt.Value.ToString(); } ParameterDouble pDouble = p as ParameterDouble; if (null != pDouble) { sValue = pDouble.Value.ToString(); } ParameterMulti pMulti = p as ParameterMulti; if (null != pMulti) { sValue = pMulti.Value.ToString() + " " + string.Join("|", pMulti.ValueList); } sb.AppendFormat("{0} = {1}\n", p.Name, sValue); } return(sb.ToString()); }
public int GetIntParameterValue(string name) { ParameterInt param = GetParameterByName(name) as ParameterInt; if (null == param) { throw new ParameterInvalidType(name, "ParameterInt"); } return(param.Value); }
public void SetIntegerParameter(string name, int value) { ParameterInt param = GetParameterByName(name) as ParameterInt; if (null == param) { throw new ParameterInvalidType(name, "ParameterInt"); } param.Value = value; }
public string GetInsertionCode() { Pic.Plugin.ParameterStack stackIn = _component.BuildParameterStack(null); string csCode = string.Empty; csCode += "\n"; csCode += "\t\t{ // " + _component.Name + "\n"; csCode += "\t\t\tIPlugin pluginIn = Host.GetPluginByGuid(\"" + _component.Guid.ToString() + "\");\n"; csCode += "\t\t\tParameterStack stackIn = Host.GetInitializedParameterStack(pluginIn);\n"; foreach (Parameter param in stackIn) { // double ParameterDouble paramDouble = param as ParameterDouble; if (null != paramDouble) { csCode += "\t\t\tstackIn.SetDoubleParameter(\"" + paramDouble.Name + "\"," + paramDouble.ValueDefault.ToString() + ");\t\t// " + paramDouble.Description + "\n"; } // bool ParameterBool paramBool = param as ParameterBool; if (null != paramBool) { csCode += "\t\t\tstackIn.SetBoolParameter(\"" + paramBool.Name + "\"," + (paramBool.ValueDefault ? "true" : "false") + ");\t\t// " + paramBool.Description + "\n"; } // int ParameterInt paramInt = param as ParameterInt; if (null != paramInt) { csCode += "\t\t\tstackIn.SetIntParameter(\"" + paramInt.Name + "\"," + paramInt.ValueDefault.ToString() + ");\t\t// " + paramInt.Description + "\n"; } // multi ParameterMulti paramMulti = param as ParameterMulti; if (null != paramMulti) { csCode += "\t\t\tstackIn.SetMultiParameter(\"" + paramMulti.Name + "\"," + paramMulti.Value.ToString() + ");\t\t// " + paramMulti.Description + "\n"; } } csCode += "\t\t\tbool reflectionX = false, reflectionY = false;\n"; csCode += "\t\t\tTransform2D transfReflect = (reflectionY ? Transform2D.ReflectionY : Transform2D.Identity) * (reflectionX ? Transform2D.ReflectionX : Transform2D.Identity);\n"; csCode += "\t\t\tpluginIn.CreateFactoryEntities(fTemp, stackIn,\n"; csCode += "\t\t\t\t Transform2D.Translation(new Vector2D(0.0, 0.0))\n"; csCode += "\t\t\t\t *Transform2D.Rotation(0.0)\n"; csCode += "\t\t\t\t *transfReflect);\n"; csCode += "\t\t}\n"; return(csCode); }
public void AddIntParameter(string name, string description, int valueDefault, bool hasMinValue, int valueMin, bool hasMaxValue, int valueMax) { ParameterInt param = new ParameterInt(); param.Name = name; param.Description = description; param.ValueDefault = valueDefault; param.Value = valueDefault; if (hasMinValue) { param.ValueMin = valueMin; } if (hasMaxValue) { param.ValueMax = valueMax; } _parameterList.Add(param); }
public ParameterStack GetParameters(IComponentSearchMethod compSearchMethod) { ParameterStack parameters = _instance.Parameters; if (null != compSearchMethod) { foreach (Parameter p in parameters) { try { ParameterDouble pd = p as ParameterDouble; if (null != pd) { parameters.SetDoubleParameter(pd.Name, compSearchMethod.GetDoubleParameterDefaultValue(Guid, pd.Name)); } ParameterBool pb = p as ParameterBool; if (null != pb) { parameters.SetBoolParameter(pb.Name, compSearchMethod.GetBoolParameterDefaultValue(Guid, pb.Name)); } ParameterInt pi = p as ParameterInt; if (null != pi) { parameters.SetIntegerParameter(pb.Name, compSearchMethod.GetIntParameterDefaultValue(Guid, pi.Name)); } ParameterMulti pm = p as ParameterMulti; if (null != pm) { parameters.SetMultiParameter(pm.Name, 0); } } catch (Exception /*ex*/) { } } } return(parameters); }
public void AddIntParameter(string name, string description, int valueDefault, bool hasMinValue, int valueMin, bool hasMaxValue, int valueMax) { ParameterInt param = new ParameterInt(); param.Name = name; param.Description = description; param.ValueDefault = valueDefault; param.Value = valueDefault; if (hasMinValue) param.ValueMin = valueMin; if (hasMaxValue) param.ValueMax = valueMax; _parameterList.Add(param); }
public ParameterStack GetInitializedParameterStack(IPlugin plugin) { // check if already available in cache ParameterStack stack = null; stack = ComponentLoader.GetStackFromCache(plugin.Guid); if (null == stack) { if (!(_searchMethod is IComponentSearchMethod)) { throw new PluginException("Component loader was not initialized with a valid plugin search method."); } IPluginExt1 pluginExt1 = plugin as IPluginExt1; IPluginExt2 pluginExt2 = plugin as IPluginExt2; IPluginExt3 pluginExt3 = plugin as IPluginExt3; // get parameter stack if (null != pluginExt1) { stack = plugin.Parameters; } else if (null != pluginExt2) { stack = pluginExt2.BuildParameterStack(null); } else if (null != pluginExt3) { stack = pluginExt3.BuildParameterStack(null); } // check parameter stack if (null == stack) { throw new PluginException("Failed to build initial parameter stack."); } // load parameter values from plugins foreach (Parameter param in stack) { try { ParameterDouble pd = param as ParameterDouble; if (null != pd) { stack.SetDoubleParameter(pd.Name, _searchMethod.GetDoubleParameterDefaultValue(plugin.Guid, pd.Name)); } ParameterBool pb = param as ParameterBool; if (null != pb) { stack.SetBoolParameter(pb.Name, _searchMethod.GetBoolParameterDefaultValue(plugin.Guid, pb.Name)); } ParameterInt pi = param as ParameterInt; if (null != pi) { stack.SetIntParameter(pi.Name, _searchMethod.GetIntParameterDefaultValue(plugin.Guid, pi.Name)); } ParameterMulti pm = param as ParameterMulti; if (null != pm) { stack.SetMultiParameter(pm.Name, _searchMethod.GetMultiParameterDefaultValue(plugin.Guid, pm.Name)); } } catch (Exception /*ex*/) { } } // save in cache ComponentLoader.InsertParameterStackInCache(plugin.Guid, stack); } return(stack.Clone()); }