Skip to content

Commit 87bff1a

Browse files
Final refinements: fix _updateNestingLevel usage, improve comments, add volatile for thread safety
Co-authored-by: RuntimeRascal <2422222+RuntimeRascal@users.noreply.github.com>
1 parent 95ec39e commit 87bff1a

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

Src/GhostDraw/Core/GlobalKeyboardHook.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class GlobalKeyboardHook : IDisposable
4646
private List<int> _hotkeyVKs = new() { 0xA2, 0xA4, 0x44 }; // Default: Ctrl+Alt+D
4747
private Dictionary<int, bool> _keyStates = new();
4848
private bool _wasHotkeyActive = false;
49-
private bool _isControlPressed = false;
49+
private volatile bool _isControlPressed = false;
5050

5151
public GlobalKeyboardHook(ILogger<GlobalKeyboardHook> logger)
5252
{

Src/GhostDraw/Services/ScreenshotService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void OpenSnippingTool()
9595
{
9696
_logger.LogInformation("Opening Windows Snipping Tool");
9797

98-
// Try SnippingTool.exe first (Windows 10)
98+
// Try SnippingTool.exe first (Windows 7, 8, 10)
9999
var snippingToolPath = Path.Combine(
100100
Environment.GetFolderPath(Environment.SpecialFolder.System),
101101
"SnippingTool.exe");

Src/GhostDraw/Views/UserControls/ScreenshotSettingsControl.xaml.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@ private void Initialize(AppSettingsService appSettings)
4343

4444
private void LoadSettings(AppSettingsService appSettings)
4545
{
46-
var settings = appSettings.CurrentSettings;
47-
SavePathTextBox.Text = settings.ScreenshotSavePath;
48-
CopyToClipboardCheckBox.IsChecked = settings.CopyScreenshotToClipboard;
49-
OpenFolderCheckBox.IsChecked = settings.OpenFolderAfterScreenshot;
50-
PlaySoundCheckBox.IsChecked = settings.PlayShutterSound;
46+
_updateNestingLevel++;
47+
try
48+
{
49+
var settings = appSettings.CurrentSettings;
50+
SavePathTextBox.Text = settings.ScreenshotSavePath;
51+
CopyToClipboardCheckBox.IsChecked = settings.CopyScreenshotToClipboard;
52+
OpenFolderCheckBox.IsChecked = settings.OpenFolderAfterScreenshot;
53+
PlaySoundCheckBox.IsChecked = settings.PlayShutterSound;
54+
}
55+
finally
56+
{
57+
_updateNestingLevel--;
58+
}
5159
}
5260

5361
private void BrowseButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)