using System.Collections.Generic;
using System.Drawing;
namespace TBO.UI.tboTK
{
abstract class Application : IContiner
{
#region IContiner
private Dictionary<string, Control> controls = new Dictionary<string, Control>();
public bool Add(Control c)
{
if (c == null)
return false;
if (Get(c.Id, true) != null)
return false;
controls[c.Id] = c;
return true;
}
public Control Get(string id, bool deep = false)
{
Control r;
if (controls.TryGetValue(id, out r))
return r;
if (deep)
foreach (Control c in controls.Values)
if (c is IContiner)
return ((IContiner)c).Get(id, deep);
return null;
}
public bool Remove(string id)
{
return Remove(Get(id));
}
public bool Remove(Control c)
{
if (c == null)
return false;
return controls.Remove(c.Id);
}
#endregion
public abstract void ResizeTo(Size size);
public void Paint(Graphics g, Rectangle clip)
{
foreach (Control c in controls.Values)
if (c.Clips(clip))
c.Paint(g, clip);
}
public abstract string Id { get; }
public abstract string Title { get; }
}
}