@@ -1398,6 +1398,9 @@ private void buttonShowAllCertDataPopup_Click(object sender, EventArgs e)
13981398 // Retrieving the text from the label
13991399 var certificateInfo = labelCertificateInformation . Text ;
14001400
1401+ // Log the certificate information popup message
1402+ Message ( "User view the certificate information popup for certificate '" + comboBoxCertificatesInStore . Text + "'" , EventType . Information , 1042 ) ;
1403+
14011404 // Displaying the data in a MessageBox
14021405 MessageBox . Show ( certificateInfo , @"Certificate Information" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
14031406 }
@@ -1418,11 +1421,18 @@ private void buttonSaveLog_Click(object sender, EventArgs e)
14181421 {
14191422 // Write the output to the file
14201423 File . WriteAllText ( sfd . FileName , textBoxOutput . Text ) ;
1424+
1425+ // Log the saving of the output to the file message
1426+ Message ( "Output saved to file: '" + sfd . FileName + "'" , EventType . Information , 1038 ) ;
14211427 }
14221428 catch ( Exception exception )
14231429 {
14241430 // Show an error message if the file could not be saved
14251431 MessageBox . Show ( exception . ToString ( ) , @"Error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
1432+
1433+ // Log the error message
1434+ Message ( "Error saving output to file: " + exception . Message , EventType . Error , 1044 ) ;
1435+
14261436 throw ;
14271437 }
14281438 }
@@ -1545,7 +1555,21 @@ private bool VerifyConfiguration()
15451555
15461556 private void linkLabelOpenTrustedSigningPortal_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
15471557 {
1548- Process . Start ( "https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts" ) ;
1558+ try
1559+ {
1560+ Process . Start ( "https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts" ) ;
1561+
1562+ // Log the opening of the URL message
1563+ Message ( "User clicked the 'Open Trusted Signing Portal' link to open the URL: 'https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts'" , EventType . Information , 1040 ) ;
1564+ }
1565+ catch ( Exception ex )
1566+ {
1567+ // Show an error message if the URL could not be opened
1568+ MessageBox . Show ( @"Failed to open the URL. Error: " + ex . Message , @"Error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
1569+
1570+ // Log the error message
1571+ Message ( "Failed to open the URL: " + ex . Message , EventType . Error , 1041 ) ;
1572+ }
15491573 }
15501574
15511575 private void aboutToolStripMenuItem_Click ( object sender , EventArgs e )
@@ -1566,7 +1590,9 @@ private void changelogToolStripMenuItem_Click(object sender, EventArgs e)
15661590
15671591 private void CheckedListBoxFiles_KeyDown ( object sender , KeyEventArgs e )
15681592 {
1593+ // Initialize the deleted files counter
15691594 int deletedFilesCount = 0 ;
1595+
15701596 // Check if the Delete key on the keyboard is pressed
15711597 if ( e . KeyCode != Keys . Delete )
15721598 return ; // If not, do nothing and exit the method
@@ -1592,11 +1618,17 @@ private void CheckedListBoxFiles_KeyDown(object sender, KeyEventArgs e)
15921618
15931619 // Update the status label with the count of deleted files
15941620 statusLabel . Text = $@ "[INFO] { deletedFilesCount } file(s) deleted from the file list";
1621+
1622+ // Log the deletion of the file from the list message and the number of files deleted
1623+ Message ( $ "User have deleted { deletedFilesCount } file(s) from the list of files to sign", EventType . Information , 1042 ) ;
15951624 }
15961625 }
15971626
15981627 private void ButtonAddFiles_Click ( object sender , EventArgs e )
15991628 {
1629+ // Log the add files button click message
1630+ Message ( "User clicked the 'Add Files' button to add files to the list of files to sign" , EventType . Information , 1041 ) ;
1631+
16001632 // Show the OpenFileDialog and add the selected files to the list
16011633 openFileDialog . Multiselect = true ;
16021634 openFileDialog . Filter = @"Executables and scripts (*.exe;*.dll;*.sys;*.ocx;*.ps1;*.msi;*.cat;*.cab;*.appx;*.appxbundle;*.msix;*.msixbundle)|*.exe;*.dll;*.sys;*.ocx;*.ps1;*.msi;*.cat;*.cab;*.appx;*.appxbundle;*.msix;*.msixbundle|All Files (*.*)|*.*" ;
@@ -1627,6 +1659,9 @@ private void ButtonAddFiles_Click(object sender, EventArgs e)
16271659 totalFiles = 0 ; // Or handle it according to your application's needs
16281660 }
16291661
1662+ // Log the number of files selected and user action
1663+ Message ( "User have selected " + openFileDialog . FileNames . Length + " file(s) to add to the list of files to sign" , EventType . Information , 1039 ) ;
1664+
16301665 // calc added files
16311666 var addedFiles = totalFiles - currentFiles ;
16321667
@@ -1656,8 +1691,14 @@ private void ButtonAddDirectory_Click(object sender, EventArgs e)
16561691 searchOption = SearchOption . AllDirectories ;
16571692 }
16581693
1694+ // Log the search for files message
1695+ Message ( "Searching for files in the source folder selected to be added to the list of files to sign..." , EventType . Information , 1039 ) ;
1696+
16591697 // Set filter for file extension and add all files from selected folder
16601698 var files = GetFiles ( folderBrowserDialog . SelectedPath , "*.exe;*.dll;*.sys;*.ocx;*.ps1" , searchOption ) ;
1699+
1700+ // Log the search for files completion message
1701+ Message ( "Files found in the source folder selected to be added to the list of files" , EventType . Information , 1040 ) ;
16611702
16621703 // loop in all files
16631704 foreach ( var file in files )
@@ -1669,6 +1710,9 @@ private void ButtonAddDirectory_Click(object sender, EventArgs e)
16691710 var totalFiles = checkedListBoxFiles ? . Items . Count ?? 0 ;
16701711 var addedFiles = totalFiles - currentFiles ;
16711712
1713+ // Log the number of files added to the list and completion message
1714+ Message ( "User have added " + addedFiles + " file(s) to the list of files to sign" , EventType . Information , 1041 ) ;
1715+
16721716 // show status
16731717 statusLabel . Text = @"[INFO] " + addedFiles + @" file(s) imported to File List from selected folder" ;
16741718 }
@@ -1700,6 +1744,9 @@ private void ButtonSelectPFXCertificate_Click(object sender, EventArgs e)
17001744 // Open the OpenFileDialog to select a PFX file for signing
17011745 try
17021746 {
1747+ // Log the browse for PFX file message
1748+ Message ( "User is browsing for a PFX file for signing..." , EventType . Information , 1040 ) ;
1749+
17031750 // Create a new instance of the OpenFileDialog class.
17041751 var fileDialog = new OpenFileDialog
17051752 {
@@ -1710,17 +1757,26 @@ private void ButtonSelectPFXCertificate_Click(object sender, EventArgs e)
17101757
17111758 // Check if the dialog result is OK and set the selected file to the text box.
17121759 if ( fileDialog . ShowDialog ( ) == DialogResult . OK ) textBoxPFXFile . Text = fileDialog . FileName ;
1760+
1761+ // Log the PFX file selected message
1762+ Message ( "User have selected the PFX file: '" + textBoxPFXFile . Text + "'" , EventType . Information , 1042 ) ;
17131763 }
17141764 catch ( Exception ex )
17151765 {
17161766 int num = ( int ) MessageBox . Show ( ex . Message , Globals . MsgBox . Error , MessageBoxButtons . OK , MessageBoxIcon . Hand ) ;
1767+
1768+ // Log the error message when selecting the PFX file
1769+ Message ( "Error selecting the PFX file: " + ex . Message , EventType . Error , 1043 ) ;
17171770 }
17181771 }
17191772
17201773 private void ButtonShowSigningCertificate_Click ( object sender , EventArgs e )
17211774 {
17221775 try
17231776 {
1777+ // Log the display of the signing certificate message
1778+ Message ( "User is displaying the signing certificate..." , EventType . Information , 1044 ) ;
1779+
17241780 // Check if the Windows Certificate Store radio button is selected.
17251781 if ( radioButtonWindowsCertificateStore . Checked )
17261782 {
@@ -1730,6 +1786,9 @@ private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17301786
17311787 // Display the selected certificate from the signing certificates list.
17321788 X509Certificate2UI . DisplayCertificate ( new X509Certificate2 ( ( X509Certificate ) _signingCerts [ comboBoxCertificatesInStore . SelectedIndex - 1 ] ) ) ;
1789+
1790+ // Log the display of the signing certificate completion message from store
1791+ Message ( "User have displayed the signing certificate from the Windows Certificate Store" , EventType . Information , 1045 ) ;
17331792 }
17341793 else
17351794 {
@@ -1738,6 +1797,9 @@ private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17381797
17391798 // Display the certificate obtained from the PFX file.
17401799 X509Certificate2UI . DisplayCertificate ( GetCertificateFromPfx ( ) ) ;
1800+
1801+ // Log the display of the signing certificate completion message from PFX file
1802+ Message ( "User have displayed the signing certificate from the .PFX file" , EventType . Information , 1046 ) ;
17411803 }
17421804
17431805 // Check if the PFX Certificate radio button is selected.
@@ -1746,15 +1808,21 @@ private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17461808 // If the label for certificate information is not null, update it with the certificate info.
17471809 if ( labelCertificateInformation != null )
17481810 labelCertificateInformation . Text = GetCertificateInfo ( GetCertificateFromPfx ( ) ) ;
1811+
1812+ // Log the display of the signing certificate completion message from PFX file to the UI
1813+ Message ( "Displayed the signing certificate from the .PFX file to the UI" , EventType . Information , 1047 ) ;
17491814 }
17501815 }
1751- catch ( Exception )
1816+ catch ( Exception ex )
17521817 {
1753- //int num = (int)MessageBox.Show(ex.Message, Txt.MsgBox.warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1818+ // TODO make error massage better for the user
1819+ //int num = (int)MessageBox.Show(ex.Message, @"Error when showing certificate data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1820+
1821+ // Log the error message when displaying the signing certificate
1822+ Message ( "Error displaying the signing certificate: " + ex . Message , EventType . Error , 1047 ) ;
17541823 }
17551824 }
17561825
1757-
17581826 #endregion Sign options - GUI
17591827
17601828 #region Sign files - GUI
@@ -1786,6 +1854,9 @@ private void CheckBoxAll_CheckedChanged(object sender, EventArgs e)
17861854 // Set the checked state of each item to match the state of the "Select All" checkbox.
17871855 checkedListBoxFiles . SetItemChecked ( i , isChecked ) ;
17881856 }
1857+
1858+ // Log the "Select All" checkbox state change.
1859+ Message ( "User have " + ( isChecked ? "checked" : "unchecked" ) + " the 'Select All' checkbox for file(s) to sign" , EventType . Information , 1042 ) ;
17891860 }
17901861
17911862 #endregion Sign files - GUI
0 commit comments