Skip to content

Commit

Permalink
Ability to show / hide context menu "Browse for Logs" in Windows Exp…
Browse files Browse the repository at this point in the history
…lorer. Closes #19.
  • Loading branch information
Scarfsail committed Jan 23, 2021
1 parent cf9eedc commit e827681
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Src/AdvancedLogViewer/History.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<History>
<Version version="9.1.0" date="2021-01-23">
<Feature>Based on feature request #24: Added support for tabs beside spaces in custom patterns. It's a new keyword $Tabs$. Also both the existing $Spaces$ and new one $Tabs$ are shown in the help below the edit box.</Feature>
<Feature>Feature request #24: Added support for tabs beside spaces in custom patterns. It's a new keyword $Tabs$. Also both the existing $Spaces$ and new one $Tabs$ are shown in the help below the edit box.</Feature>
<Feature>Feature request #19: Ability to show / hide context menu "Browse for Logs" in Windows Explorer. Option is in Settings->System Integration</Feature>
</Version>
<Version version="9.0.2" date="2021-01-21">
<BigFeature>This is the first version built in .NET 5 as self-contained application. Thus it doesn't need any .NET framework to be installed on the target machine. Because of that, the app is compiled for both x86 and x64 environments with appropriate embedded framework inside. This change increased installer size to ~20 MB but benefit of not requiring installed specific .NET framework won over the increased size of binaries. There is visible performance boost mainly on bigger logs thanks to improvements in .NET 5.</BigFeature>
Expand Down
16 changes: 16 additions & 0 deletions Src/AdvancedLogViewer/UI/SettingsDlg.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 36 additions & 3 deletions Src/AdvancedLogViewer/UI/SettingsDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using AdvancedLogViewer.BL.LogBrowser;
using Scarfsail.Common.BL;
using System.Reflection;
using Microsoft.Win32;
using AdvancedLogViewer.Common;

namespace AdvancedLogViewer.UI
{
Expand All @@ -24,6 +26,7 @@ public partial class SettingsDlg : Form
TotalCmdIntegration totalCmd;
LogBrowserSettings logBrowser;
bool alvWasAssociated;
bool explorerContextMenuWasPresent;
private static Scarfsail.Logging.Log log = new Scarfsail.Logging.Log();

public SettingsDlg(AlvSettings alvSettings, bool firstTimeShown)
Expand Down Expand Up @@ -85,6 +88,17 @@ public SettingsDlg(AlvSettings alvSettings, bool firstTimeShown)
MessageBox.Show("Can't get information about associated application with LOG extension. Run ALV as Administrator.", "Administration rights required", MessageBoxButtons.OK, MessageBoxIcon.Error);
associateWithAlvCheckBox.Enabled = false;
}
try
{
explorerContextMenuWasPresent = Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\Shell\Browse for Logs\command", null, null) != null;
showBrowseWithAlvCheckBox.Checked = explorerContextMenuWasPresent;

}
catch
{
MessageBox.Show("Can't get information about explorer context menu. Run ALV as Administrator.", "Administration rights required", MessageBoxButtons.OK, MessageBoxIcon.Error);
showBrowseWithAlvCheckBox.Enabled = false;
}
this.automaticUpdateEnabledCheckBox.Checked = this.settings.AutomaticUpdates.EnableAutomaticCheck;
this.automaticUpdateCheckPeriodEdit.Value = this.settings.AutomaticUpdates.CheckInterval;

Expand Down Expand Up @@ -178,12 +192,31 @@ private void okButton_Click(object sender, EventArgs e)
}
catch
{
var msg = "Can'setassociation for the LOG extension. Run ALV as Administrator.";
var msg = "Can'set association for the LOG extension. Run ALV as Administrator.";
MessageBox.Show(msg, "Administration rights required", MessageBoxButtons.OK, MessageBoxIcon.Error);
log.Error(msg);
}
}
if (this.showBrowseWithAlvCheckBox.Enabled && this.showBrowseWithAlvCheckBox.Checked != explorerContextMenuWasPresent)
{
try
{
if (this.showBrowseWithAlvCheckBox.Checked)
{
//C:\Program Files (x86)\AdvancedLogViewer\AdvancedLogViewer.exe "%1\\"
Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\Shell\Browse for Logs\command","", $"{System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName} \"%1\\\\\"");
}
else
{
Registry.CurrentUser.DeleteSubKeyTree(@"SOFTWARE\Classes\Folder\Shell\Browse for Logs");
}
}
catch (System.Exception)
{
var msg = "Can'set explorer's context menu. Run ALV as Administrator.";
MessageBox.Show(msg, "Administration rights required", MessageBoxButtons.OK, MessageBoxIcon.Error);
log.Error(msg);
}


}
}

Expand Down

0 comments on commit e827681

Please sign in to comment.