Author: miguel
Date: 2007-07-20 18:49:31 -0400 (Fri, 20 Jul 2007)
New Revision: 82394

Modified:
   
trunk/olive/class/System.Silverlight/System.Windows.Browser/BrowserRuntimeSettings.cs
   trunk/olive/class/System.Silverlight/System.Windows.Browser/ChangeLog
   trunk/olive/class/System.Silverlight/System.Windows.Browser/HtmlTimer.cs
Log:
2007-07-20  Miguel de Icaza  <[EMAIL PROTECTED]>

        * HtmlTimer.cs: Implement.



Modified: 
trunk/olive/class/System.Silverlight/System.Windows.Browser/BrowserRuntimeSettings.cs
===================================================================
--- 
trunk/olive/class/System.Silverlight/System.Windows.Browser/BrowserRuntimeSettings.cs
       2007-07-20 22:48:49 UTC (rev 82393)
+++ 
trunk/olive/class/System.Silverlight/System.Windows.Browser/BrowserRuntimeSettings.cs
       2007-07-20 22:49:31 UTC (rev 82394)
@@ -1,3 +1,30 @@
+//
+// System.Windows.Browser.BrowserInformation class
+//
+// Authors:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 using System;
 using System.Globalization;
 using System.Runtime.InteropServices;

Modified: trunk/olive/class/System.Silverlight/System.Windows.Browser/ChangeLog
===================================================================
--- trunk/olive/class/System.Silverlight/System.Windows.Browser/ChangeLog       
2007-07-20 22:48:49 UTC (rev 82393)
+++ trunk/olive/class/System.Silverlight/System.Windows.Browser/ChangeLog       
2007-07-20 22:49:31 UTC (rev 82394)
@@ -1,3 +1,7 @@
+2007-07-20  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * HtmlTimer.cs: Implement.
+
 2007-07-16  Chris Toshok  <[EMAIL PROTECTED]>
 
        * HtmlObject.cs: track WebApplication's Instance -> PluginHandle

Modified: 
trunk/olive/class/System.Silverlight/System.Windows.Browser/HtmlTimer.cs
===================================================================
--- trunk/olive/class/System.Silverlight/System.Windows.Browser/HtmlTimer.cs    
2007-07-20 22:48:49 UTC (rev 82393)
+++ trunk/olive/class/System.Silverlight/System.Windows.Browser/HtmlTimer.cs    
2007-07-20 22:49:31 UTC (rev 82394)
@@ -1,49 +1,119 @@
+//
+// System.Windows.Browser.HtmLTimer class
+//
+// Authors:
+//     Miguel de Icaza  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 using System;
+using Mono;
 
 namespace System.Windows.Browser
 {
        public class HtmlTimer
        {
+               
+               uint source_id;
+               NativeMethods.GSourceFunc callback;
+               
                public HtmlTimer ()
                {
                }
 
                [MonoTODO]
                public bool Enabled {
-                       set { /* nothing yet*/ }
-                       get { return false; }
+                       set {
+                               if (value)
+                                       Start ();
+                               else
+                                       Stop ();
+                       }
+                       
+                       get {
+                               return source_id != 0;
+                       }
                }
 
                int interval;
-               [MonoTODO]
                public int Interval {
-                       set { interval = value; }
-                       get { return interval; }
+                       set {
+                               if (value < 1)
+                                       throw new ArgumentOutOfRangeException 
("value");
+
+                               interval = value;
+                               if (source_id != 0){
+                                       Stop ();
+                                       Start ();
+                               }
+                       }
+
+                       get {
+                               return interval;
+                       }
                }
 
-               [MonoTODO]
+               bool timer_callback (IntPtr data)
+               {
+                       OnTick (EventArgs.Empty);
+
+                       // If we are killed by Enabled or Stop, still return 
that value
+                       return source_id != 0;
+               }
+               
                public void Start ()
                {
+                       if (source_id != 0)
+                               return;
+
+                       callback = new NativeMethods.GSourceFunc 
(timer_callback);
+                       source_id = NativeMethods.html_timer_timeout_add 
(interval, callback, IntPtr.Zero);
                }
 
-               [MonoTODO]
                public void Stop ()
                {
+                       if (source_id == 0)
+                               return;
+
+                       NativeMethods.html_timer_timeout_stop (source_id);
+                       source_id = 0;
+                       callback = null;
                }
 
-               [MonoTODO]
                public override string ToString ()
                {
-                       return base.ToString ();
+                       return String.Format ("Enabled: {0}, Interval: {1}", 
Enabled, Interval);
                }
 
                protected virtual void OnTick (EventArgs e)
                {
+                       // Keep a reference, in case the callback changes the 
source.
+                       NativeMethods.GSourceFunc my_callback = callback;
+
                        if (Tick != null)
                                Tick (this, e);
+                       
                }
 
-               [MonoTODO]
                public event EventHandler Tick;
        }
 }

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

Reply via email to