/// <summary> /// Replace a value list with one that has been pre-populated with possible methonds. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnParameterSourcesChanged(Object sender, GH_ParamServerEventArgs e) { int index = e.ParameterIndex; IGH_Param param = e.Parameter; //Only add value list to the first input if (param.Name != "*Method") { return; } //Only change value lists var extractedItems = param.Sources.Where(p => p.Name == "Value List"); //Set up value list Dictionary <string, string> options = new Dictionary <string, string>(); foreach (int entity in typeof(MotionType).GetEnumValues()) { MotionType m = (MotionType)entity; options.Add(m.ToString(), entity.ToString()); } Grasshopper.Kernel.Special.GH_ValueList gH_ValueList = Canvas.Component.CreateValueList("Mothods", options); //The magic Canvas.Component.ChangeObjects(extractedItems, gH_ValueList); }
//This is for if any source connected, reconnected, removed, replacement private void ParamSourcesChanged(Object sender, GH_ParamServerEventArgs e) { bool isInputSide = e.ParameterSide == GH_ParameterSide.Input ? true : false; //check input side only if (!isInputSide) { return; } bool isLastSourceFull = Params.Input.Last().Sources.Any(); // add a new input param while the second last input is full if (isLastSourceFull) { IGH_Param newParam = CreateParameter(GH_ParameterSide.Input, Params.Input.Count); Params.RegisterInputParam(newParam, Params.Input.Count); VariableParameterMaintenance(); this.Params.OnParametersChanged(); } ////recollecting the filteredSources and rename while any source changed //_filteredSources = gatherSources(); //checkAllNames(filteredSources); checkInputParamNickname(e.Parameter); }
void UpdateValueList(object sender, GH_ParamServerEventArgs e) { if (e.ParameterIndex == folderParamIndex) { var valueLists = GetConnectedValueLists(); if (valueLists.Count > 1) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Multiple value lists connected, only first value list will be populated with files"); } if (valueLists.Count >= 1) { var valueList = valueLists[0]; var paths = GetPaths(); HashSet <string> newFolderNames = GetFolders(paths); HashSet <string> oldFolderNames = GetValueListNames(valueList); if (!oldFolderNames.SetEquals(newFolderNames)) { var newNameValuePairs = newFolderNames.Select(name => (name, name.ToValueListString())); RebuildValueList(valueList, newNameValuePairs); } } } }
/// <summary> /// Replace a number slider with one that has the proper values set. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnParameterSourcesChanged(Object sender, GH_ParamServerEventArgs e) { int index = e.ParameterIndex; IGH_Param param = e.Parameter; //Trigger data collection if (param.Name == "Robot" | param.Name == "Instructions") { newData = true; } //Only add value list to the first input if (param.Name != "*Timeline") { return; } //Only change value lists var extractedItems = param.Sources.Where(p => p.Name == "Number Slider"); //Set up the number slider Grasshopper.Kernel.Special.GH_NumberSlider gH_NumberSlider = Canvas.Component.CreateNumbersilder("Timeline", 0, 1m, 4, 400); //The magic Canvas.Component.ChangeObjects(extractedItems, gH_NumberSlider); }
/// <summary> /// Replace a value list with one that has been pre-populated with possible speeds. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnParameterSourcesChanged(Object sender, GH_ParamServerEventArgs e) { int index = e.ParameterIndex; IGH_Param param = e.Parameter; //Only add value list to the first input if (index != 0) { return; } //Only change value lists var extractedItems = param.Sources.Where(p => p.Name == "Value List"); //Set up value list Dictionary <string, string> options = new Dictionary <string, string>(); foreach (KeyValuePair <double, Speed> entity in Util.ABBSpeeds()) { options.Add(entity.Value.Name, entity.Key.ToString()); } Grasshopper.Kernel.Special.GH_ValueList gH_ValueList = Canvas.Component.CreateValueList("Speeds", options); //The magic Canvas.Component.ChangeObjects(extractedItems, gH_ValueList); }
/*******************************************/ /**** Interface Methods ****/ /*******************************************/ protected virtual void OnGHParamChanged(object sender, GH_ParamServerEventArgs e) { if (Caller == null) { return; } if (e?.Parameter == null || e?.ParameterIndex == -1 || e?.ParameterSide == GH_ParameterSide.Output || Caller?.InputParams.Count - 1 < e.ParameterIndex) { return; } // Updating Caller.InputParams based on the new Grasshopper parameter just received // We update the InputParams with the new type or name if (m_NotifyChanges) { bool newName = Caller.InputParams.Count > e.ParameterIndex && Caller.InputParams[e.ParameterIndex].Name != e.Parameter.NickName; Caller.UpdateInput(e.ParameterIndex, e.Parameter.NickName, e.Parameter.Type(Caller)); if (newName) { ExpireSolution(true); // It would be great to only expire the solution when the input menu closes to avoid doing it on each key stroke but there doesn't seem to be a way to access the menu } } return; }
private void ParamSourcesChanged(object sender, GH_ParamServerEventArgs e) { if (((e.ParameterSide == 0) && (e.ParameterIndex == (Component.Params.Input.Count - 1))) && (e.Parameter.SourceCount > 0)) { IGH_Param param = this.CreateParameter(0, Component.Params.Input.Count); Component.Params.RegisterInputParam(param); Component.Params.OnParametersChanged(); } }
//remove preview when disconnect source public void Params_ParameterSourcesChanged(object sender, GH_ParamServerEventArgs e) { if (!inputLock) { if (e.Parameter.SourceCount == 0) { RemovePreviewObjects(); } } }
private void Params_ParameterChanged(object sender, GH_ParamServerEventArgs e) { if (e.ParameterSide == GH_ParameterSide.Input) { if (e.ParameterIndex == 0 || e.ParameterIndex == 1 || e.ParameterIndex == 6) { SetupDone = false; } } }
//if the user adds/removes a parameter, this is the event handler private void ParamSourcesChanged(object sender, GH_ParamServerEventArgs e) { // if where the user clicked was the output side, and it's the last of the output parameters if (e.ParameterSide == GH_ParameterSide.Output && e.ParameterIndex == Params.Output.Count - 1) { //create a new parameter IGH_Param new_Param = CreateParameter(GH_ParameterSide.Output, Params.Output.Count); Params.RegisterOutputParam(new_Param); VariableParameterMaintenance(); Params.OnParametersChanged(); } }
private void AddInput(Object _sender, GH_ParamServerEventArgs _eventargs) { if (_eventargs.ParameterSide == GH_ParameterSide.Input) { if (Params.Input.Last().Sources.Any()) { IGH_Param toAdd = CreateParameter(GH_ParameterSide.Input, Params.Input.Count); Params.RegisterInputParam(toAdd, Params.Input.Count); VariableParameterMaintenance(); this.Params.OnParametersChanged(); } } }
/// <summary> /// Replace a value list with one that has been pre-populated with possible methonds. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnParameterSourcesChanged(Object sender, GH_ParamServerEventArgs e) { int index = e.ParameterIndex; IGH_Param param = e.Parameter; switch (param.Name) { case "*Method": #region Change Value List //Only change value lists var extractedItems = param.Sources.Where(p => p.Name == "Value List"); //Set up value list Dictionary <string, string> options = new Dictionary <string, string>(); foreach (int entity in typeof(MotionType).GetEnumValues()) { MotionType m = (MotionType)entity; options.Add(m.ToString(), entity.ToString()); } Grasshopper.Kernel.Special.GH_ValueList gH_ValueList = Canvas.Component.CreateValueList("Mothods", options); //The magic Canvas.Component.ChangeObjects(extractedItems, gH_ValueList); break; #endregion Change Value List case "Plane": if (param.Sources.Count == 0) { return; } foreach (var p in param.Sources) { if (p.Name == "Panel") { this.c_motionType = MotionType.AbsoluteJoint; return; } } break; default: break; } }
//This is for if any source connected, reconnected, removed, replacement private void ParamSourcesChanged(Object sender, GH_ParamServerEventArgs e) { //int inputParamCount = this.Params.Input.Count - 1; int selectionIndex = this.Params.IndexOfInputParam(this._selectionName); bool isInputSide = e.ParameterSide == GH_ParameterSide.Input; bool isSelection = e.ParameterIndex == selectionIndex; bool isRemoteFly = e.Parameter.NickName == this._remoteFlyName; //check input side only if (!isInputSide) { return; } //check if is Selection setting only if (isSelection) { return; } //check if is _remoteFly setting if (isRemoteFly) { return; } //{ // //Selection's index becomes this.Params.Input.Count - 2 // if (e.ParameterIndex == inputParamCount-1) return; //} bool isSecondLastSourceFull = Params.Input[selectionIndex - 1].Sources.Any(); // add a new input param while the second last input is full if (isSecondLastSourceFull) { IGH_Param newParam = CreateParameter(GH_ParameterSide.Input, selectionIndex); Params.RegisterInputParam(newParam, selectionIndex); VariableParameterMaintenance(); this.Params.OnParametersChanged(); } ////recollecting the filteredSources and rename while any source changed //_filteredSources = gatherSources(); //checkAllNames(filteredSources); }
private void Params_ParameterSourcesChanged(object sender, GH_ParamServerEventArgs e) { if (e.ParameterSide == GH_ParameterSide.Output) { return; } if (e.ParameterIndex == 2) { this.isScaleChanged = true; this.TempExtrCoordinates = new List <Drawing.Point>(this.ExtractedCoordinates); if (this.Params.Input[2].SourceCount > 0) { this.Params.Input[2].Sources[0].SolutionExpired -= OnScale_SolutionExpired; this.Params.Input[2].Sources[0].SolutionExpired += OnScale_SolutionExpired; } } }
//This is for if any source connected, reconnected, removed, replacement private void ParamSourcesChanged(Object sender, GH_ParamServerEventArgs e) { bool isInputSide = e.ParameterSide == GH_ParameterSide.Input ? true : false; //check input side only if (!isInputSide) { return; } bool isLastSourceFull = Params.Input[Params.Input.Count - 1].Sources.Any(); // add a new input param while the second last input is full if (isLastSourceFull) { IGH_Param newParam = CreateParameter(GH_ParameterSide.Input, Params.Input.Count); Params.RegisterInputParam(newParam, Params.Input.Count); VariableParameterMaintenance(); Params.OnParametersChanged(); } }
private void OnParameterSourcesChanged(object sender, GH_ParamServerEventArgs e) { //// It's happening on Params.Input //if (e.ParameterSide == GH_ParameterSide.Input) //{ // // it's happening on Params.Input[0] // if (e.ParameterIndex == 0) // { // int n = Params.Input[0].SourceCount; // if (n == 0) // { // // no more source is connected to Inpur[0] // hasValidPoint = false; // return; // } // // one source is connected // if (n == 1) // { // // thus the grid may have changed ... // // we request refresh from the user // hasValidControls = false; // hasValidPoint = false; // Params.Input[0]..SolutionExpired += OnGridExpired; // this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Grid Has Changed. Reset Controls via Menu."); // this.Message = "Select Controls in Menu"; // } // // more than one source is not allowed : disconnect them // for (int i = 1; i < n; i++) // { // Params.Input[0].RemoveSource(Params.Input[0].Sources[i]); // } // } //} }
private void Params_ParameterNickNameChanged(object sender, GH_ParamServerEventArgs e) { ExpireSolution(true); }
private void ParameterChanged(object sender, GH_ParamServerEventArgs e) { InitalizePrivateData(); ClearData(); }
void ParameterChanged(object sender, GH_ParamServerEventArgs e) { VariableParameterMaintenance(); }
protected virtual void OnParameterChange(object sender, GH_ParamServerEventArgs e) { ExpireSolution(true); }
private void Params_ParameterSourcesChanged(object sender, GH_ParamServerEventArgs e) { this.ExpireSolution(true); }
private void ParameterChanged(object sender, GH_ParamServerEventArgs e) { InitalizePrivateData(); ClearData(); }
//This is for if any source connected, reconnected, removed, replacement private void ParamSourcesChanged(Object sender, GH_ParamServerEventArgs e) { previousMessage = null; previousBroadcast = !previousBroadcast; }
// this function forces GH to recompute the component - bound to change events protected virtual void OnParameterChanged(object sender, GH_ParamServerEventArgs e) { //curParam.reset(); ExpireSolution(false); }
private void Params_ParameterSourcesChanged(object sender, GH_ParamServerEventArgs e) { this.DropDownControl.ConstructContextMenu(this.ContextMenuName); }