public override void Add(Component component) { if (PlayingWorld) { WorldComponents.Add(component); } base.Add(component); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// Adds a component or a control to the manager. /// </summary> /// <param name="component"> /// The component or control being added. /// </param> public virtual void Add(Component component) { if (component != null) { if (component is Control && !controls.Contains(component as Control)) { Control c = (Control)component; if (c.Parent != null) c.Parent.Remove(c); controls.Add(c); c.Manager = this; c.Parent = null; if (focusedControl == null) c.Focused = true; DeviceSettingsChanged += new DeviceEventHandler((component as Control).OnDeviceSettingsChanged); SkinChanging += new SkinEventHandler((component as Control).OnSkinChanging); SkinChanged += new SkinEventHandler((component as Control).OnSkinChanged); } else if (!(component is Control) && !components.Contains(component)) { components.Add(component); component.Manager = this; } } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// Removes a component or a control from the manager. /// </summary> /// <param name="component"> /// The component or control being removed. /// </param> public virtual void Remove(Component component) { if (component != null) { if (component is Control) { Control c = component as Control; SkinChanging -= c.OnSkinChanging; SkinChanged -= c.OnSkinChanged; DeviceSettingsChanged -= c.OnDeviceSettingsChanged; if (c.Focused) c.Focused = false; controls.Remove(c); } else { components.Remove(component); } } }
/// <summary> /// Adds a component or a control to the manager. /// </summary> /// <param name="component"> /// The component or control being added. /// </param> public virtual void Add(Component component) { // Component exists? if (component != null) { // Component is a Control not already in the list? if (component is Control && !controls.Contains(component as Control)) { Control c = (Control)component; // Remove control from parent list because it's under new management now. if (c.Parent != null) c.Parent.Remove(c); controls.Add(c); c.Manager = this; c.Parent = null; // New control gains focus unless another control already has it. if (focusedControl == null) c.Focused = true; DeviceSettingsChanged += new DeviceEventHandler((component as Control).OnDeviceSettingsChanged); SkinChanging += new SkinEventHandler((component as Control).OnSkinChanging); SkinChanged += new SkinEventHandler((component as Control).OnSkinChanged); } // Component is not a control and doesn't already exist in the component list? else if (!(component is Control) && !components.Contains(component)) { components.Add(component); component.Manager = this; } } }
/// <summary> /// Removes a component or a control from the manager. /// </summary> /// <param name="component"> /// The component or control being removed. /// </param> public virtual void Remove(Component component) { // Component is valid? if (component != null) { // Remove from the control list? if (component is Control) { Control c = component as Control; SkinChanging -= c.OnSkinChanging; SkinChanged -= c.OnSkinChanged; DeviceSettingsChanged -= c.OnDeviceSettingsChanged; if (c.Focused) c.Focused = false; controls.Remove(c); } // Remove from components list. else { components.Remove(component); } } }