From 335a12a525b290bb5a6124871aa6c4597a893069 Mon Sep 17 00:00:00 2001 From: Thomas Parkison Date: Mon, 1 May 2023 01:41:05 -0400 Subject: [PATCH 1/5] Moved some buttons around on the Welcome tab and made the "Check for Updates" button invisible if checking for updates is set to be automatic. --- Hasher/Form1.Designer.vb | 17 ++--------------- Hasher/Form1.resx | 3 +++ Hasher/Form1.vb | 2 ++ Hasher/Program Modules/Check for Update.vb | 11 ----------- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Hasher/Form1.Designer.vb b/Hasher/Form1.Designer.vb index 3322442..f242b8e 100644 --- a/Hasher/Form1.Designer.vb +++ b/Hasher/Form1.Designer.vb @@ -27,7 +27,6 @@ Partial Class Form1 Me.TabControl1 = New System.Windows.Forms.TabControl() Me.tabWelcome = New System.Windows.Forms.TabPage() Me.btnDonate = New System.Windows.Forms.Button() - Me.lblDownloadNotification = New System.Windows.Forms.Label() Me.btnCheckForUpdates = New System.Windows.Forms.Button() Me.lblWelcomeText = New System.Windows.Forms.Label() Me.tabHashText = New System.Windows.Forms.TabPage() @@ -231,7 +230,6 @@ Partial Class Form1 ' Me.tabWelcome.BackColor = System.Drawing.SystemColors.Control Me.tabWelcome.Controls.Add(Me.btnDonate) - Me.tabWelcome.Controls.Add(Me.lblDownloadNotification) Me.tabWelcome.Controls.Add(Me.btnCheckForUpdates) Me.tabWelcome.Controls.Add(Me.lblWelcomeText) Me.tabWelcome.Location = New System.Drawing.Point(4, 22) @@ -245,7 +243,7 @@ Partial Class Form1 ' Me.btnDonate.Image = Global.Hasher.My.Resources.Resources.green_dollar Me.btnDonate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft - Me.btnDonate.Location = New System.Drawing.Point(19, 119) + Me.btnDonate.Location = New System.Drawing.Point(19, 74) Me.btnDonate.Name = "btnDonate" Me.btnDonate.Size = New System.Drawing.Size(163, 39) Me.btnDonate.TabIndex = 9 @@ -253,19 +251,9 @@ Partial Class Form1 Me.btnDonate.TextAlign = System.Drawing.ContentAlignment.MiddleRight Me.btnDonate.UseVisualStyleBackColor = True ' - 'lblDownloadNotification - ' - Me.lblDownloadNotification.AutoSize = True - Me.lblDownloadNotification.Location = New System.Drawing.Point(188, 74) - Me.lblDownloadNotification.Name = "lblDownloadNotification" - Me.lblDownloadNotification.Size = New System.Drawing.Size(133, 13) - Me.lblDownloadNotification.TabIndex = 8 - Me.lblDownloadNotification.Text = "(No Download in Progress)" - Me.lblDownloadNotification.Visible = False - ' 'btnCheckForUpdates ' - Me.btnCheckForUpdates.Location = New System.Drawing.Point(19, 74) + Me.btnCheckForUpdates.Location = New System.Drawing.Point(19, 119) Me.btnCheckForUpdates.Name = "btnCheckForUpdates" Me.btnCheckForUpdates.Size = New System.Drawing.Size(163, 39) Me.btnCheckForUpdates.TabIndex = 7 @@ -1991,7 +1979,6 @@ Partial Class Form1 Friend WithEvents colFileSize As ColumnHeader Friend WithEvents colFileSize2 As ColumnHeader Friend WithEvents listFilesContextMenu As ContextMenuStrip - Friend WithEvents lblDownloadNotification As Label Friend WithEvents btnCheckForUpdates As Button Friend WithEvents tabCompareFiles As TabPage Friend WithEvents btnCompareFilesBrowseFile1 As Button diff --git a/Hasher/Form1.resx b/Hasher/Form1.resx index e2071c8..801d6af 100644 --- a/Hasher/Form1.resx +++ b/Hasher/Form1.resx @@ -142,4 +142,7 @@ that the two files are different. However, if you want to compute the hashes any 468, 19 + + 180, 18 + \ No newline at end of file diff --git a/Hasher/Form1.vb b/Hasher/Form1.vb index 4ca29f4..5fa3448 100644 --- a/Hasher/Form1.vb +++ b/Hasher/Form1.vb @@ -963,6 +963,7 @@ Public Class Form1 chkDisplayHashesInUpperCase.Checked = My.Settings.boolDisplayHashesInUpperCase chkUseCommasInNumbers.Checked = My.Settings.boolUseCommasInNumbers chkCheckForUpdates.Checked = My.Settings.boolCheckForUpdates + btnCheckForUpdates.Visible = Not chkCheckForUpdates.Checked chkAutoAddExtension.Checked = My.Settings.boolAutoAddExtension chkDisplayValidChecksumString.Checked = My.Settings.boolDisplayValidChecksumString chkOpenInExplorer.Checked = My.Settings.boolOpenInExplorer @@ -2634,6 +2635,7 @@ Public Class Form1 Private Sub ChkCheckForUpdates_Click(sender As Object, e As EventArgs) Handles chkCheckForUpdates.Click My.Settings.boolCheckForUpdates = chkCheckForUpdates.Checked + btnCheckForUpdates.Visible = Not chkCheckForUpdates.Checked End Sub Private Sub ChkAutoAddExtension_Click(sender As Object, e As EventArgs) Handles chkAutoAddExtension.Click diff --git a/Hasher/Program Modules/Check for Update.vb b/Hasher/Program Modules/Check for Update.vb index feb6cf8..8c6bccf 100644 --- a/Hasher/Program Modules/Check for Update.vb +++ b/Hasher/Program Modules/Check for Update.vb @@ -251,18 +251,7 @@ Namespace checkForUpdates Private Sub DownloadAndPerformUpdate() Dim newExecutableName As String = $"{New FileInfo(Application.ExecutablePath).Name}.new.exe" - ' We have to do this stuff on the thread that the form belongs to or we will get an error. - windowObject.Invoke(Sub() - windowObject.lblDownloadNotification.Visible = True - End Sub) - Dim httpHelper As HttpHelper = CreateNewHTTPHelperObject() - httpHelper.SetDownloadStatusUpdateRoutine = Function(downloadStatusDetails As DownloadStatusDetails) - windowObject.Invoke(Sub() - windowObject.lblDownloadNotification.Text = $"{downloadStatusDetails.PercentageDownloaded}% Downloaded." - End Sub) - Return Nothing - End Function Using memoryStream As New MemoryStream() If Not httpHelper.DownloadFile(programZipFileURL, memoryStream, False) Then From 8b2d61c20ebca3b5041548bc2bb64b6b6af46aca Mon Sep 17 00:00:00 2001 From: Thomas Parkison Date: Sun, 4 Jun 2023 10:05:54 -0400 Subject: [PATCH 2/5] Renamed the CaseInsensitiveReplace() function to simply Replace(). --- Hasher/Form1.vb | 14 +++++++------- Hasher/Program Modules/Check for Update.vb | 2 +- Hasher/Program Modules/StringExtensions.vb | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Hasher/Form1.vb b/Hasher/Form1.vb index 5fa3448..e47feb2 100644 --- a/Hasher/Form1.vb +++ b/Hasher/Form1.vb @@ -495,7 +495,7 @@ Public Class Form1 For Each item As MyListViewItem In listFiles.Items If Not String.IsNullOrWhiteSpace(item.Hash) Then strFile = item.FileName - If chkSaveChecksumFilesWithRelativePaths.Checked Then strFile = strFile.CaseInsensitiveReplace(folderOfChecksumFile, "", StringComparison.OrdinalIgnoreCase) + If chkSaveChecksumFilesWithRelativePaths.Checked Then strFile = strFile.Replace(folderOfChecksumFile, "", StringComparison.OrdinalIgnoreCase) stringBuilder.AppendLine($"{GetDataFromAllTheHashes(checksumType, item.AllTheHashes)} *{strFile}") End If Next @@ -861,7 +861,7 @@ Public Class Form1 If strReceivedMessage.StartsWith("--comparefile=", StringComparison.OrdinalIgnoreCase) Then MyInvoke(Sub() - Dim strFilePathToBeCompared As String = strReceivedMessage.CaseInsensitiveReplace("--comparefile=", "", StringComparison.OrdinalIgnoreCase) + Dim strFilePathToBeCompared As String = strReceivedMessage.Replace("--comparefile=", "", StringComparison.OrdinalIgnoreCase) If String.IsNullOrWhiteSpace(txtFile1.Text) And String.IsNullOrWhiteSpace(txtFile2.Text) Then txtFile1.Text = strFilePathToBeCompared @@ -875,7 +875,7 @@ Public Class Form1 If Not String.IsNullOrWhiteSpace(txtFile1.Text) AndAlso Not String.IsNullOrWhiteSpace(txtFile2.Text) Then btnCompareFiles.PerformClick() End Sub) ElseIf strReceivedMessage.StartsWith("--addfile=", StringComparison.OrdinalIgnoreCase) Then - AddFileOrDirectoryToHashFileList(strReceivedMessage.CaseInsensitiveReplace("--addfile=", "", StringComparison.OrdinalIgnoreCase)) + AddFileOrDirectoryToHashFileList(strReceivedMessage.Replace("--addfile=", "", StringComparison.OrdinalIgnoreCase)) End If namedPipeServer.Dispose() @@ -901,11 +901,11 @@ Public Class Form1 ' so, this instance of the program will continue operating as the host of the named pipe server. If commandLineArgument.StartsWith("--addfile=", StringComparison.OrdinalIgnoreCase) Then ' We now have to strip off what we don't need. - commandLineArgument = commandLineArgument.CaseInsensitiveReplace("--addfile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") + commandLineArgument = commandLineArgument.Replace("--addfile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") AddFileOrDirectoryToHashFileList(commandLineArgument) ElseIf commandLineArgument.StartsWith("--comparefile=", StringComparison.OrdinalIgnoreCase) Then ' We now have to strip off what we don't need. - commandLineArgument = commandLineArgument.CaseInsensitiveReplace("--comparefile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") + commandLineArgument = commandLineArgument.Replace("--comparefile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") txtFile1.Text = commandLineArgument End If Else @@ -917,7 +917,7 @@ Public Class Form1 Process.GetCurrentProcess.Kill() ' This terminates the process. End If ElseIf commandLineArgument.StartsWith("--hashfile=", StringComparison.OrdinalIgnoreCase) Then - commandLineArgument = commandLineArgument.CaseInsensitiveReplace("--hashfile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") + commandLineArgument = commandLineArgument.Replace("--hashfile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") If IO.File.Exists(commandLineArgument) Then TabControl1.SelectTab(TabNumberVerifySavedHashesTab) @@ -926,7 +926,7 @@ Public Class Form1 ProcessExistingHashFile(commandLineArgument) End If ElseIf commandLineArgument.StartsWith("--knownhashfile=", StringComparison.OrdinalIgnoreCase) Then - commandLineArgument = commandLineArgument.CaseInsensitiveReplace("--knownhashfile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") + commandLineArgument = commandLineArgument.Replace("--knownhashfile=", "", StringComparison.OrdinalIgnoreCase).Replace(Chr(34), "") TabControl1.SelectTab(TabNumberCompareFileAgainstKnownHashTab) txtFileForKnownHash.Text = commandLineArgument txtKnownHash.Select() diff --git a/Hasher/Program Modules/Check for Update.vb b/Hasher/Program Modules/Check for Update.vb index 8c6bccf..8151cce 100644 --- a/Hasher/Program Modules/Check for Update.vb +++ b/Hasher/Program Modules/Check for Update.vb @@ -33,7 +33,7 @@ Namespace checkForUpdates Dim currentProcessFileName As String = New FileInfo(Application.ExecutablePath).Name If currentProcessFileName.CaseInsensitiveContains(".new.exe") Then - Dim mainEXEName As String = currentProcessFileName.CaseInsensitiveReplace(".new.exe", "", StringComparison.OrdinalIgnoreCase) + Dim mainEXEName As String = currentProcessFileName.Replace(".new.exe", "", StringComparison.OrdinalIgnoreCase) SearchForProcessAndKillIt(mainEXEName, False) diff --git a/Hasher/Program Modules/StringExtensions.vb b/Hasher/Program Modules/StringExtensions.vb index 63eaf62..3ba2a0d 100644 --- a/Hasher/Program Modules/StringExtensions.vb +++ b/Hasher/Program Modules/StringExtensions.vb @@ -10,16 +10,16 @@ Module StringExtensions Return haystack.IndexOf(needle, StringComparison.OrdinalIgnoreCase) <> -1 End Function - '''Returns a New String In which all occurrences Of a specified String In the current instance are replaced With another specified string according the type of search to use for the specified string. - ''' The string performing the replace method. - ''' The string to be replaced. - ''' The string replace all occurrences of . + '''Works similar to the original String Replacement function but with a potential case-insensitive match capability. + ''' The source String. + ''' The String to be replaced. + ''' The String that will replace all occurrences of . ''' If value Is equal to null, than all occurrences of will be removed from the . ''' One of the enumeration values that specifies the rules for the search. ''' A string that Is equivalent to the current string except that all instances of are replaced with . ''' If Is Not found in the current instance, the method returns the current instance unchanged. - Public Function CaseInsensitiveReplace(source As String, strReplace As String, strReplaceWith As String, comparisonType As StringComparison) As String + Public Function Replace(source As String, strReplace As String, strReplaceWith As String, comparisonType As StringComparison) As String If String.IsNullOrWhiteSpace(source) Then Throw New ArgumentNullException(NameOf(source)) If source.Length = 0 Then Return source If String.IsNullOrWhiteSpace(strReplace) Then Throw New ArgumentNullException(NameOf(strReplace)) From dab5727e7f705651fe8117364ac5a55b8d29634f Mon Sep 17 00:00:00 2001 From: Thomas Parkison Date: Sun, 25 Jun 2023 10:58:03 -0400 Subject: [PATCH 3/5] Updated the copyright line to include the year 2024. --- Hasher/Form1.Designer.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hasher/Form1.Designer.vb b/Hasher/Form1.Designer.vb index f242b8e..170dc10 100644 --- a/Hasher/Form1.Designer.vb +++ b/Hasher/Form1.Designer.vb @@ -271,7 +271,7 @@ Partial Class Form1 Me.lblWelcomeText.TabIndex = 0 Me.lblWelcomeText.Text = "Welcome to Hasher, the only hash program you need." & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Hasher version {0} (Ru" & "nning in {1}-bit mode on a {2}-bit operating system)" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Written by Tom Parkison." & - " Copyright Thomas Parkison 2018-2023." + " Copyright Thomas Parkison 2018-2024." ' 'tabHashText ' From 1349aea6fcb6d13052d6ef10ace103fc244d3309 Mon Sep 17 00:00:00 2001 From: Thomas Parkison Date: Sun, 25 Jun 2023 15:35:04 -0400 Subject: [PATCH 4/5] Replaced a hardcoded string in the Check for Update.vb file. --- Hasher/Program Modules/Check for Update.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hasher/Program Modules/Check for Update.vb b/Hasher/Program Modules/Check for Update.vb index 8151cce..13e526e 100644 --- a/Hasher/Program Modules/Check for Update.vb +++ b/Hasher/Program Modules/Check for Update.vb @@ -289,7 +289,7 @@ Namespace checkForUpdates Private Shared Function CreateHTTPUserAgentHeaderString() As String Dim versionInfo As String() = Application.ProductVersion.Split(".") Dim versionString As String = $"{versionInfo(0)}.{versionInfo(1)} Build {versionInfo(2)}" - Return $"Hasher version {versionString} on {GetFullOSVersionString()}" + Return $"{strProgramName} version {versionString} on {GetFullOSVersionString()}" End Function Private Shared Function GetFullOSVersionString() As String @@ -355,7 +355,7 @@ Namespace checkForUpdates Dim response As ProcessUpdateXMLResponse = ProcessUpdateXMLData(xmlData, remoteVersion, remoteBuild) If response = ProcessUpdateXMLResponse.newVersion Then - If BackgroundThreadMessageBox($"An update to Hasher (version {remoteVersion} Build {remoteBuild}) is available to be downloaded, do you want to download and update to this new version?", strMessageBoxTitleText) = MsgBoxResult.Yes Then + If BackgroundThreadMessageBox($"An update to {strProgramName} (version {remoteVersion} Build {remoteBuild}) is available to be downloaded, do you want to download and update to this new version?", strMessageBoxTitleText) = MsgBoxResult.Yes Then DownloadAndPerformUpdate() Else windowObject.Invoke(Sub() MsgBox("The update will not be downloaded.", MsgBoxStyle.Information, strMessageBoxTitleText)) From e4a5b871ecfa68faee48b4bbb0735733aa488902 Mon Sep 17 00:00:00 2001 From: Thomas Parkison Date: Sun, 25 Jun 2023 19:22:55 -0400 Subject: [PATCH 5/5] Updated build number. --- Hasher/My Project/AssemblyInfo.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hasher/My Project/AssemblyInfo.vb b/Hasher/My Project/AssemblyInfo.vb index 647802e..4150f05 100644 --- a/Hasher/My Project/AssemblyInfo.vb +++ b/Hasher/My Project/AssemblyInfo.vb @@ -31,4 +31,4 @@ Imports System.Runtime.InteropServices ' - +