Author: rolf
Date: 2007-10-10 04:01:12 -0400 (Wed, 10 Oct 2007)
New Revision: 87243

Modified:
   trunk/moon/gtk/ChangeLog
   trunk/moon/gtk/gtk.cs
Log:
2007-10-10  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>

        * gtk.cs: Use the XamlLoader in the LoadFile overload as well. 
        Set the surface of the domain for the XamlLoader.



Modified: trunk/moon/gtk/ChangeLog
===================================================================
--- trunk/moon/gtk/ChangeLog    2007-10-10 08:00:05 UTC (rev 87242)
+++ trunk/moon/gtk/ChangeLog    2007-10-10 08:01:12 UTC (rev 87243)
@@ -1,3 +1,8 @@
+2007-10-10  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
+
+       * gtk.cs: Use the XamlLoader in the LoadFile overload as well. 
+       Set the surface of the domain for the XamlLoader.
+
 2007-10-09  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
 
        * gtk.cs: Use the XamlLoader in agclr.

Modified: trunk/moon/gtk/gtk.cs
===================================================================
--- trunk/moon/gtk/gtk.cs       2007-10-10 08:00:05 UTC (rev 87242)
+++ trunk/moon/gtk/gtk.cs       2007-10-10 08:01:12 UTC (rev 87243)
@@ -111,11 +111,12 @@
        ///
        ///    <para>The widget is initially empty, you must call the <see 
cref="Attach"/>
        ///    method with a System.Windows.Controls.Canvas instance (you can 
create
-       ///    those programatically, using XAML, or using the <see 
cref="LoadFile"/> method).</para>
+       ///    those programatically, using XAML, or using the <see 
cref="LoadFile(System.String)"/> method).</para>
        /// </remarks>
        public GtkSilver (int width, int height)
        {
                surface = NativeMethods.surface_new (width, height);
+               Mono.Xaml.XamlLoader.SurfaceInDomain = surface;
                Raw = NativeMethods.surface_get_drawing_area (surface);
        }
 
@@ -207,34 +208,31 @@
        ///    Initializes the GtkSilver widget from the XAML contents in a file
        /// </summary>
        /// <param name="file">The name of a file in your file system.</param>
+       /// <param name="canvas">The created canvas, if the creation of the 
xaml string was successful.</param>
        /// <remarks>
        ///   This uses the XAML parser to load the given file and display it 
on 
        ///   the GtkSilver widget.
        /// </remarks>
-       public bool LoadFile (string file)
+       public bool LoadFile (string file, out Canvas canvas)
        {
                if (file == null)
                        throw new ArgumentNullException ("file");
 
-               Mono.Kind k;
-               
-               IntPtr loader = NativeMethods.xaml_loader_new (file, null, 
surface);
-               IntPtr x = NativeMethods.xaml_create_from_file (loader, file, 
true, out k);
-               NativeMethods.xaml_loader_free (loader);
+               return LoadXaml (System.IO.File.ReadAllText (file), out canvas);
+       }
 
-               if (x == IntPtr.Zero)
-                       return false;
-
-               // TODO: Check that x is a Canvas
-
-               MethodInfo m = typeof (Canvas).GetMethod ("FromPtr", 
BindingFlags.Static | BindingFlags.NonPublic);
-               Canvas c = (Canvas) m.Invoke (null, new object [] { x });
-               if (c == null)
-                       return false;
-               
-               Attach (c);
-               
-               return true;
+       /// <summary>
+       ///    Initializes the GtkSilver widget from the XAML contents in a file
+       /// </summary>
+       /// <param name="file">The name of a file in your file system.</param>
+       /// <remarks>
+       ///   This uses the XAML parser to load the given file and display it 
on 
+       ///   the GtkSilver widget.
+       /// </remarks>
+       public bool LoadFile (string file)
+       {
+               Canvas canvas;
+               return LoadFile (file, out canvas);
        }
 }
 }

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

Reply via email to