/[RomCheater]/trunk/RomCheater.Core/IWebBrowserProvider.cs
ViewVC logotype

Diff of /trunk/RomCheater.Core/IWebBrowserProvider.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.Core/IWebBrowserProvider.cs	2013/06/17 11:47:23	696
+++ trunk/RomCheater.Core/IWebBrowserProvider.cs	2013/06/17 12:03:50	697
@@ -3,6 +3,7 @@
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using RomCheater.Logging;
 
 namespace RomCheater.Core
 {
@@ -11,35 +12,11 @@
         IWebBrowserInterface GetProvider();
     }
     public interface IWebBrowserInterface
-    {
-        //WebBrowser Provider { get; }
+    {        
         void Navigate(string urlString);    
         void Navigate(Uri url);
-        //void Navigate(string urlString, bool newWindow);
-        //void Navigate(string urlString, string targetFrameName);
-        //void Navigate(Uri url, bool newWindow);
-        //void Navigate(Uri url, string targetFrameName);        
-        //void Navigate(string urlString, string targetFrameName, byte[] postData, string additionalHeaders);
-        //void Navigate(Uri url, string targetFrameName, byte[] postData, string additionalHeaders);
-
     }
 
-    //public class WebBrowserProvider : IWebBrowserProvider
-    //{
-    //    public WebBrowserProvider(IWebBrowserInterface provider)
-    //    {
-    //        _provider = provider;
-    //    }
-
-    //    #region IWebBrowserProvider Members
-    //    private IWebBrowserInterface _provider;
-    //    public IWebBrowserInterface GetProvider()
-    //    {
-    //        return _provider;
-    //    }
-    //    #endregion
-    //}
-
     public class EmptyWebBrowserProvider : BaseWebBrowserProvider, IWebBrowserInterface
     {
         public EmptyWebBrowserProvider() :base()
@@ -70,14 +47,24 @@
         public WebBrowser Provider { get { return _Provider; } protected set { _Provider = value; } }
 
         #region Extensions to WebBrowser provider
-        public void Navigate(string urlString) { this.Provider.Navigate(urlString); }
-        public void Navigate(Uri url) { this.Provider.Navigate(url); }
-        //public void Navigate(string urlString, bool newWindow) { this.Provider.Navigate(urlString, newWindow); }
-        //public void Navigate(string urlString, string targetFrameName) { this.Provider.Navigate(urlString, targetFrameName); }
-        //public void Navigate(Uri url, bool newWindow) { this.Provider.Navigate(url, newWindow); }
-        //public void Navigate(Uri url, string targetFrameName) { this.Provider.Navigate(url, targetFrameName); }
-        //public void Navigate(string urlString, string targetFrameName, byte[] postData, string additionalHeaders) { this.Provider.Navigate(urlString, targetFrameName, postData, additionalHeaders); }
-        //public void Navigate(Uri url, string targetFrameName, byte[] postData, string additionalHeaders) { this.Provider.Navigate(url, targetFrameName, postData, additionalHeaders); }
+        public void Navigate(string urlString) { NavigateInternal(urlString); }
+        public void Navigate(Uri url) { NavigateInternal(url.ToString()); }
+
+        private void NavigateInternal(string url)
+        {
+            try
+            {
+                Uri uri = new Uri(url);
+                this.Provider.Navigate(uri);
+            }
+            catch (UriFormatException ex)
+            {
+                MessageBox.Show(string.Format("Could not navigate to url: '{0}'", url), string.Format("A Uri Format Exception Occurred in '{0}'", this.GetType().Name), MessageBoxButtons.OK, MessageBoxIcon.Error);
+                logger.Error.WriteLine("Unable to navigate to url: '{0}'", url);
+                logger.VerboseError.WriteLine(ex.ToString());
+            }
+        }
+
         #endregion
         #endregion
 

 

  ViewVC Help
Powered by ViewVC 1.1.22