PageRenderTime 39ms CodeModel.GetById 26ms app.highlight 8ms RepoModel.GetById 2ms 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
16Imports System.Net.NetworkInformation
17
18Partial Public Class MainPage
19	Inherits UserControl
20
21	Public Sub New()
22		InitializeComponent()
23		AddHandler Application.Current.CheckAndDownloadUpdateCompleted, New CheckAndDownloadUpdateCompletedEventHandler(AddressOf Me.Current_CheckAndDownloadUpdateCompleted)
24		AddHandler NetworkChange.NetworkAddressChanged, New NetworkAddressChangedEventHandler(AddressOf Me.NetworkChange_NetworkAddressChanged)
25	End Sub
26
27	''' <summary>
28	''' Check if an update is available.
29	''' </summary>
30	''' <param name="sender"></param>
31	''' <param name="e"></param>
32	''' <remarks></remarks>
33	Private Sub CheckUpdateButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
34		Application.Current.CheckAndDownloadUpdateAsync()
35	End Sub
36
37	Private Sub Current_CheckAndDownloadUpdateCompleted(ByVal sender As Object, ByVal e As CheckAndDownloadUpdateCompletedEventArgs)
38		If e.UpdateAvailable Then
39			MessageBox.Show("You have to upgrade this application to the latest version in order to use it. Restart this application to upgrade automatically!")
40		End If
41	End Sub
42
43	''' <summary>
44	''' Install OOB with code.
45	''' </summary>
46	''' <param name="sender"></param>
47	''' <param name="e"></param>
48	''' <remarks></remarks>
49	Private Sub InstallButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
50		If (Application.Current.InstallState = InstallState.NotInstalled) Then
51			Application.Current.Install()
52		ElseIf (Application.Current.InstallState = InstallState.Installed) Then
53			MessageBox.Show("Application already installed. You cannot remove the OOB via code!")
54		End If
55	End Sub
56
57	''' <summary>
58	''' Detect the network connection changing.
59	''' </summary>
60	''' <param name="sender"></param>
61	''' <param name="e"></param>
62	''' <remarks></remarks>
63	Private Sub NetworkChange_NetworkAddressChanged(ByVal sender As Object, ByVal e As EventArgs)
64		If Not NetworkInterface.GetIsNetworkAvailable Then
65			Me.informationTextBlock.Text = "Your network connection has been lost!"
66		Else
67			Me.informationTextBlock.Text = "Your network connection has been restored!"
68		End If
69	End Sub
70End Class