using System;
using System.Collections.Generic;
using Chernobyl.Update;
namespace Chernobyl.Input.Controls
{
///
/// An that uses it's
/// for all implementations.
///
public abstract class ControlDecorator : UpdateableDecorator, IControl
{
///
/// The name of this control.
///
public string Name { get { return DecoratedController.Name; } set { DecoratedController.Name = value; } }
///
/// The parent of this control.
///
public IControl ControlParent
{
get { return DecoratedController.ControlParent; }
set { DecoratedController.ControlParent = value; }
}
///
/// The children of this control
///
public ICollection ControlChildren { get { return DecoratedController.ControlChildren; } }
///
/// An event that is raised when this is
/// disconnected from the device it was previously connected to and is
/// no longer available for use. Actions performed on the
/// after it has been disconnected may result
/// is an being thrown.
///
public virtual event EventHandler Disconnected
{
add
{
if (_disconnected == null && DecoratedController != null)
DecoratedController.Disconnected += OnDecoratedControllerDisconnected;
_disconnected += value;
}
remove
{
_disconnected -= value;
if (_disconnected == null && DecoratedController != null)
DecoratedController.Disconnected -= OnDecoratedControllerDisconnected;
}
}
///
/// The that implements the functionality of
/// this . Note that, when setting this property,
/// the data from the previous value of this property will be copied to
/// the new value using
/// .
///
protected abstract IControl DecoratedController { get; }
///
/// The that implements the functionality of
/// this . Note that, when setting this property,
/// the data from the previous value of this property will be copied to
/// the new value using
/// .
///
protected override IUpdateable DecoratedUpdateable { get { return DecoratedController; } }
///
/// An event handler that is invoked whenever the
/// has been disconnected from the
/// device it was previously connected to. This method raises the
/// event of this class but using 'this' as
/// the sender.
///
/// The instance that generated the event.
/// The instance containing the event data.
void OnDecoratedControllerDisconnected(object sender, EventArgs e)
{
if (_disconnected != null)
_disconnected(this, e);
}
///
/// The backing field to .
///
EventHandler _disconnected;
}
}