1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| Private Sub stck_ud_MouseLeftButtonDown(sender As System.Object, e As System.Windows.Input.MouseButtonEventArgs) Handles stck_ud.MouseLeftButtonDown
Mouse.OverrideCursor = Cursors.Wait
Dim downloadUrl As String = ""
Dim newVersion As Version = Nothing
Dim xmlUrl As String = "http://url.com/dossier/updates.xml"
Dim reader As XmlTextReader = Nothing
Try
reader = New XmlTextReader(xmlUrl)
reader.MoveToContent()
Dim elementName As String = ""
If (reader.NodeType = XmlNodeType.Element) AndAlso (reader.Name = "soft") Then
While reader.Read()
If reader.NodeType = XmlNodeType.Element Then
elementName = reader.Name
Else
If (reader.NodeType = XmlNodeType.Text) AndAlso (reader.HasValue) Then
Select Case elementName
Case "version"
newVersion = New Version(reader.Value)
Exit Select
Case "url"
downloadUrl = reader.Value
Exit Select
End Select
End If
End If
End While
End If
Catch ex As Exception
Finally
If reader IsNot Nothing Then
reader.Close()
End If
End Try
Dim applicationVersion As Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
Dim cd As System.Deployment.Application.ApplicationDeployment = System.Deployment.Application.ApplicationDeployment.CurrentDeployment
Dim publishVersion As Version = cd.CurrentVersion
applicationVersion = publishVersion
End If
Mouse.OverrideCursor = Nothing
If applicationVersion.CompareTo(newVersion) < 0 Then
Dim ans As MessageBoxResult = MessageBox.Show("Màj dispo blablabla", "Blablabla", MessageBoxButton.YesNo, MessageBoxImage.Question)
If ans = MessageBoxResult.Yes Then
System.Diagnostics.Process.Start(downloadUrl)
End If
Else
MessageBox.Show("Soft à jour", "Blablabla", MessageBoxButton.OK, MessageBoxImage.Information)
End If
End Sub |