Example #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);
             }
         }
     }
 }
Example #2
0
        protected override void Internal_Redo(GH_Document doc)
        {
            IGH_DocumentObject val = doc.FindObject(oldState.ComponentId, true);

            if (val == null || !(val is GH_SwitcherComponent))
            {
                throw new GH_UndoException("Switcher component with id[" + oldState.ComponentId + "] not found");
            }
            GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)val;

            if (newUnit != null)
            {
                gH_SwitcherComponent.SwitchUnit(newUnit, recompute: true, recordEvent: false);
            }
            else
            {
                gH_SwitcherComponent.ClearUnit(recompute: false);
            }
        }