Skip to content

Commit 95ec39e

Browse files
Add screenshot settings UI panel to SettingsWindow
Co-authored-by: RuntimeRascal <2422222+RuntimeRascal@users.noreply.github.com>
1 parent bc5ace8 commit 95ec39e

4 files changed

Lines changed: 271 additions & 0 deletions

File tree

Src/GhostDraw/Services/AppSettingsService.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,46 @@ public DrawTool ToggleTool()
287287
return newTool;
288288
}
289289

290+
/// <summary>
291+
/// Sets the screenshot save path
292+
/// </summary>
293+
public void SetScreenshotSavePath(string path)
294+
{
295+
_logger.LogInformation("Setting screenshot save path to: {Path}", path);
296+
_currentSettings.ScreenshotSavePath = path;
297+
SaveSettings(_currentSettings);
298+
}
299+
300+
/// <summary>
301+
/// Sets whether to copy screenshot to clipboard
302+
/// </summary>
303+
public void SetCopyScreenshotToClipboard(bool copyToClipboard)
304+
{
305+
_logger.LogInformation("Setting copy screenshot to clipboard: {Value}", copyToClipboard);
306+
_currentSettings.CopyScreenshotToClipboard = copyToClipboard;
307+
SaveSettings(_currentSettings);
308+
}
309+
310+
/// <summary>
311+
/// Sets whether to play shutter sound on screenshot
312+
/// </summary>
313+
public void SetPlayShutterSound(bool playSound)
314+
{
315+
_logger.LogInformation("Setting play shutter sound: {Value}", playSound);
316+
_currentSettings.PlayShutterSound = playSound;
317+
SaveSettings(_currentSettings);
318+
}
319+
320+
/// <summary>
321+
/// Sets whether to open folder after screenshot
322+
/// </summary>
323+
public void SetOpenFolderAfterScreenshot(bool openFolder)
324+
{
325+
_logger.LogInformation("Setting open folder after screenshot: {Value}", openFolder);
326+
_currentSettings.OpenFolderAfterScreenshot = openFolder;
327+
SaveSettings(_currentSettings);
328+
}
329+
290330
/// <summary>
291331
/// Resets all settings to default values
292332
/// </summary>

Src/GhostDraw/Views/SettingsWindow.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@
162162
<!-- Mode Settings -->
163163
<uc:ModeSettingsControl AppSettings="{Binding AppSettings}"/>
164164

165+
<!-- Screenshot Settings -->
166+
<uc:ScreenshotSettingsControl AppSettings="{Binding AppSettings}"/>
167+
165168
<!-- Logging Settings -->
166169
<uc:LoggingSettingsControl LoggingSettings="{Binding LoggingSettings}"/>
167170
</StackPanel>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<UserControl x:Class="GhostDraw.Views.UserControls.ScreenshotSettingsControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
4+
5+
<GroupBox Header="// SCREENSHOT">
6+
<StackPanel>
7+
<!-- Save Path Section -->
8+
<TextBlock Text="SAVE LOCATION"
9+
Foreground="#00FFFF"
10+
FontWeight="Bold"
11+
FontFamily="Consolas"
12+
FontSize="11"
13+
Margin="0,0,0,8"/>
14+
15+
<Grid Margin="0,0,0,16">
16+
<Grid.ColumnDefinitions>
17+
<ColumnDefinition Width="*"/>
18+
<ColumnDefinition Width="Auto"/>
19+
</Grid.ColumnDefinitions>
20+
21+
<TextBox x:Name="SavePathTextBox"
22+
Grid.Column="0"
23+
Background="#0A0E27"
24+
BorderBrush="#404040"
25+
BorderThickness="1"
26+
Foreground="#B0B0B0"
27+
FontFamily="Consolas"
28+
FontSize="11"
29+
Padding="8"
30+
IsReadOnly="True"
31+
Margin="0,0,8,0"/>
32+
33+
<Button x:Name="BrowseButton"
34+
Grid.Column="1"
35+
Content="BROWSE..."
36+
Background="#1A1A2E"
37+
BorderBrush="#00FFFF"
38+
BorderThickness="1"
39+
Foreground="#00FFFF"
40+
FontFamily="Consolas"
41+
FontSize="10"
42+
FontWeight="Bold"
43+
Padding="12,6"
44+
Click="BrowseButton_Click"
45+
Cursor="Hand">
46+
<Button.Style>
47+
<Style TargetType="Button">
48+
<Setter Property="Background" Value="#1A1A2E"/>
49+
<Setter Property="Template">
50+
<Setter.Value>
51+
<ControlTemplate TargetType="Button">
52+
<Border Background="{TemplateBinding Background}"
53+
BorderBrush="{TemplateBinding BorderBrush}"
54+
BorderThickness="{TemplateBinding BorderThickness}"
55+
Padding="{TemplateBinding Padding}">
56+
<ContentPresenter HorizontalAlignment="Center"
57+
VerticalAlignment="Center"/>
58+
</Border>
59+
</ControlTemplate>
60+
</Setter.Value>
61+
</Setter>
62+
<Style.Triggers>
63+
<Trigger Property="IsMouseOver" Value="True">
64+
<Setter Property="Background" Value="#2A2A3E"/>
65+
</Trigger>
66+
</Style.Triggers>
67+
</Style>
68+
</Button.Style>
69+
</Button>
70+
</Grid>
71+
72+
<!-- Options Section -->
73+
<TextBlock Text="OPTIONS"
74+
Foreground="#00FFFF"
75+
FontWeight="Bold"
76+
FontFamily="Consolas"
77+
FontSize="11"
78+
Margin="0,0,0,8"/>
79+
80+
<CheckBox x:Name="CopyToClipboardCheckBox"
81+
Content="Copy to clipboard after capture"
82+
Foreground="#B0B0B0"
83+
FontFamily="Consolas"
84+
FontSize="11"
85+
Checked="CopyToClipboardCheckBox_Changed"
86+
Unchecked="CopyToClipboardCheckBox_Changed"
87+
Margin="0,0,0,8"/>
88+
89+
<CheckBox x:Name="OpenFolderCheckBox"
90+
Content="Open folder after capture"
91+
Foreground="#B0B0B0"
92+
FontFamily="Consolas"
93+
FontSize="11"
94+
Checked="OpenFolderCheckBox_Changed"
95+
Unchecked="OpenFolderCheckBox_Changed"
96+
Margin="0,0,0,8"/>
97+
98+
<CheckBox x:Name="PlaySoundCheckBox"
99+
Content="Play shutter sound"
100+
Foreground="#B0B0B0"
101+
FontFamily="Consolas"
102+
FontSize="11"
103+
Checked="PlaySoundCheckBox_Changed"
104+
Unchecked="PlaySoundCheckBox_Changed"
105+
Margin="0,0,0,16"/>
106+
107+
<!-- Info Section -->
108+
<Border Background="#0A0E27"
109+
BorderBrush="#404040"
110+
BorderThickness="1"
111+
Padding="16">
112+
<StackPanel>
113+
<TextBlock Foreground="#B0B0B0"
114+
FontSize="11"
115+
FontFamily="Consolas"
116+
TextWrapping="Wrap"
117+
Margin="0,0,0,8"
118+
LineHeight="16">
119+
<Run Text="[Ctrl+S]" Foreground="#00FF00" FontWeight="Bold"/>
120+
<Run Text=" Capture full screen with overlay"/>
121+
</TextBlock>
122+
<TextBlock Foreground="#B0B0B0"
123+
FontSize="11"
124+
FontFamily="Consolas"
125+
TextWrapping="Wrap"
126+
LineHeight="16">
127+
<Run Text="[S]" Foreground="#00FF00" FontWeight="Bold"/>
128+
<Run Text=" Open Windows Snipping Tool"/>
129+
</TextBlock>
130+
</StackPanel>
131+
</Border>
132+
</StackPanel>
133+
</GroupBox>
134+
</UserControl>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using System.Windows;
2+
using GhostDraw.Services;
3+
using Microsoft.Win32;
4+
using WpfUserControl = System.Windows.Controls.UserControl;
5+
6+
namespace GhostDraw.Views.UserControls;
7+
8+
public partial class ScreenshotSettingsControl : WpfUserControl
9+
{
10+
private int _updateNestingLevel = 0;
11+
12+
// DependencyProperty for AppSettings
13+
public static readonly DependencyProperty AppSettingsProperty =
14+
DependencyProperty.Register(
15+
nameof(AppSettings),
16+
typeof(AppSettingsService),
17+
typeof(ScreenshotSettingsControl),
18+
new PropertyMetadata(null, OnAppSettingsChanged));
19+
20+
public AppSettingsService? AppSettings
21+
{
22+
get => (AppSettingsService?)GetValue(AppSettingsProperty);
23+
set => SetValue(AppSettingsProperty, value);
24+
}
25+
26+
private static void OnAppSettingsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
27+
{
28+
if (d is ScreenshotSettingsControl control && e.NewValue is AppSettingsService appSettings)
29+
{
30+
control.Initialize(appSettings);
31+
}
32+
}
33+
34+
public ScreenshotSettingsControl()
35+
{
36+
InitializeComponent();
37+
}
38+
39+
private void Initialize(AppSettingsService appSettings)
40+
{
41+
LoadSettings(appSettings);
42+
}
43+
44+
private void LoadSettings(AppSettingsService appSettings)
45+
{
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;
51+
}
52+
53+
private void BrowseButton_Click(object sender, RoutedEventArgs e)
54+
{
55+
if (AppSettings == null) return;
56+
57+
var dialog = new OpenFolderDialog
58+
{
59+
Title = "Select Screenshot Save Location",
60+
InitialDirectory = AppSettings.CurrentSettings.ScreenshotSavePath
61+
};
62+
63+
if (dialog.ShowDialog() == true)
64+
{
65+
var selectedPath = dialog.FolderName;
66+
SavePathTextBox.Text = selectedPath;
67+
AppSettings.SetScreenshotSavePath(selectedPath);
68+
}
69+
}
70+
71+
private void CopyToClipboardCheckBox_Changed(object sender, RoutedEventArgs e)
72+
{
73+
if (_updateNestingLevel == 0 && CopyToClipboardCheckBox.IsChecked.HasValue && AppSettings != null)
74+
{
75+
AppSettings.SetCopyScreenshotToClipboard(CopyToClipboardCheckBox.IsChecked.Value);
76+
}
77+
}
78+
79+
private void OpenFolderCheckBox_Changed(object sender, RoutedEventArgs e)
80+
{
81+
if (_updateNestingLevel == 0 && OpenFolderCheckBox.IsChecked.HasValue && AppSettings != null)
82+
{
83+
AppSettings.SetOpenFolderAfterScreenshot(OpenFolderCheckBox.IsChecked.Value);
84+
}
85+
}
86+
87+
private void PlaySoundCheckBox_Changed(object sender, RoutedEventArgs e)
88+
{
89+
if (_updateNestingLevel == 0 && PlaySoundCheckBox.IsChecked.HasValue && AppSettings != null)
90+
{
91+
AppSettings.SetPlayShutterSound(PlaySoundCheckBox.IsChecked.Value);
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)