Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Control : Component
- {
- // Claves únicas eventos:
- static readonly object mouseDownEventKey = new object();
- static readonly object mouseUpEventKey = new object();
- // Recupera un manejador de eventos. El menajedor recuperado
- // está asociado con una clave
- protected Delegate ObtenerEventHandler(object key){ ... }
- // Agrega un menajedor de eventos:
- protected void AgregarEventHandler(object key, Delegate handler) { ... }
- // Remuee un menejador de eventos:
- protected void RemoverEventHandler(object key, Delegate handler) { ... }
- // Evento de movimiento de mouse MouseDown
- public event MouseEventHandler
- {
- add
- {
- AgregarEventHandler(mouseDownEventKey, value);
- }
- remove
- {
- RemoverEventHandler(mouseDownEventKey, value);
- }
- }
- // Evento de movimiento de mouse MouseUp:
- public event MouseEventHandler MouseUp
- {
- add
- {
- AgregarEventHandler(mouseUpEventKey, value);
- }
- remove
- {
- RemoverEventHandler(mouseUpEventKey, value);
- }
- }
- // Invocación del evento MouseUp:
- protected void OnMouseUp(MouseEventArgs args)
- {
- MouseEventHandler handler;
- handler = (MouseEventHandler) ObtenerEventHandler(mouseUpEventKey);
- if (handler != null)
- {
- handler(this, args);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement