/// <summary> /// Adapts the control with the given control adapters, calling their Bind methods /// in the order that they are given here and their BindReverse methods in the /// reverse order that they are given here</summary> /// <param name="adapters">Adapters to adapt the control</param> /// <remarks>By convention, the bottom-most IControlAdapter should appear as the /// first parameter and subscribe to the Paint event in its Bind() method and subscribe /// to mouse events in its BindReverse() method. Likewise, the top-most IControlAdapter /// should be the last parameter.</remarks> public void Adapt(params IControlAdapter[] adapters) { OnAdapting(EventArgs.Empty); Adapting.Raise(this, EventArgs.Empty); // allow existing adapters to detach from context Context = null; foreach (IControlAdapter adapter in m_adapters) { adapter.Unbind(this); Dispose(adapter); } m_adapters.Clear(); m_adapterCache.Clear(); m_contextAdapterPreferred.Clear(); m_adapters.AddRange(adapters); foreach (IControlAdapter adapter in m_adapters) { adapter.Bind(this); } for (int i = m_adapters.Count - 1; i >= 0; i--) { m_adapters[i].BindReverse(this); } OnAdapted(EventArgs.Empty); Adapted.Raise(this, EventArgs.Empty); Invalidate(); }
/// <inheritdoc /> public void Proceed() { Adapted.Proceed(); }