/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pColorSets ClrSets = new pColorSets(); pManager.AddColourParameter("Color", "C", "Color", GH_ParamAccess.item, Color.Transparent); pManager[0].Optional = true; pManager.AddIntegerParameter("Color Modes", "M", "---", GH_ParamAccess.item, 1); pManager[1].Optional = true; pManager.AddColourParameter("Custom Palette", "P", "Custom Palette", GH_ParamAccess.list, ClrSets.Standard); pManager[2].Optional = true; pManager.AddColourParameter("Standard Colors", "S", "Standard Colors", GH_ParamAccess.list, ClrSets.Standard); pManager[3].Optional = true; Param_Integer param = (Param_Integer)Params.Input[1]; param.AddNamedValue("Custom", 0); param.AddNamedValue("RGB Range", 1); }
public void SetProperties(System.Drawing.Color Default, List <System.Drawing.Color> CustomColors, List <System.Drawing.Color> ColorSet, int Mode) { Element.SelectedColor = new wColor(Default).ToNullableMediaColor().Value; Element.ShowDropDownButton = false; Element.ShowDropDownButton = false; pColorSets ColorSets = new pColorSets(); switch (Mode) { case 0: Element.AvailableColors = ColorSets.CustomSet(ColorSet); break; case 1: Element.AvailableColors = ColorSets.RGBrange; break; default: Element.AvailableColors = ColorSets.RGBrange; break; } Element.StandardColors = ListToCollection(CustomColors); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string ID = this.Attributes.InstanceGuid.ToString(); string name = new GUIDtoAlpha(Convert.ToString(ID + Convert.ToString(this.RunCount)), false).Text; int C = this.RunCount; wObject WindObject = new wObject(); pElement Element = new pElement(); bool Active = Elements.ContainsKey(C); var pCtrl = new pColorPicker(name); if (Elements.ContainsKey(C)) { Active = true; } //Check if control already exists if (Active) { if (Elements[C] != null) { WindObject = Elements[C]; Element = (pElement)WindObject.Element; pCtrl = (pColorPicker)Element.ParrotControl; } } else { Elements.Add(C, WindObject); } //Set Unique Control Properties Color D = Color.Transparent; List <Color> S = new List <Color>(); List <Color> K = new List <Color>(); int M = 1; if (!DA.GetData(0, ref D)) { return; } if (!DA.GetData(1, ref M)) { return; } if (!DA.GetDataList(2, K)) { return; } if (!DA.GetDataList(3, S)) { return; } pColorSets ClrSets = new pColorSets(); if (S.Count < 1) { S = ClrSets.Standard; } if (K.Count < 1) { K = ClrSets.Standard; } pCtrl.SetProperties(D, S, K, M); //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type, 1); } WindObject = new wObject(Element, "Parrot", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; DA.SetData(0, WindObject); }