private void SetReadState() { if (activeUnit != null) { staticData.UnregisterUnit(activeUnit); activeUnit.Active = false; activeUnit = null; } GH_Document val = this.OnPingDocument(); if (val != null) { val.Modified(); val.DestroyAttributeCache(); val.DestroyObjectTable(); } if (this.Attributes != null) { ((GH_SwitcherComponentAttributes)this.Attributes).OnSwitchUnit(); } this.Name = staticData.CachedName; this.NickName = staticData.CachedNickname; this.Description = staticData.CachedDescription; this.SetIconOverride(staticData.CachedIcon); if (this.Attributes != null) { this.Attributes.ExpireLayout(); } }
protected virtual void SwitchUnit(EvaluationUnit unit, bool recompute = true, bool recordEvent = true) { if (unit != null && (activeUnit == null || activeUnit != unit)) { if (recordEvent) { this.RecordUndoEvent("Switch Unit", new GH_SwitchAction(this, unit.Name)); } if (activeUnit != null) { staticData.UnregisterUnit(activeUnit); activeUnit.Active = false; activeUnit = null; } staticData.RegisterUnit(unit); activeUnit = unit; activeUnit.Active = true; GH_Document val = this.OnPingDocument(); if (val != null) { val.Modified(); val.DestroyAttributeCache(); val.DestroyObjectTable(); } if (this.Attributes != null) { ((GH_SwitcherComponentAttributes)this.Attributes).OnSwitchUnit(); } if (unit.DisplayName != null) { this.SetIconOverride(unit.Icon); } if (this.Attributes != null) { this.Attributes.ExpireLayout(); } if (recompute) { this.ExpireSolution(true); } } }
public void ClearUnit(bool recompute = true, bool recordEvent = true) { if (!UnitlessExistence) { return; } if (activeUnit != null) { if (recordEvent) { this.RecordUndoEvent("Switch Unit", new GH_SwitchAction(this, null)); } staticData.UnregisterUnit(activeUnit); activeUnit.Active = false; activeUnit = null; } GH_Document val = this.OnPingDocument(); if (val != null) { val.Modified(); val.DestroyAttributeCache(); val.DestroyObjectTable(); } if (this.Attributes != null) { ((GH_SwitcherComponentAttributes)this.Attributes).OnSwitchUnit(); } this.Name = staticData.CachedName; this.NickName = staticData.CachedNickname; this.Description = staticData.CachedDescription; this.SetIconOverride(staticData.CachedIcon); if (this.Attributes != null) { this.Attributes.ExpireLayout(); } if (recompute) { this.ExpireSolution(true); } }