Permalink
Browse files

Bind event using MapEvent and virtual method.

  • Loading branch information...
1 parent 76d5886 commit 77e96b4065cdd262d47182693e9373be4453e89c Antony Denyer committed Apr 19, 2012
Showing with 33 additions and 10 deletions.
  1. +33 −10 Xwt/Xwt/WindowFrame.cs
View
@@ -59,6 +59,9 @@ namespace Xwt
public class WindowFrame: XwtComponent
{
EventHandler boundsChanged;
+ EventHandler shown;
+ EventHandler hidden;
+
Rectangle bounds;
bool pendingReallocation;
@@ -70,26 +73,30 @@ protected override void OnBackendCreated ()
Backend.Initialize (this);
Parent.bounds = Backend.Bounds;
Backend.EnableEvent (WindowFrameEvent.BoundsChanged);
- Backend.EnableEvent (WindowFrameEvent.Shown);
- Backend.EnableEvent (WindowFrameEvent.Hidden);
}
public void OnBoundsChanged (Rectangle bounds)
{
Parent.OnBoundsChanged (new BoundsChangedEventArgs () { Bounds = bounds });
- }
-
+ }
+
public virtual void OnShown ()
{
Parent.OnShown ();
- }
-
+ }
+
public virtual void OnHidden ()
{
Parent.OnHidden ();
}
}
+ static WindowFrame()
+ {
+ MapEvent(WindowFrameEvent.Shown, typeof(Window), "OnShown");
+ MapEvent(WindowFrameEvent.Hidden, typeof(Window), "OnHidden");
+ }
+
public WindowFrame ()
{
if (!(base.BackendHost is WindowBackendHost))
@@ -212,7 +219,6 @@ public void Show ()
protected virtual void OnShown ()
{
- var shown = Shown;
if(shown != null)
shown (this, EventArgs.Empty);
}
@@ -224,7 +230,6 @@ public void Hide ()
protected virtual void OnHidden ()
{
- var hidden = Hidden;
if (hidden != null)
hidden (this, EventArgs.Empty);
}
@@ -273,9 +278,27 @@ protected virtual void OnReallocate ()
}
}
- public EventHandler Shown;
- public EventHandler Hidden;
+ public event EventHandler Shown {
+ add {
+ BackendHost.OnBeforeEventAdd (WindowFrameEvent.Shown, shown);
+ shown += value;
+ }
+ remove {
+ shown -= value;
+ BackendHost.OnAfterEventRemove (WindowFrameEvent.Shown, shown);
+ }
+ }
+ public event EventHandler Hidden {
+ add {
+ BackendHost.OnBeforeEventAdd (WindowFrameEvent.Hidden, hidden);
+ hidden += value;
+ }
+ remove {
+ hidden -= value;
+ BackendHost.OnAfterEventRemove (WindowFrameEvent.Hidden, hidden);
+ }
+ }
}
public class BoundsChangedEventArgs: EventArgs

0 comments on commit 77e96b4

Please sign in to comment.