Ejemplo n.º 1
0
 public void Apply(GH_SwitcherComponent component, GH_Document document)
 {
     if (noUnit)
     {
         component.ClearUnit(recompute: true, recordEvent: false);
     }
     else
     {
         component.SwitchUnit(unit, recompute: true, recordEvent: false);
     }
     for (int i = 0; i < inputs.Count; i++)
     {
         GH_SwitcherParamState gH_SwitcherParamState = inputs[i];
         int num = component.Params.IndexOfInputParam(gH_SwitcherParamState.ParameterId);
         if (num == -1)
         {
             continue;
         }
         IGH_Param val = component.Params.Input[num];
         for (int j = 0; j < gH_SwitcherParamState.Targets.Count; j++)
         {
             IGH_Param val2 = document.FindParameter(gH_SwitcherParamState.Targets[j]);
             if (val2 != null)
             {
                 val.AddSource(val2);
             }
         }
     }
     for (int k = 0; k < outputs.Count; k++)
     {
         GH_SwitcherParamState gH_SwitcherParamState2 = outputs[k];
         int num2 = component.Params.IndexOfOutputParam(gH_SwitcherParamState2.ParameterId);
         if (num2 == -1)
         {
             continue;
         }
         IGH_Param val3 = component.Params.Output[num2];
         for (int l = 0; l < gH_SwitcherParamState2.Targets.Count; l++)
         {
             IGH_Param val4 = document.FindParameter(gH_SwitcherParamState2.Targets[l]);
             if (val4 != null)
             {
                 val4.AddSource(val3);
             }
         }
     }
 }
Ejemplo n.º 2
0
            public static GH_SwitcherConnectivity Create(GH_SwitcherComponent component)
            {
                GH_SwitcherConnectivity gH_SwitcherConnectivity = new GH_SwitcherConnectivity();

                gH_SwitcherConnectivity.componentId = component.InstanceGuid;
                EvaluationUnit activeUnit = component.ActiveUnit;

                if (activeUnit != null)
                {
                    gH_SwitcherConnectivity.noUnit = false;
                    gH_SwitcherConnectivity.unit   = activeUnit.Name;
                }
                else if (component.UnitlessExistence)
                {
                    gH_SwitcherConnectivity.noUnit = true;
                }
                foreach (IGH_Param item in component.Params.Input)
                {
                    GH_SwitcherParamState gH_SwitcherParamState = new GH_SwitcherParamState(0, item.InstanceGuid);
                    gH_SwitcherConnectivity.inputs.Add(gH_SwitcherParamState);
                    foreach (IGH_Param source in item.Sources)
                    {
                        gH_SwitcherParamState.Targets.Add(source.InstanceGuid);
                    }
                }
                foreach (IGH_Param item2 in component.Params.Output)
                {
                    GH_SwitcherParamState gH_SwitcherParamState2 = new GH_SwitcherParamState(GH_ParameterSide.Output, item2.InstanceGuid);
                    gH_SwitcherConnectivity.outputs.Add(gH_SwitcherParamState2);
                    foreach (IGH_Param recipient in item2.Recipients)
                    {
                        gH_SwitcherParamState2.Targets.Add(recipient.InstanceGuid);
                    }
                }
                return(gH_SwitcherConnectivity);
            }