PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/VBSL3OOB/VBSL3OOB/MainPage.xaml.vb

#
Visual Basic | 70 lines | 31 code | 7 blank | 32 comment | 0 complexity | 5944fdc7424a83d4c78f572390901344 MD5 | raw file
  1. '****************************** Module Header ******************************'
  2. ' Module Name: MainPage.xaml.vb
  3. ' Project: VBSL3OOB
  4. ' Copyright (c) Microsoft Corporation.
  5. '
  6. ' This example demonstrates how to work with OOB using VB.
  7. '
  8. ' This source is subject to the Microsoft Public License.
  9. ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  10. ' All other rights reserved.
  11. '
  12. ' History:
  13. ' * 10/15/2009 16:21 Yilun Luo Created
  14. '***************************************************************************'
  15. Imports System.Net.NetworkInformation
  16. Partial Public Class MainPage
  17. Inherits UserControl
  18. Public Sub New()
  19. InitializeComponent()
  20. AddHandler Application.Current.CheckAndDownloadUpdateCompleted, New CheckAndDownloadUpdateCompletedEventHandler(AddressOf Me.Current_CheckAndDownloadUpdateCompleted)
  21. AddHandler NetworkChange.NetworkAddressChanged, New NetworkAddressChangedEventHandler(AddressOf Me.NetworkChange_NetworkAddressChanged)
  22. End Sub
  23. ''' <summary>
  24. ''' Check if an update is available.
  25. ''' </summary>
  26. ''' <param name="sender"></param>
  27. ''' <param name="e"></param>
  28. ''' <remarks></remarks>
  29. Private Sub CheckUpdateButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
  30. Application.Current.CheckAndDownloadUpdateAsync()
  31. End Sub
  32. Private Sub Current_CheckAndDownloadUpdateCompleted(ByVal sender As Object, ByVal e As CheckAndDownloadUpdateCompletedEventArgs)
  33. If e.UpdateAvailable Then
  34. MessageBox.Show("You have to upgrade this application to the latest version in order to use it. Restart this application to upgrade automatically!")
  35. End If
  36. End Sub
  37. ''' <summary>
  38. ''' Install OOB with code.
  39. ''' </summary>
  40. ''' <param name="sender"></param>
  41. ''' <param name="e"></param>
  42. ''' <remarks></remarks>
  43. Private Sub InstallButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
  44. If (Application.Current.InstallState = InstallState.NotInstalled) Then
  45. Application.Current.Install()
  46. ElseIf (Application.Current.InstallState = InstallState.Installed) Then
  47. MessageBox.Show("Application already installed. You cannot remove the OOB via code!")
  48. End If
  49. End Sub
  50. ''' <summary>
  51. ''' Detect the network connection changing.
  52. ''' </summary>
  53. ''' <param name="sender"></param>
  54. ''' <param name="e"></param>
  55. ''' <remarks></remarks>
  56. Private Sub NetworkChange_NetworkAddressChanged(ByVal sender As Object, ByVal e As EventArgs)
  57. If Not NetworkInterface.GetIsNetworkAvailable Then
  58. Me.informationTextBlock.Text = "Your network connection has been lost!"
  59. Else
  60. Me.informationTextBlock.Text = "Your network connection has been restored!"
  61. End If
  62. End Sub
  63. End Class