Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f5f267e61 | |||
| bde9fb4b41 | |||
| b42242540a | |||
| 755da5e9b9 | |||
| a1e50d20c5 | |||
| 1c4b41d474 |
Generated
+23
-5
@@ -22,6 +22,7 @@ Partial Class Form1
|
|||||||
'Do not modify it using the code editor.
|
'Do not modify it using the code editor.
|
||||||
<System.Diagnostics.DebuggerStepThrough()>
|
<System.Diagnostics.DebuggerStepThrough()>
|
||||||
Private Sub InitializeComponent()
|
Private Sub InitializeComponent()
|
||||||
|
Me.components = New System.ComponentModel.Container()
|
||||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
|
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
|
||||||
Me.btnClickThis = New System.Windows.Forms.Button()
|
Me.btnClickThis = New System.Windows.Forms.Button()
|
||||||
Me.lblHelloWorld = New System.Windows.Forms.Label()
|
Me.lblHelloWorld = New System.Windows.Forms.Label()
|
||||||
@@ -34,12 +35,14 @@ Partial Class Form1
|
|||||||
Me.btnDHLShipping = New System.Windows.Forms.Button()
|
Me.btnDHLShipping = New System.Windows.Forms.Button()
|
||||||
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
|
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
|
||||||
Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
|
Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
|
||||||
|
Me.lblCoppiedNotifyer = New System.Windows.Forms.Label()
|
||||||
|
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
|
||||||
Me.MenuStrip1.SuspendLayout()
|
Me.MenuStrip1.SuspendLayout()
|
||||||
Me.SuspendLayout()
|
Me.SuspendLayout()
|
||||||
'
|
'
|
||||||
'btnClickThis
|
'btnClickThis
|
||||||
'
|
'
|
||||||
Me.btnClickThis.Location = New System.Drawing.Point(12, 148)
|
Me.btnClickThis.Location = New System.Drawing.Point(11, 203)
|
||||||
Me.btnClickThis.Name = "btnClickThis"
|
Me.btnClickThis.Name = "btnClickThis"
|
||||||
Me.btnClickThis.Size = New System.Drawing.Size(138, 23)
|
Me.btnClickThis.Size = New System.Drawing.Size(138, 23)
|
||||||
Me.btnClickThis.TabIndex = 0
|
Me.btnClickThis.TabIndex = 0
|
||||||
@@ -49,7 +52,7 @@ Partial Class Form1
|
|||||||
'lblHelloWorld
|
'lblHelloWorld
|
||||||
'
|
'
|
||||||
Me.lblHelloWorld.AutoSize = True
|
Me.lblHelloWorld.AutoSize = True
|
||||||
Me.lblHelloWorld.Location = New System.Drawing.Point(9, 101)
|
Me.lblHelloWorld.Location = New System.Drawing.Point(8, 161)
|
||||||
Me.lblHelloWorld.Name = "lblHelloWorld"
|
Me.lblHelloWorld.Name = "lblHelloWorld"
|
||||||
Me.lblHelloWorld.Size = New System.Drawing.Size(99, 13)
|
Me.lblHelloWorld.Size = New System.Drawing.Size(99, 13)
|
||||||
Me.lblHelloWorld.TabIndex = 1
|
Me.lblHelloWorld.TabIndex = 1
|
||||||
@@ -57,7 +60,7 @@ Partial Class Form1
|
|||||||
'
|
'
|
||||||
'txtFinalUrl
|
'txtFinalUrl
|
||||||
'
|
'
|
||||||
Me.txtFinalUrl.Location = New System.Drawing.Point(12, 121)
|
Me.txtFinalUrl.Location = New System.Drawing.Point(12, 177)
|
||||||
Me.txtFinalUrl.Name = "txtFinalUrl"
|
Me.txtFinalUrl.Name = "txtFinalUrl"
|
||||||
Me.txtFinalUrl.ReadOnly = True
|
Me.txtFinalUrl.ReadOnly = True
|
||||||
Me.txtFinalUrl.Size = New System.Drawing.Size(652, 20)
|
Me.txtFinalUrl.Size = New System.Drawing.Size(652, 20)
|
||||||
@@ -120,7 +123,7 @@ Partial Class Form1
|
|||||||
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AboutToolStripMenuItem})
|
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AboutToolStripMenuItem})
|
||||||
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
|
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
|
||||||
Me.MenuStrip1.Name = "MenuStrip1"
|
Me.MenuStrip1.Name = "MenuStrip1"
|
||||||
Me.MenuStrip1.Size = New System.Drawing.Size(687, 24)
|
Me.MenuStrip1.Size = New System.Drawing.Size(587, 24)
|
||||||
Me.MenuStrip1.TabIndex = 13
|
Me.MenuStrip1.TabIndex = 13
|
||||||
Me.MenuStrip1.Text = "MenuStrip1"
|
Me.MenuStrip1.Text = "MenuStrip1"
|
||||||
'
|
'
|
||||||
@@ -130,11 +133,24 @@ Partial Class Form1
|
|||||||
Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(52, 20)
|
Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(52, 20)
|
||||||
Me.AboutToolStripMenuItem.Text = "About"
|
Me.AboutToolStripMenuItem.Text = "About"
|
||||||
'
|
'
|
||||||
|
'lblCoppiedNotifyer
|
||||||
|
'
|
||||||
|
Me.lblCoppiedNotifyer.AutoSize = True
|
||||||
|
Me.lblCoppiedNotifyer.Location = New System.Drawing.Point(13, 100)
|
||||||
|
Me.lblCoppiedNotifyer.Name = "lblCoppiedNotifyer"
|
||||||
|
Me.lblCoppiedNotifyer.Size = New System.Drawing.Size(92, 13)
|
||||||
|
Me.lblCoppiedNotifyer.TabIndex = 14
|
||||||
|
Me.lblCoppiedNotifyer.Text = "lblCoppiedNotifyer"
|
||||||
|
'
|
||||||
|
'Timer1
|
||||||
|
'
|
||||||
|
'
|
||||||
'Form1
|
'Form1
|
||||||
'
|
'
|
||||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||||
Me.ClientSize = New System.Drawing.Size(687, 181)
|
Me.ClientSize = New System.Drawing.Size(587, 122)
|
||||||
|
Me.Controls.Add(Me.lblCoppiedNotifyer)
|
||||||
Me.Controls.Add(Me.btnDHLShipping)
|
Me.Controls.Add(Me.btnDHLShipping)
|
||||||
Me.Controls.Add(Me.btnFedexShipping)
|
Me.Controls.Add(Me.btnFedexShipping)
|
||||||
Me.Controls.Add(Me.Button1)
|
Me.Controls.Add(Me.Button1)
|
||||||
@@ -168,4 +184,6 @@ Partial Class Form1
|
|||||||
Friend WithEvents btnDHLShipping As Button
|
Friend WithEvents btnDHLShipping As Button
|
||||||
Friend WithEvents MenuStrip1 As MenuStrip
|
Friend WithEvents MenuStrip1 As MenuStrip
|
||||||
Friend WithEvents AboutToolStripMenuItem As ToolStripMenuItem
|
Friend WithEvents AboutToolStripMenuItem As ToolStripMenuItem
|
||||||
|
Friend WithEvents lblCoppiedNotifyer As Label
|
||||||
|
Friend WithEvents Timer1 As Timer
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -120,6 +120,9 @@
|
|||||||
<metadata name="MenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="MenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="Timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>132, 17</value>
|
||||||
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|||||||
+25
-13
@@ -1,20 +1,16 @@
|
|||||||
|
|
||||||
|
Imports System.Media
|
||||||
Imports System.Net
|
Imports System.Net
|
||||||
Imports System.Net.Http
|
Imports System.Net.Http
|
||||||
Imports System.Security.Cryptography.X509Certificates
|
Imports System.Security.Cryptography.X509Certificates
|
||||||
Imports System.Text
|
Imports System.Text
|
||||||
Imports System.Media
|
|
||||||
|
|
||||||
|
|
||||||
Public Class Form1
|
Public Class Form1
|
||||||
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles btnClickThis.Click
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
||||||
My.Computer.Clipboard.SetText(txtFinalUrl.Text)
|
lblCoppiedNotifyer.Text = ""
|
||||||
Using player As New SoundPlayer(My.Resources.WindowsXPCriticalStop)
|
Timer1.Stop()
|
||||||
player.Play()
|
|
||||||
End Using
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Private Sub btnEditBaseUrl_Click(sender As Object, e As EventArgs) Handles btnEditBaseUrl.Click
|
Private Sub btnEditBaseUrl_Click(sender As Object, e As EventArgs) Handles btnEditBaseUrl.Click
|
||||||
Dim rawRMA As String
|
Dim rawRMA As String
|
||||||
rawRMA = txtRMA.Text
|
rawRMA = txtRMA.Text
|
||||||
@@ -22,6 +18,10 @@ Public Class Form1
|
|||||||
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
||||||
|
|
||||||
txtFinalUrl.Text = "https://www.tnt.com/express/en_au/site/shipping-tools/tracking.html?searchType=ref&cons=" & encodedRMA
|
txtFinalUrl.Text = "https://www.tnt.com/express/en_au/site/shipping-tools/tracking.html?searchType=ref&cons=" & encodedRMA
|
||||||
|
My.Computer.Clipboard.SetText(txtFinalUrl.Text)
|
||||||
|
lblCoppiedNotifyer.Text = "Copied!"
|
||||||
|
Timer1.Interval = 5000
|
||||||
|
Timer1.Start()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
|
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
|
||||||
@@ -31,6 +31,10 @@ Public Class Form1
|
|||||||
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
||||||
|
|
||||||
txtFinalUrl.Text = "https://www.tnt.com/express/en_au/site/shipping-tools/tracking.html?searchType=con&cons=" & encodedRMA
|
txtFinalUrl.Text = "https://www.tnt.com/express/en_au/site/shipping-tools/tracking.html?searchType=con&cons=" & encodedRMA
|
||||||
|
My.Computer.Clipboard.SetText(txtFinalUrl.Text)
|
||||||
|
lblCoppiedNotifyer.Text = "Copied!"
|
||||||
|
Timer1.Interval = 5000
|
||||||
|
Timer1.Start()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnFedexShipping_Click(sender As Object, e As EventArgs) Handles btnFedexShipping.Click
|
Private Sub btnFedexShipping_Click(sender As Object, e As EventArgs) Handles btnFedexShipping.Click
|
||||||
@@ -39,7 +43,11 @@ Public Class Form1
|
|||||||
|
|
||||||
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
||||||
|
|
||||||
txtFinalUrl.Text = "https://www.fedex.com/fedextrack/?trknbr=" & encodedRMA
|
txtFinalUrl.Text = "https://www.fedex.com/apps/fedextrack/?tracknumbers=" & encodedRMA
|
||||||
|
My.Computer.Clipboard.SetText(txtFinalUrl.Text)
|
||||||
|
lblCoppiedNotifyer.Text = "Copied!"
|
||||||
|
Timer1.Interval = 5000
|
||||||
|
Timer1.Start()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnDHLShipping.Click
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnDHLShipping.Click
|
||||||
@@ -49,15 +57,19 @@ Public Class Form1
|
|||||||
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
Dim encodedRMA As String = Uri.EscapeDataString(rawRMA)
|
||||||
|
|
||||||
txtFinalUrl.Text = "https://www.dhl.com/au-en/home/tracking/tracking-express.html?submit=1&tracking-id=" & encodedRMA
|
txtFinalUrl.Text = "https://www.dhl.com/au-en/home/tracking/tracking-express.html?submit=1&tracking-id=" & encodedRMA
|
||||||
End Sub
|
My.Computer.Clipboard.SetText(txtFinalUrl.Text)
|
||||||
|
lblCoppiedNotifyer.Text = "Copied!"
|
||||||
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
|
Timer1.Interval = 5000
|
||||||
|
Timer1.Start()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
|
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
|
||||||
Dim box = New Form3()
|
Dim box = New Form3()
|
||||||
box.Show()
|
box.Show()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
|
lblCoppiedNotifyer.Text = ""
|
||||||
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
Generated
+15
-4
@@ -24,25 +24,35 @@ Partial Class Form3
|
|||||||
Private Sub InitializeComponent()
|
Private Sub InitializeComponent()
|
||||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form3))
|
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form3))
|
||||||
Me.Label1 = New System.Windows.Forms.Label()
|
Me.Label1 = New System.Windows.Forms.Label()
|
||||||
|
Me.btnUpdates = New System.Windows.Forms.Button()
|
||||||
Me.SuspendLayout()
|
Me.SuspendLayout()
|
||||||
'
|
'
|
||||||
'Label1
|
'Label1
|
||||||
'
|
'
|
||||||
Me.Label1.AutoSize = True
|
Me.Label1.AutoSize = True
|
||||||
Me.Label1.Cursor = System.Windows.Forms.Cursors.WaitCursor
|
Me.Label1.Cursor = System.Windows.Forms.Cursors.Arrow
|
||||||
Me.Label1.Location = New System.Drawing.Point(12, 9)
|
Me.Label1.Location = New System.Drawing.Point(12, 9)
|
||||||
Me.Label1.Name = "Label1"
|
Me.Label1.Name = "Label1"
|
||||||
Me.Label1.Size = New System.Drawing.Size(222, 39)
|
Me.Label1.Size = New System.Drawing.Size(222, 39)
|
||||||
Me.Label1.TabIndex = 1
|
Me.Label1.TabIndex = 1
|
||||||
Me.Label1.Text = "Verson 1.0.5.3 " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Made by Ben Nicholson - All Rights Reserved" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
|
Me.Label1.Text = "Verson 1.1.0.0 " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Made by Ben Nicholson - All Rights Reserved" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
|
||||||
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
|
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
|
||||||
Me.Label1.UseWaitCursor = True
|
'
|
||||||
|
'btnUpdates
|
||||||
|
'
|
||||||
|
Me.btnUpdates.Location = New System.Drawing.Point(87, 66)
|
||||||
|
Me.btnUpdates.Name = "btnUpdates"
|
||||||
|
Me.btnUpdates.Size = New System.Drawing.Size(75, 23)
|
||||||
|
Me.btnUpdates.TabIndex = 2
|
||||||
|
Me.btnUpdates.Text = "Updates"
|
||||||
|
Me.btnUpdates.UseVisualStyleBackColor = True
|
||||||
'
|
'
|
||||||
'Form3
|
'Form3
|
||||||
'
|
'
|
||||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||||
Me.ClientSize = New System.Drawing.Size(246, 60)
|
Me.ClientSize = New System.Drawing.Size(246, 101)
|
||||||
|
Me.Controls.Add(Me.btnUpdates)
|
||||||
Me.Controls.Add(Me.Label1)
|
Me.Controls.Add(Me.Label1)
|
||||||
Me.ForeColor = System.Drawing.Color.Black
|
Me.ForeColor = System.Drawing.Color.Black
|
||||||
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
|
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
|
||||||
@@ -58,4 +68,5 @@ Partial Class Form3
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Friend WithEvents Label1 As Label
|
Friend WithEvents Label1 As Label
|
||||||
|
Friend WithEvents btnUpdates As Button
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -117,9 +117,6 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,11 @@
|
|||||||
Public Class Form3
|
Public Class Form3
|
||||||
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnUpdates.Click
|
||||||
|
Dim webAddress As String = "https://gitea.apointless.space/bsncubed/ShippingTracker/releases"
|
||||||
|
Process.Start(webAddress)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Public Class About
|
|
||||||
|
|
||||||
End Class
|
|
||||||
@@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
|
|||||||
<Assembly: AssemblyTitle("Shipping Tracker")>
|
<Assembly: AssemblyTitle("Shipping Tracker")>
|
||||||
<Assembly: AssemblyDescription("")>
|
<Assembly: AssemblyDescription("")>
|
||||||
<Assembly: AssemblyCompany("")>
|
<Assembly: AssemblyCompany("")>
|
||||||
<Assembly: AssemblyProduct("TNT Tracking Link Creator")>
|
<Assembly: AssemblyProduct("Shipping Tracker")>
|
||||||
<Assembly: AssemblyCopyright("Copyright © 2025 Ben Nicholson")>
|
<Assembly: AssemblyCopyright("Copyright © 2025 Ben Nicholson")>
|
||||||
<Assembly: AssemblyTrademark("")>
|
<Assembly: AssemblyTrademark("")>
|
||||||
|
|
||||||
@@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
|
|||||||
' by using the '*' as shown below:
|
' by using the '*' as shown below:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.0.5.3")>
|
<Assembly: AssemblyVersion("1.1.0.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.0.5.3")>
|
<Assembly: AssemblyFileVersion("1.1.0.0")>
|
||||||
<Assembly: NeutralResourcesLanguage("en-AU")>
|
<Assembly: NeutralResourcesLanguage("en-AU")>
|
||||||
|
|||||||
-9
@@ -59,14 +59,5 @@ Namespace My.Resources
|
|||||||
resourceCulture = value
|
resourceCulture = value
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream.
|
|
||||||
'''</summary>
|
|
||||||
Friend ReadOnly Property WindowsXPCriticalStop() As System.IO.UnmanagedMemoryStream
|
|
||||||
Get
|
|
||||||
Return ResourceManager.GetStream("WindowsXPCriticalStop", resourceCulture)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
End Module
|
End Module
|
||||||
End Namespace
|
End Namespace
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
<data name="WindowsXPCriticalStop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<!-- <data name="WindowsXPCriticalStop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\WindowsXPCriticalStop.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>..\WindowsXPCriticalStop.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data> -->
|
||||||
</root>
|
</root>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<PublishUrl>C:\Users\Ben\Desktop\</PublishUrl>
|
<PublishUrl>C:\Users\Ben\Desktop\Shipping\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
<UpdateEnabled>false</UpdateEnabled>
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<AutorunEnabled>true</AutorunEnabled>
|
<AutorunEnabled>true</AutorunEnabled>
|
||||||
<ApplicationRevision>3</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.5.%2a</ApplicationVersion>
|
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
@@ -228,7 +228,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="TNT.ico" />
|
<Content Include="TNT.ico" />
|
||||||
<None Include="WindowsXPCriticalStop.wav" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||||
|
|||||||
@@ -0,0 +1,502 @@
|
|||||||
|
Imports System.Collections.Generic
|
||||||
|
Imports System.IO
|
||||||
|
Imports System.Net.Http
|
||||||
|
Imports System.Security.Cryptography
|
||||||
|
Imports System.Web.Script.Serialization
|
||||||
|
Imports System.Windows.Forms
|
||||||
|
|
||||||
|
' ---------------------------------------------------------------------------
|
||||||
|
' Updater.vb - self-update for Shipping Tracker
|
||||||
|
'
|
||||||
|
' Requires a project reference to: System.Web.Extensions (for JavaScriptSerializer)
|
||||||
|
' Everything else is in the framework already.
|
||||||
|
'
|
||||||
|
' Wire-up (see notes at bottom of file):
|
||||||
|
' Form1_Load -> Updater.CleanupOldBinary() + Await Updater.CheckForUpdatesAsync(True)
|
||||||
|
' Form3 btnUpdates -> Await Updater.CheckForUpdatesAsync(False)
|
||||||
|
' ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Public Module Updater
|
||||||
|
|
||||||
|
' --- configuration -----------------------------------------------------
|
||||||
|
|
||||||
|
Private Const ApiLatest As String =
|
||||||
|
"https://gitea.apointless.space/api/v1/repos/bsncubed/ShippingTracker/releases/latest"
|
||||||
|
|
||||||
|
Private Const ReleasesPage As String =
|
||||||
|
"https://gitea.apointless.space/bsncubed/ShippingTracker/releases"
|
||||||
|
|
||||||
|
' Name of the .exe asset attached to each release. Must match exactly.
|
||||||
|
Private Const AssetName As String = "Shipping Tracker.exe"
|
||||||
|
|
||||||
|
' Name of the checksum asset. sha256sum format: "<hash> <filename>" per line.
|
||||||
|
Private Const ChecksumAssetName As String = "checksums.txt"
|
||||||
|
|
||||||
|
Private ReadOnly Http As New HttpClient() With {.Timeout = TimeSpan.FromSeconds(10)}
|
||||||
|
|
||||||
|
' --- public entry points -----------------------------------------------
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Checks for a newer release and offers to install it.
|
||||||
|
''' silent = True -> startup check. Any failure (offline, DNS, timeout,
|
||||||
|
''' bad response) returns quietly with no UI at all.
|
||||||
|
''' silent = False -> user clicked "Check for updates". Reports
|
||||||
|
''' "up to date" and surfaces errors.
|
||||||
|
''' </summary>
|
||||||
|
Public Async Function CheckForUpdatesAsync(silent As Boolean) As Task
|
||||||
|
|
||||||
|
Dim rel As ReleaseInfo = Nothing
|
||||||
|
|
||||||
|
Try
|
||||||
|
rel = Await FetchLatestReleaseAsync()
|
||||||
|
Catch ex As Exception
|
||||||
|
' Offline / DNS failure / timeout / non-200 / malformed JSON.
|
||||||
|
If Not silent Then
|
||||||
|
MessageBox.Show("Could not check for updates:" & vbCrLf & vbCrLf & ex.Message,
|
||||||
|
"Shipping Tracker", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||||
|
End If
|
||||||
|
Return
|
||||||
|
End Try
|
||||||
|
|
||||||
|
If rel Is Nothing OrElse rel.Version Is Nothing Then
|
||||||
|
If Not silent Then
|
||||||
|
MessageBox.Show("Could not read the latest version number.",
|
||||||
|
"Shipping Tracker", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||||
|
End If
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim current As Version = Normalise(My.Application.Info.Version)
|
||||||
|
|
||||||
|
If rel.Version <= current Then
|
||||||
|
If Not silent Then
|
||||||
|
MessageBox.Show("You're running the latest version (" & current.ToString() & ").",
|
||||||
|
"Shipping Tracker", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||||
|
End If
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
' --- newer version available ---------------------------------------
|
||||||
|
|
||||||
|
Dim answer = MessageBox.Show(
|
||||||
|
"A new version of Shipping Tracker is available." & vbCrLf & vbCrLf &
|
||||||
|
"You have: " & current.ToString() & vbCrLf &
|
||||||
|
"Available: " & rel.Version.ToString() & vbCrLf & vbCrLf &
|
||||||
|
"Update now?",
|
||||||
|
"Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||||
|
|
||||||
|
If answer <> DialogResult.Yes Then Return
|
||||||
|
|
||||||
|
If String.IsNullOrEmpty(rel.AssetUrl) Then
|
||||||
|
OfferManualDownload("This release doesn't contain a file named """ & AssetName & """.")
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Fail early if we can't write next to ourselves (e.g. Program Files,
|
||||||
|
' read-only network share) rather than half-applying the update.
|
||||||
|
If Not CanWriteBesideExe() Then
|
||||||
|
OfferManualDownload("Shipping Tracker doesn't have permission to update itself " &
|
||||||
|
"in this folder.")
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
Await DownloadAndApplyAsync(rel)
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Deletes the previous binary left behind by an update.
|
||||||
|
''' Call once, early, from Form1_Load. Never throws.
|
||||||
|
''' </summary>
|
||||||
|
Public Sub CleanupOldBinary()
|
||||||
|
Try
|
||||||
|
Dim oldPath = Application.ExecutablePath & ".old"
|
||||||
|
If File.Exists(oldPath) Then File.Delete(oldPath)
|
||||||
|
Catch
|
||||||
|
' Still locked, or already gone. Harmless - try again next launch.
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' --- release metadata --------------------------------------------------
|
||||||
|
|
||||||
|
Private Class ReleaseInfo
|
||||||
|
Public Property Version As Version
|
||||||
|
Public Property AssetUrl As String
|
||||||
|
Public Property ChecksumUrl As String
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Private Async Function FetchLatestReleaseAsync() As Task(Of ReleaseInfo)
|
||||||
|
|
||||||
|
Using req As New HttpRequestMessage(HttpMethod.Get, ApiLatest)
|
||||||
|
req.Headers.Add("User-Agent", "ShippingTracker")
|
||||||
|
req.Headers.Add("Accept", "application/json")
|
||||||
|
|
||||||
|
Using resp = Await Http.SendAsync(req)
|
||||||
|
resp.EnsureSuccessStatusCode()
|
||||||
|
Dim body = Await resp.Content.ReadAsStringAsync()
|
||||||
|
|
||||||
|
Dim js As New JavaScriptSerializer()
|
||||||
|
Dim root = TryCast(js.DeserializeObject(body), Dictionary(Of String, Object))
|
||||||
|
If root Is Nothing Then Return Nothing
|
||||||
|
|
||||||
|
Dim info As New ReleaseInfo()
|
||||||
|
|
||||||
|
Dim tag As String = Nothing
|
||||||
|
If root.ContainsKey("tag_name") Then tag = TryCast(root("tag_name"), String)
|
||||||
|
info.Version = ParseVersion(tag)
|
||||||
|
|
||||||
|
If root.ContainsKey("assets") Then
|
||||||
|
Dim assets = TryCast(root("assets"), Object())
|
||||||
|
If assets IsNot Nothing Then
|
||||||
|
For Each a In assets
|
||||||
|
Dim asset = TryCast(a, Dictionary(Of String, Object))
|
||||||
|
If asset Is Nothing Then Continue For
|
||||||
|
|
||||||
|
Dim name As String = Nothing
|
||||||
|
Dim url As String = Nothing
|
||||||
|
If asset.ContainsKey("name") Then name = TryCast(asset("name"), String)
|
||||||
|
If asset.ContainsKey("browser_download_url") Then _
|
||||||
|
url = TryCast(asset("browser_download_url"), String)
|
||||||
|
|
||||||
|
If name Is Nothing OrElse url Is Nothing Then Continue For
|
||||||
|
|
||||||
|
If String.Equals(name, AssetName, StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
info.AssetUrl = url
|
||||||
|
ElseIf String.Equals(name, ChecksumAssetName, StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
info.ChecksumUrl = url
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return info
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
' --- version handling --------------------------------------------------
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Parses a tag like "1.2.0.0", "v1.2.0" or "1.2" into a 4-part Version.
|
||||||
|
''' Missing components become 0 so comparison against AssemblyVersion is sane
|
||||||
|
''' (an unset component in System.Version is -1, which would sort wrong).
|
||||||
|
''' </summary>
|
||||||
|
Private Function ParseVersion(tag As String) As Version
|
||||||
|
If String.IsNullOrEmpty(tag) Then Return Nothing
|
||||||
|
|
||||||
|
Dim s = tag.Trim()
|
||||||
|
If s.StartsWith("v", StringComparison.OrdinalIgnoreCase) Then s = s.Substring(1)
|
||||||
|
|
||||||
|
Dim nums As New List(Of Integer)
|
||||||
|
For Each part In s.Split("."c)
|
||||||
|
Dim n As Integer
|
||||||
|
If Not Integer.TryParse(part.Trim(), n) Then Exit For
|
||||||
|
If n < 0 Then Exit For
|
||||||
|
nums.Add(n)
|
||||||
|
If nums.Count = 4 Then Exit For
|
||||||
|
Next
|
||||||
|
|
||||||
|
If nums.Count = 0 Then Return Nothing
|
||||||
|
While nums.Count < 4
|
||||||
|
nums.Add(0)
|
||||||
|
End While
|
||||||
|
|
||||||
|
Return New Version(nums(0), nums(1), nums(2), nums(3))
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function Normalise(v As Version) As Version
|
||||||
|
Return New Version(Math.Max(v.Major, 0), Math.Max(v.Minor, 0),
|
||||||
|
Math.Max(v.Build, 0), Math.Max(v.Revision, 0))
|
||||||
|
End Function
|
||||||
|
|
||||||
|
' --- download / verify / swap -----------------------------------------
|
||||||
|
|
||||||
|
Private Async Function DownloadAndApplyAsync(rel As ReleaseInfo) As Task
|
||||||
|
|
||||||
|
Dim exePath = Application.ExecutablePath
|
||||||
|
Dim newPath = exePath & ".new"
|
||||||
|
|
||||||
|
Dim prog As New UpdateProgressForm()
|
||||||
|
prog.Show()
|
||||||
|
|
||||||
|
Try
|
||||||
|
' 1. download the new binary
|
||||||
|
prog.SetStatus("Downloading update...")
|
||||||
|
Await DownloadToFileAsync(rel.AssetUrl, newPath, prog)
|
||||||
|
|
||||||
|
' 2. verify it, if the release published checksums
|
||||||
|
If Not String.IsNullOrEmpty(rel.ChecksumUrl) Then
|
||||||
|
prog.SetStatus("Verifying download...")
|
||||||
|
prog.SetProgress(100)
|
||||||
|
|
||||||
|
Dim expected = Await FetchExpectedHashAsync(rel.ChecksumUrl)
|
||||||
|
If String.IsNullOrEmpty(expected) Then
|
||||||
|
Throw New Exception("The checksum file has no entry for """ & AssetName & """.")
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim actual = Sha256File(newPath)
|
||||||
|
If Not String.Equals(expected, actual, StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
Throw New Exception("Checksum mismatch - the download was corrupted or tampered with." &
|
||||||
|
vbCrLf & vbCrLf &
|
||||||
|
"Expected: " & expected & vbCrLf &
|
||||||
|
"Got: " & actual)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
' 3. swap the binaries
|
||||||
|
prog.SetStatus("Installing...")
|
||||||
|
ApplyUpdate(newPath)
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
SafeDelete(newPath)
|
||||||
|
prog.Close()
|
||||||
|
OfferManualDownload("The update could not be installed:" & vbCrLf & vbCrLf & ex.Message)
|
||||||
|
Return
|
||||||
|
End Try
|
||||||
|
|
||||||
|
prog.Close()
|
||||||
|
|
||||||
|
MessageBox.Show("Update installed. Shipping Tracker will now restart.",
|
||||||
|
"Shipping Tracker", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||||
|
|
||||||
|
Try
|
||||||
|
Process.Start(exePath)
|
||||||
|
Catch
|
||||||
|
' If relaunch fails the update is still applied - next manual
|
||||||
|
' launch gets the new version.
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Application.Exit()
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Async Function DownloadToFileAsync(url As String, destPath As String,
|
||||||
|
prog As UpdateProgressForm) As Task
|
||||||
|
|
||||||
|
Using req As New HttpRequestMessage(HttpMethod.Get, url)
|
||||||
|
req.Headers.Add("User-Agent", "ShippingTracker")
|
||||||
|
|
||||||
|
' ResponseHeadersRead so we stream to disk instead of buffering it all.
|
||||||
|
Using resp = Await Http.SendAsync(req, HttpCompletionOption.ResponseHeadersRead)
|
||||||
|
resp.EnsureSuccessStatusCode()
|
||||||
|
|
||||||
|
Dim total As Long = -1
|
||||||
|
If resp.Content.Headers.ContentLength.HasValue Then
|
||||||
|
total = resp.Content.Headers.ContentLength.Value
|
||||||
|
End If
|
||||||
|
|
||||||
|
Using src = Await resp.Content.ReadAsStreamAsync(),
|
||||||
|
dst = New FileStream(destPath, FileMode.Create, FileAccess.Write, FileShare.None)
|
||||||
|
|
||||||
|
Dim buffer(81919) As Byte
|
||||||
|
Dim readTotal As Long = 0
|
||||||
|
Dim n As Integer
|
||||||
|
|
||||||
|
Do
|
||||||
|
n = Await src.ReadAsync(buffer, 0, buffer.Length)
|
||||||
|
If n = 0 Then Exit Do
|
||||||
|
Await dst.WriteAsync(buffer, 0, n)
|
||||||
|
readTotal += n
|
||||||
|
If total > 0 Then
|
||||||
|
prog.SetProgress(CInt(Math.Min(100L, readTotal * 100L \ total)))
|
||||||
|
End If
|
||||||
|
Loop
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Async Function FetchExpectedHashAsync(checksumUrl As String) As Task(Of String)
|
||||||
|
|
||||||
|
Using req As New HttpRequestMessage(HttpMethod.Get, checksumUrl)
|
||||||
|
req.Headers.Add("User-Agent", "ShippingTracker")
|
||||||
|
|
||||||
|
Using resp = Await Http.SendAsync(req)
|
||||||
|
resp.EnsureSuccessStatusCode()
|
||||||
|
Dim text = Await resp.Content.ReadAsStringAsync()
|
||||||
|
|
||||||
|
' sha256sum format: "<hash> <filename>" (two spaces, or " *")
|
||||||
|
For Each line In text.Split({vbCr, vbLf}, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
Dim trimmed = line.Trim()
|
||||||
|
If trimmed.Length = 0 Then Continue For
|
||||||
|
|
||||||
|
Dim sep = trimmed.IndexOf(" "c)
|
||||||
|
If sep <= 0 Then Continue For
|
||||||
|
|
||||||
|
Dim hash = trimmed.Substring(0, sep).Trim()
|
||||||
|
Dim name = trimmed.Substring(sep).Trim().TrimStart("*"c).Trim()
|
||||||
|
|
||||||
|
If String.Equals(name, AssetName, StringComparison.OrdinalIgnoreCase) Then
|
||||||
|
Return hash
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return Nothing
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function Sha256File(path As String) As String
|
||||||
|
Using sha = SHA256.Create(), fs = File.OpenRead(path)
|
||||||
|
Return BitConverter.ToString(sha.ComputeHash(fs)).Replace("-", "").ToLowerInvariant()
|
||||||
|
End Using
|
||||||
|
End Function
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Windows won't let you delete a running .exe, but it will let you RENAME
|
||||||
|
''' one. So: current -> .old, downloaded -> current. The .old file is removed
|
||||||
|
''' by CleanupOldBinary() on the next launch.
|
||||||
|
''' </summary>
|
||||||
|
Private Sub ApplyUpdate(newFile As String)
|
||||||
|
|
||||||
|
Dim exePath = Application.ExecutablePath
|
||||||
|
Dim oldPath = exePath & ".old"
|
||||||
|
|
||||||
|
SafeDelete(oldPath)
|
||||||
|
|
||||||
|
File.Move(exePath, oldPath) ' running exe is now .old
|
||||||
|
|
||||||
|
Try
|
||||||
|
File.Move(newFile, exePath) ' new binary takes its place
|
||||||
|
Catch
|
||||||
|
' Roll back so the user isn't left without an application.
|
||||||
|
Try
|
||||||
|
File.Move(oldPath, exePath)
|
||||||
|
Catch
|
||||||
|
End Try
|
||||||
|
Throw
|
||||||
|
End Try
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' --- helpers -----------------------------------------------------------
|
||||||
|
|
||||||
|
Private Function CanWriteBesideExe() As Boolean
|
||||||
|
Try
|
||||||
|
Dim dir = Path.GetDirectoryName(Application.ExecutablePath)
|
||||||
|
Dim probe = Path.Combine(dir, "." & Guid.NewGuid().ToString("N") & ".tmp")
|
||||||
|
Using fs = New FileStream(probe, FileMode.CreateNew, FileAccess.Write, FileShare.None)
|
||||||
|
End Using
|
||||||
|
File.Delete(probe)
|
||||||
|
Return True
|
||||||
|
Catch
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Sub SafeDelete(path As String)
|
||||||
|
Try
|
||||||
|
If File.Exists(path) Then File.Delete(path)
|
||||||
|
Catch
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub OfferManualDownload(message As String)
|
||||||
|
Dim answer = MessageBox.Show(
|
||||||
|
message & vbCrLf & vbCrLf & "Open the downloads page instead?",
|
||||||
|
"Shipping Tracker", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
|
||||||
|
|
||||||
|
If answer = DialogResult.Yes Then
|
||||||
|
Try
|
||||||
|
Process.Start(ReleasesPage)
|
||||||
|
Catch
|
||||||
|
End Try
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Module
|
||||||
|
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Minimal progress window, built in code so there's no extra .Designer.vb
|
||||||
|
''' to add to the project.
|
||||||
|
''' </summary>
|
||||||
|
Friend Class UpdateProgressForm
|
||||||
|
Inherits Form
|
||||||
|
|
||||||
|
Private ReadOnly _bar As ProgressBar
|
||||||
|
Private ReadOnly _label As Label
|
||||||
|
|
||||||
|
Public Sub New()
|
||||||
|
Me.Text = "Updating Shipping Tracker"
|
||||||
|
Me.FormBorderStyle = FormBorderStyle.FixedDialog
|
||||||
|
Me.StartPosition = FormStartPosition.CenterScreen
|
||||||
|
Me.MaximizeBox = False
|
||||||
|
Me.MinimizeBox = False
|
||||||
|
Me.ControlBox = False
|
||||||
|
Me.ClientSize = New Drawing.Size(360, 90)
|
||||||
|
|
||||||
|
_label = New Label() With {
|
||||||
|
.Text = "Starting...",
|
||||||
|
.AutoSize = False,
|
||||||
|
.Location = New Drawing.Point(15, 15),
|
||||||
|
.Size = New Drawing.Size(330, 20)
|
||||||
|
}
|
||||||
|
|
||||||
|
_bar = New ProgressBar() With {
|
||||||
|
.Location = New Drawing.Point(15, 45),
|
||||||
|
.Size = New Drawing.Size(330, 22),
|
||||||
|
.Minimum = 0,
|
||||||
|
.Maximum = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
Me.Controls.Add(_label)
|
||||||
|
Me.Controls.Add(_bar)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetStatus(text As String)
|
||||||
|
_label.Text = text
|
||||||
|
_label.Refresh()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetProgress(percent As Integer)
|
||||||
|
If percent < 0 Then percent = 0
|
||||||
|
If percent > 100 Then percent = 100
|
||||||
|
_bar.Value = percent
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Class
|
||||||
|
|
||||||
|
|
||||||
|
' ---------------------------------------------------------------------------
|
||||||
|
' INTEGRATION
|
||||||
|
'
|
||||||
|
' 1. Project -> Add Reference -> Assemblies -> System.Web.Extensions
|
||||||
|
'
|
||||||
|
' 2. Form1.vb - replace the existing Form1_Load with:
|
||||||
|
'
|
||||||
|
' Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
|
' lblCoppiedNotifyer.Text = ""
|
||||||
|
' Updater.CleanupOldBinary()
|
||||||
|
' Await Updater.CheckForUpdatesAsync(True)
|
||||||
|
' End Sub
|
||||||
|
'
|
||||||
|
' (Async Sub is fine here - the await resumes on the UI thread, and the
|
||||||
|
' window paints while the HTTP request is in flight.)
|
||||||
|
'
|
||||||
|
' 3. Form3.vb - replace the btnUpdates handler with:
|
||||||
|
'
|
||||||
|
' Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles btnUpdates.Click
|
||||||
|
' Await Updater.CheckForUpdatesAsync(False)
|
||||||
|
' End Sub
|
||||||
|
'
|
||||||
|
' 4. Bump <Assembly: AssemblyVersion> and AssemblyFileVersion in
|
||||||
|
' My Project\AssemblyInfo.vb before each release. This is what the updater
|
||||||
|
' compares against - if you forget, users are told they're up to date.
|
||||||
|
'
|
||||||
|
' PUBLISHING A RELEASE
|
||||||
|
'
|
||||||
|
' - Tag the release "1.2.0.0" (a leading "v" is also accepted).
|
||||||
|
' - Attach the built binary, named exactly: Shipping Tracker.exe
|
||||||
|
' - Attach checksums.txt containing:
|
||||||
|
' <sha256> Shipping Tracker.exe
|
||||||
|
' Generate it in PowerShell with:
|
||||||
|
' (Get-FileHash ".\Shipping Tracker.exe" -Algorithm SHA256).Hash.ToLower() `
|
||||||
|
' + " Shipping Tracker.exe" | Out-File checksums.txt -Encoding ascii
|
||||||
|
' - Don't mark it pre-release: /releases/latest skips drafts and pre-releases.
|
||||||
|
'
|
||||||
|
' If checksums.txt is missing the update still installs, but unverified.
|
||||||
|
' ---------------------------------------------------------------------------
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
3b8e4dcfc328e7f3fedf6c8f0adbc8689e7eeb8c5646d5a81212b863dda07e7a Shipping Tracker.exe
|
||||||
Reference in New Issue
Block a user