Author: jackson
Date: 2007-06-20 14:56:51 -0400 (Wed, 20 Jun 2007)
New Revision: 80349

Modified:
   trunk/olive/class/agclr/Mono/ChangeLog
   trunk/olive/class/agclr/Mono/NativeMethods.cs
   trunk/olive/class/agclr/System.Windows/ChangeLog
   trunk/olive/class/agclr/System.Windows/XamlReader.cs
Log:

        Tie into events.



Modified: trunk/olive/class/agclr/Mono/ChangeLog
===================================================================
--- trunk/olive/class/agclr/Mono/ChangeLog      2007-06-20 18:55:56 UTC (rev 
80348)
+++ trunk/olive/class/agclr/Mono/ChangeLog      2007-06-20 18:56:51 UTC (rev 
80349)
@@ -1,3 +1,7 @@
+2007-06-20  Jackson Harper  <[EMAIL PROTECTED]>
+
+       * NativeMethods.cs: Tie into events.
+
 2007-06-19  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * Kind.cs, NativeMethods.cs: More updates.

Modified: trunk/olive/class/agclr/Mono/NativeMethods.cs
===================================================================
--- trunk/olive/class/agclr/Mono/NativeMethods.cs       2007-06-20 18:55:56 UTC 
(rev 80348)
+++ trunk/olive/class/agclr/Mono/NativeMethods.cs       2007-06-20 18:56:51 UTC 
(rev 80349)
@@ -33,6 +33,7 @@
 
        internal delegate IntPtr CreateCustomXamlElementCallback (string xmlns, 
string name);
        internal delegate void SetCustomXamlAttributeCallback (IntPtr target, 
string name, string value);
+       internal delegate void XamlHookupEventCallback (IntPtr target, string 
name, string value);
        internal delegate void UnmanagedEventHandler (IntPtr data);
 
        internal static class NativeMethods {
@@ -116,6 +117,7 @@
                internal extern static IntPtr xaml_create_from_str (string 
xaml, bool create_namescope,
                                Mono.CreateCustomXamlElementCallback ccecb,
                                Mono.SetCustomXamlAttributeCallback scacb,
+                               Mono.XamlHookupEventCallback hue,
                                out Kind kind);
 
                [DllImport("moon")]

Modified: trunk/olive/class/agclr/System.Windows/ChangeLog
===================================================================
--- trunk/olive/class/agclr/System.Windows/ChangeLog    2007-06-20 18:55:56 UTC 
(rev 80348)
+++ trunk/olive/class/agclr/System.Windows/ChangeLog    2007-06-20 18:56:51 UTC 
(rev 80349)
@@ -1,5 +1,9 @@
 2007-06-20  Jackson Harper  <[EMAIL PROTECTED]>
 
+       * XamlReader.cs: Tie into events.
+
+2007-06-20  Jackson Harper  <[EMAIL PROTECTED]>
+
        * UIElement.cs: Invoke the loaded event.
 
 2007-06-20  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 

Modified: trunk/olive/class/agclr/System.Windows/XamlReader.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/XamlReader.cs        2007-06-20 
18:55:56 UTC (rev 80348)
+++ trunk/olive/class/agclr/System.Windows/XamlReader.cs        2007-06-20 
18:56:51 UTC (rev 80349)
@@ -40,6 +40,7 @@
        
                static CreateCustomXamlElementCallback custom_el_cb = new 
CreateCustomXamlElementCallback (create_element);
                static SetCustomXamlAttributeCallback custom_at_cb = new 
SetCustomXamlAttributeCallback (set_attribute);
+               static XamlHookupEventCallback hookup_event_cb = new 
XamlHookupEventCallback (hookup_event);
 
                public static DependencyObject Load (string xaml)
                {
@@ -52,7 +53,8 @@
                                throw new ArgumentNullException ("xaml");
 
                        Kind kind;
-                       IntPtr top = NativeMethods.xaml_create_from_str (xaml, 
createNamescope, custom_el_cb, custom_at_cb, out kind);
+                       IntPtr top = NativeMethods.xaml_create_from_str (xaml, 
createNamescope, custom_el_cb,
+                                       custom_at_cb, hookup_event_cb, out 
kind);
 
                        if (top == IntPtr.Zero)
                                return null;
@@ -131,6 +133,32 @@
                        pd.SetValue (target, pd.Converter.ConvertFrom (value));
                }
 
+               internal static void hookup_event (IntPtr target_ptr, string 
name, string value)
+               {
+                       MethodInfo m = typeof (DependencyObject).GetMethod 
("Lookup",
+                                       BindingFlags.Static | 
BindingFlags.NonPublic, null, new Type [] { typeof (IntPtr) }, null);
+                       DependencyObject target = (DependencyObject) m.Invoke 
(null, new object [] { target_ptr });
+
+                       if (target == null) {
+                               Console.WriteLine ("hookup event unable to 
create target object from: 0x{0}", target_ptr);
+                               return;
+                       }
+
+                       EventInfo src = target.GetType ().GetEvent (name);
+                       if (src == null) {
+                               Console.WriteLine ("hookup event unable to find 
event to hook to: '{0}'.", name);
+                               return;
+                       }
+
+                       Delegate d = Delegate.CreateDelegate 
(src.EventHandlerType, target, value);
+                       if (d == null) {
+                               Console.WriteLine ("hookup event unable to 
create delegate.");
+                               return;
+                       }
+
+                       src.AddEventHandler (target, d);
+               }
+
                internal static void ParseXmlns (string xmlns, out string 
type_name, out string ns, out string asm)
                {
                        type_name = null;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to