Beispiel #1
0
		/// <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);
				}
			}
		}
Beispiel #2
0
		/// <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;
				}
			}
		}