/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { Param_Guid guid = new Param_Guid(); guid.Name = "Guid"; guid.NickName = "G"; guid.Description = "Guid of Light"; guid.Access = GH_ParamAccess.item; pManager.AddParameter(guid); pManager.AddPointParameter("Location", "Loc", "Location", GH_ParamAccess.item, Point3d.Origin); pManager.AddPointParameter("Target", "T", "Target", GH_ParamAccess.item, new Point3d(0, 0, -1)); pManager.AddNumberParameter("Intensity", "In", "Intensity", GH_ParamAccess.item, 100); pManager.AddAngleParameter("Radius", "R", "Radius, must be in 0-Pi/2.", GH_ParamAccess.item, Math.PI / 4); pManager.AddNumberParameter("HotSpot", "H", "HotSpot, must be in 0-1.", GH_ParamAccess.item, 0.5); pManager.AddColourParameter("DiffuseColor", "Di", "DiffuseColor", GH_ParamAccess.item, Color.Aqua); pManager.AddColourParameter("SpecularColor", "Sp", "SpecularColor", GH_ParamAccess.item, Color.Aqua); }
/*************************************/ /**** Public Methods ****/ /*************************************/ public static IGH_Param ToGH_Param(this ParamInfo info) { UnderlyingType subType = info.DataType.UnderlyingType(); IGH_Param param; switch (subType.Type.FullName) { case "System.Boolean": param = new Param_Boolean(); break; case "System.Drawing.Color": param = new Param_Colour(); break; case "System.DateTime": param = new Param_Time(); break; case "System.Double": param = new Param_Number(); break; case "System.Guid": param = new Param_Guid(); break; case "System.Int16": case "System.Int32": param = new Param_Integer(); break; case "System.Int64": param = new Param_Time(); break; case "System.String": param = new Param_String(); break; case "System.Type": param = new Param_Type(); break; default: Type type = subType.Type; if (typeof(IGeometry).IsAssignableFrom(type)) { param = new Param_BHoMGeometry(); } else if (typeof(IBHoMObject).IsAssignableFrom(type)) { param = new Param_BHoMObject(); } else if (typeof(IObject).IsAssignableFrom(type)) { param = new Param_IObject(); } else if (typeof(Enum).IsAssignableFrom(type)) { param = new Param_Enum(); } else if (typeof(IDictionary).IsAssignableFrom(type)) { param = new Param_Dictionary(); } else if (typeof(BHoMAdapter).IsAssignableFrom(type)) { param = new Param_BHoMAdapter(); } else { param = new Param_Variable { SelectedHint = new GH_NullHint(), PossibleHints = Helpers.AvailableHints, }; } break; } param.Access = (GH_ParamAccess)subType.Depth; param.Description = info.Description; param.Name = info.Name; param.NickName = info.Name; param.Optional = !info.IsRequired; //TODO: Is it necessary to react to param.AttributesChanged ? if (param is IBHoMParam) { ((IBHoMParam)param).ObjectType = subType.Type; } try { if (info.HasDefaultValue && !info.IsRequired) { var data = Helpers.IToGoo(info.DefaultValue as dynamic); SetPersistentData(param as dynamic, data as dynamic); } } catch { } return(param); }