Skip to content

Commit c7d4801

Browse files
authored
Merge pull request #31 from Co0ob1iee/claude/cleanup-logs-project-01CgeLKK4Nw2cK3rDJdLF88m
fix: Replace StackPanel.Spacing with StackPanelHelper for WPF compati…
2 parents 665de2a + dcdf1a5 commit c7d4801

10 files changed

Lines changed: 139 additions & 48 deletions

Helpers/StackPanelHelper.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
4+
namespace PrettyScreenSHOT.Helpers
5+
{
6+
/// <summary>
7+
/// Helper class that adds Spacing support to StackPanel (WPF compatibility)
8+
/// </summary>
9+
public static class StackPanelHelper
10+
{
11+
/// <summary>
12+
/// Attached property for adding spacing between StackPanel children
13+
/// </summary>
14+
public static readonly DependencyProperty SpacingProperty =
15+
DependencyProperty.RegisterAttached(
16+
"Spacing",
17+
typeof(double),
18+
typeof(StackPanelHelper),
19+
new PropertyMetadata(0.0, OnSpacingChanged));
20+
21+
public static double GetSpacing(DependencyObject obj)
22+
{
23+
return (double)obj.GetValue(SpacingProperty);
24+
}
25+
26+
public static void SetSpacing(DependencyObject obj, double value)
27+
{
28+
obj.SetValue(SpacingProperty, value);
29+
}
30+
31+
private static void OnSpacingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
32+
{
33+
if (d is StackPanel stackPanel)
34+
{
35+
stackPanel.Loaded -= StackPanel_Loaded;
36+
stackPanel.Loaded += StackPanel_Loaded;
37+
38+
if (stackPanel.IsLoaded)
39+
{
40+
ApplySpacing(stackPanel);
41+
}
42+
}
43+
}
44+
45+
private static void StackPanel_Loaded(object sender, RoutedEventArgs e)
46+
{
47+
if (sender is StackPanel stackPanel)
48+
{
49+
ApplySpacing(stackPanel);
50+
}
51+
}
52+
53+
private static void ApplySpacing(StackPanel stackPanel)
54+
{
55+
var spacing = GetSpacing(stackPanel);
56+
var isHorizontal = stackPanel.Orientation == Orientation.Horizontal;
57+
58+
for (int i = 0; i < stackPanel.Children.Count; i++)
59+
{
60+
if (stackPanel.Children[i] is FrameworkElement element)
61+
{
62+
if (i == 0)
63+
{
64+
// First element - no spacing
65+
element.Margin = new Thickness(0);
66+
}
67+
else
68+
{
69+
// Add spacing to the left (horizontal) or top (vertical)
70+
if (isHorizontal)
71+
{
72+
element.Margin = new Thickness(spacing, 0, 0, 0);
73+
}
74+
else
75+
{
76+
element.Margin = new Thickness(0, spacing, 0, 0);
77+
}
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}

Views/Dialogs/SaveScreenshotDialog.xaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
5+
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
56
Title="Save Screenshot"
67
Height="450"
78
Width="520"
@@ -33,9 +34,9 @@
3334

3435
<!-- Input Fields Card -->
3536
<ui:Card Grid.Row="0">
36-
<StackPanel Spacing="16">
37+
<StackPanel helpers:StackPanelHelper.Spacing="16">
3738
<!-- Category -->
38-
<StackPanel Spacing="8">
39+
<StackPanel helpers:StackPanelHelper.Spacing="8">
3940
<TextBlock x:Name="CategoryLabel"
4041
Text="Category:"
4142
FontWeight="SemiBold"/>
@@ -44,7 +45,7 @@
4445
</StackPanel>
4546

4647
<!-- Tags -->
47-
<StackPanel Spacing="8">
48+
<StackPanel helpers:StackPanelHelper.Spacing="8">
4849
<TextBlock x:Name="TagsLabel"
4950
Text="Tags (comma separated):"
5051
FontWeight="SemiBold"/>
@@ -54,7 +55,7 @@
5455
</StackPanel>
5556

5657
<!-- Notes -->
57-
<StackPanel Spacing="8">
58+
<StackPanel helpers:StackPanelHelper.Spacing="8">
5859
<TextBlock x:Name="NotesLabel"
5960
Text="Notes:"
6061
FontWeight="SemiBold"/>
@@ -70,7 +71,7 @@
7071
<StackPanel Grid.Row="1"
7172
Orientation="Horizontal"
7273
HorizontalAlignment="Right"
73-
Spacing="8"
74+
helpers:StackPanelHelper.Spacing="8"
7475
Margin="0,16,0,0">
7576
<ui:Button x:Name="CancelButton"
7677
Content="Cancel"

Views/Windows/ScreenshotEditorWindow.xaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
5+
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
56
Title="Screenshot Editor"
67
Height="800"
78
Width="1200"
@@ -21,7 +22,7 @@
2122
<ui:TitleBar Title="Screenshot Editor"
2223
Icon="pack://application:,,,/app.ico">
2324
<ui:TitleBar.Header>
24-
<StackPanel Orientation="Horizontal" Margin="8,0,0,0" Spacing="4">
25+
<StackPanel Orientation="Horizontal" Margin="8,0,0,0" helpers:StackPanelHelper.Spacing="4">
2526
<ui:Button Icon="Copy24"
2627
Appearance="Transparent"
2728
ToolTip="Copy"
@@ -57,7 +58,7 @@
5758
<StackPanel Orientation="Vertical"
5859
VerticalAlignment="Top"
5960
HorizontalAlignment="Center"
60-
Spacing="8">
61+
helpers:StackPanelHelper.Spacing="8">
6162
<ui:Button Icon="Wifi124"
6263
Appearance="Secondary"
6364
ToolTip="WiFi"/>
@@ -85,7 +86,7 @@
8586

8687
<!-- Górny pasek z akcjami -->
8788
<ui:Card Grid.Row="0" Margin="0,0,0,12" Padding="12">
88-
<StackPanel Orientation="Horizontal" Spacing="8">
89+
<StackPanel Orientation="Horizontal" helpers:StackPanelHelper.Spacing="8">
8990
<!-- Color Picker -->
9091
<TextBlock Text="KOLOR:"
9192
VerticalAlignment="Center"
@@ -180,7 +181,7 @@
180181
<StackPanel Orientation="Vertical"
181182
VerticalAlignment="Top"
182183
HorizontalAlignment="Center"
183-
Spacing="8">
184+
helpers:StackPanelHelper.Spacing="8">
184185
<TextBlock Text="NARZĘDZIA"
185186
FontWeight="SemiBold"
186187
FontSize="12"
@@ -256,7 +257,7 @@
256257
Grid.Row="1"
257258
Margin="0,0,12,12"
258259
Padding="12">
259-
<StackPanel Orientation="Horizontal" Spacing="8">
260+
<StackPanel Orientation="Horizontal" helpers:StackPanelHelper.Spacing="8">
260261
<TextBlock Text="FORMATOWANIE TEKSTU:"
261262
FontWeight="SemiBold"
262263
VerticalAlignment="Center"

Views/Windows/ScreenshotHistoryWindow.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
55
xmlns:local="clr-namespace:PrettyScreenSHOT"
6+
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
67
Title="Screenshot History"
78
Height="650"
89
Width="720"
@@ -98,7 +99,7 @@
9899
<!-- Info -->
99100
<StackPanel Grid.Column="1"
100101
VerticalAlignment="Center"
101-
Spacing="4">
102+
helpers:StackPanelHelper.Spacing="4">
102103
<TextBlock Text="{Binding Filename}"
103104
FontWeight="Medium"
104105
FontSize="14"/>
@@ -135,7 +136,7 @@
135136
<StackPanel Grid.Column="2"
136137
Orientation="Horizontal"
137138
VerticalAlignment="Center"
138-
Spacing="8">
139+
helpers:StackPanelHelper.Spacing="8">
139140
<!-- Upload Button (if not uploaded) -->
140141
<ui:Button Click="OnUploadClick"
141142
Icon="ArrowUpload24"

Views/Windows/SettingsWindow.xaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
5+
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
56
Title="Ustawienia"
67
Height="650"
78
Width="720"
@@ -20,12 +21,11 @@
2021
<ui:TitleBar Grid.Row="0"
2122
x:Name="TitleText"
2223
Title="Ustawienia"
23-
Icon="pack://application:,,,/app.ico"
24-
UseSnapLayout="True"/>
24+
Icon="pack://application:,,,/app.ico"/>
2525

2626
<!-- Main Content -->
2727
<ScrollViewer Grid.Row="1" Margin="20" VerticalScrollBarVisibility="Auto">
28-
<StackPanel Spacing="16">
28+
<StackPanel helpers:StackPanelHelper.Spacing="16">
2929

3030
<!-- Language -->
3131
<ui:Card>
@@ -90,7 +90,7 @@
9090

9191
<!-- Image Quality -->
9292
<ui:Card>
93-
<StackPanel Spacing="8">
93+
<StackPanel helpers:StackPanelHelper.Spacing="8">
9494
<TextBlock x:Name="ImageQualityLabel" Text="Image Quality:"/>
9595
<Grid>
9696
<Grid.ColumnDefinitions>
@@ -116,7 +116,7 @@
116116

117117
<!-- Options -->
118118
<ui:Card>
119-
<StackPanel Spacing="12">
119+
<StackPanel helpers:StackPanelHelper.Spacing="12">
120120
<TextBlock Text="Options" FontSize="16" FontWeight="SemiBold"/>
121121
<CheckBox x:Name="AutoSaveCheckBox" Content="Auto Save"/>
122122
<CheckBox x:Name="CopyToClipboardCheckBox" Content="Copy to Clipboard"/>
@@ -141,7 +141,7 @@
141141
<!-- Action Buttons -->
142142
<StackPanel Orientation="Horizontal"
143143
HorizontalAlignment="Right"
144-
Spacing="8"
144+
helpers:StackPanelHelper.Spacing="8"
145145
Margin="0,16,0,0">
146146
<ui:Button x:Name="ResetButton"
147147
Content="Reset to Defaults"

Views/Windows/TextInputWindow.xaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
5+
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
56
Title="Dodaj Tekst"
67
Height="720"
78
Width="540"
@@ -26,11 +27,11 @@
2627

2728
<!-- Main Content -->
2829
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
29-
<StackPanel Margin="20" Spacing="16">
30+
<StackPanel Margin="20" helpers:StackPanelHelper.Spacing="16">
3031

3132
<!-- Text Input Card -->
3233
<ui:Card>
33-
<StackPanel Spacing="8">
34+
<StackPanel helpers:StackPanelHelper.Spacing="8">
3435
<TextBlock x:Name="TextLabel"
3536
Text="Text:"
3637
FontWeight="SemiBold"/>
@@ -44,20 +45,20 @@
4445

4546
<!-- Font Settings Card -->
4647
<ui:Card>
47-
<StackPanel Spacing="16">
48+
<StackPanel helpers:StackPanelHelper.Spacing="16">
4849
<TextBlock Text="Ustawienia czcionki"
4950
FontSize="16"
5051
FontWeight="SemiBold"/>
5152

5253
<!-- Font Family -->
53-
<StackPanel Spacing="8">
54+
<StackPanel helpers:StackPanelHelper.Spacing="8">
5455
<TextBlock Text="Czcionka:" FontWeight="Medium"/>
5556
<ComboBox x:Name="FontFamilyComboBox"
5657
SelectionChanged="FontFamilyComboBox_SelectionChanged"/>
5758
</StackPanel>
5859

5960
<!-- Font Size -->
60-
<StackPanel Spacing="8">
61+
<StackPanel helpers:StackPanelHelper.Spacing="8">
6162
<TextBlock x:Name="FontSizeTextLabel"
6263
Text="Rozmiar czcionki:"
6364
FontWeight="Medium"/>
@@ -82,9 +83,9 @@
8283
</StackPanel>
8384

8485
<!-- Text Alignment -->
85-
<StackPanel Spacing="8">
86+
<StackPanel helpers:StackPanelHelper.Spacing="8">
8687
<TextBlock Text="Wyrównanie:" FontWeight="Medium"/>
87-
<StackPanel Orientation="Horizontal" Spacing="12">
88+
<StackPanel Orientation="Horizontal" helpers:StackPanelHelper.Spacing="12">
8889
<RadioButton x:Name="AlignLeftRadio"
8990
Content="Lewo"
9091
GroupName="Alignment"
@@ -102,7 +103,7 @@
102103
</StackPanel>
103104

104105
<!-- Text Style Options -->
105-
<StackPanel Spacing="8">
106+
<StackPanel helpers:StackPanelHelper.Spacing="8">
106107
<TextBlock Text="Styl tekstu:" FontWeight="Medium"/>
107108
<WrapPanel Orientation="Horizontal">
108109
<CheckBox x:Name="BoldCheckBox"
@@ -132,13 +133,13 @@
132133

133134
<!-- Color Settings Card -->
134135
<ui:Card>
135-
<StackPanel Spacing="16">
136+
<StackPanel helpers:StackPanelHelper.Spacing="16">
136137
<TextBlock Text="Kolory"
137138
FontSize="16"
138139
FontWeight="SemiBold"/>
139140

140141
<!-- Text Color -->
141-
<StackPanel Spacing="8">
142+
<StackPanel helpers:StackPanelHelper.Spacing="8">
142143
<TextBlock Text="Kolor tekstu:" FontWeight="Medium"/>
143144
<ComboBox x:Name="ColorComboBox"
144145
SelectedIndex="0"
@@ -155,7 +156,7 @@
155156
</StackPanel>
156157

157158
<!-- Background Color -->
158-
<StackPanel Spacing="8">
159+
<StackPanel helpers:StackPanelHelper.Spacing="8">
159160
<TextBlock Text="Kolor tła (opcjonalnie):" FontWeight="Medium"/>
160161
<ComboBox x:Name="BackgroundColorComboBox"
161162
SelectedIndex="0"
@@ -174,7 +175,7 @@
174175

175176
<!-- Stroke Settings Card -->
176177
<ui:Card>
177-
<StackPanel Spacing="16">
178+
<StackPanel helpers:StackPanelHelper.Spacing="16">
178179
<TextBlock Text="Obramowanie"
179180
FontSize="16"
180181
FontWeight="SemiBold"/>
@@ -186,7 +187,7 @@
186187
</Grid.ColumnDefinitions>
187188

188189
<!-- Stroke Color -->
189-
<StackPanel Grid.Column="0" Spacing="8" Margin="0,0,12,0">
190+
<StackPanel Grid.Column="0" helpers:StackPanelHelper.Spacing="8" Margin="0,0,12,0">
190191
<TextBlock Text="Kolor:" FontWeight="Medium"/>
191192
<ComboBox x:Name="StrokeColorComboBox"
192193
SelectedIndex="0"
@@ -199,7 +200,7 @@
199200
</StackPanel>
200201

201202
<!-- Stroke Thickness -->
202-
<StackPanel Grid.Column="1" Spacing="8" MinWidth="140">
203+
<StackPanel Grid.Column="1" helpers:StackPanelHelper.Spacing="8" MinWidth="140">
203204
<TextBlock Text="Grubość:" FontWeight="Medium"/>
204205
<Grid>
205206
<Grid.ColumnDefinitions>
@@ -226,7 +227,7 @@
226227

227228
<!-- Preview Card -->
228229
<ui:Card>
229-
<StackPanel Spacing="8">
230+
<StackPanel helpers:StackPanelHelper.Spacing="8">
230231
<TextBlock x:Name="PreviewLabel"
231232
Text="Podgląd:"
232233
FontWeight="SemiBold"/>
@@ -249,7 +250,7 @@
249250
<!-- Action Buttons -->
250251
<StackPanel Orientation="Horizontal"
251252
HorizontalAlignment="Right"
252-
Spacing="8"
253+
helpers:StackPanelHelper.Spacing="8"
253254
Margin="0,8,0,0">
254255
<ui:Button x:Name="OkButton"
255256
Content="OK"

0 commit comments

Comments
 (0)