Guest User

Untitled

a guest
May 21st, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. {
  2. webBrowser1.Navigating += new EventHandler<NavigatingEventArgs>(webBrowser1_Navigating);
  3. }
  4.  
  5. void webBrowser1_Navigating(object sender, NavigatingEventArgs e)
  6. {
  7. string scheme = null;
  8.  
  9. try
  10. {
  11. scheme = e.Uri.Scheme; // <- this is throwing an exception here
  12. }
  13. catch
  14. {
  15. }
  16. if (scheme == null || scheme == "file")
  17. return;
  18. // Not going to follow any other link
  19. e.Cancel = true;
  20. if (scheme == "shared")
  21. {
  22.  
  23. }
  24.  
  25. void webBrowser1_Navigating(object sender, NavigatingEventArgs e)
  26. {
  27. String scheme = null;
  28.  
  29. try
  30. {
  31. scheme = e.Uri.Scheme;
  32. }
  33. catch
  34. {
  35. }
  36. if (scheme == null || scheme == "file")
  37. return;
  38. // Not going to follow any other link
  39. e.Cancel = true;
  40. if (scheme == "http")
  41. {
  42. // Check if it's the "shared" URL
  43. if (e.Uri.Host == "shared")
  44. {
  45. // Start email
  46. EmailComposeTask emailComposeTask = new EmailComposeTask();
  47. emailComposeTask.Subject = "Sharing an app with you";
  48. emailComposeTask.Body = "You may like this app...";
  49. emailComposeTask.Show();
  50. }
  51. else
  52. {
  53. // start it in Internet Explorer
  54. WebBrowserTask webBrowserTask = new WebBrowserTask();
  55. webBrowserTask.Uri = new Uri(e.Uri.AbsoluteUri);
  56. webBrowserTask.Show();
  57. }
  58. }
  59. if (scheme == "mailto")
  60. {
  61. EmailComposeTask emailComposeTask = new EmailComposeTask();
  62. emailComposeTask.To = e.Uri.AbsoluteUri;
  63. emailComposeTask.Show();
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment