Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions Helpers/StackPanelHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System.Windows;
using System.Windows.Controls;

namespace PrettyScreenSHOT.Helpers
{
/// <summary>
/// Helper class that adds Spacing support to StackPanel (WPF compatibility)
/// </summary>
public static class StackPanelHelper
{
/// <summary>
/// Attached property for adding spacing between StackPanel children
/// </summary>
public static readonly DependencyProperty SpacingProperty =
DependencyProperty.RegisterAttached(
"Spacing",
typeof(double),
typeof(StackPanelHelper),
new PropertyMetadata(0.0, OnSpacingChanged));

public static double GetSpacing(DependencyObject obj)
{
return (double)obj.GetValue(SpacingProperty);
}

public static void SetSpacing(DependencyObject obj, double value)
{
obj.SetValue(SpacingProperty, value);
}

private static void OnSpacingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is StackPanel stackPanel)
{
stackPanel.Loaded -= StackPanel_Loaded;
stackPanel.Loaded += StackPanel_Loaded;

if (stackPanel.IsLoaded)
{
ApplySpacing(stackPanel);
}
}
}

private static void StackPanel_Loaded(object sender, RoutedEventArgs e)
{
if (sender is StackPanel stackPanel)
{
ApplySpacing(stackPanel);
}
}

private static void ApplySpacing(StackPanel stackPanel)
{
var spacing = GetSpacing(stackPanel);
var isHorizontal = stackPanel.Orientation == Orientation.Horizontal;

for (int i = 0; i < stackPanel.Children.Count; i++)
{
if (stackPanel.Children[i] is FrameworkElement element)
{
if (i == 0)
{
// First element - no spacing
element.Margin = new Thickness(0);
}
else
{
// Add spacing to the left (horizontal) or top (vertical)
if (isHorizontal)
{
element.Margin = new Thickness(spacing, 0, 0, 0);
}
else
{
element.Margin = new Thickness(0, spacing, 0, 0);
}
}
}
}
}
}
}
11 changes: 6 additions & 5 deletions Views/Dialogs/SaveScreenshotDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
Title="Save Screenshot"
Height="450"
Width="520"
Expand Down Expand Up @@ -33,9 +34,9 @@

<!-- Input Fields Card -->
<ui:Card Grid.Row="0">
<StackPanel Spacing="16">
<StackPanel helpers:StackPanelHelper.Spacing="16">
<!-- Category -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="CategoryLabel"
Text="Category:"
FontWeight="SemiBold"/>
Expand All @@ -44,7 +45,7 @@
</StackPanel>

<!-- Tags -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="TagsLabel"
Text="Tags (comma separated):"
FontWeight="SemiBold"/>
Expand All @@ -54,7 +55,7 @@
</StackPanel>

<!-- Notes -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="NotesLabel"
Text="Notes:"
FontWeight="SemiBold"/>
Expand All @@ -70,7 +71,7 @@
<StackPanel Grid.Row="1"
Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8"
helpers:StackPanelHelper.Spacing="8"
Margin="0,16,0,0">
<ui:Button x:Name="CancelButton"
Content="Cancel"
Expand Down
11 changes: 6 additions & 5 deletions Views/Windows/ScreenshotEditorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
Title="Screenshot Editor"
Height="800"
Width="1200"
Expand All @@ -21,7 +22,7 @@
<ui:TitleBar Title="Screenshot Editor"
Icon="pack://application:,,,/app.ico">
<ui:TitleBar.Header>
<StackPanel Orientation="Horizontal" Margin="8,0,0,0" Spacing="4">
<StackPanel Orientation="Horizontal" Margin="8,0,0,0" helpers:StackPanelHelper.Spacing="4">
<ui:Button Icon="Copy24"
Appearance="Transparent"
ToolTip="Copy"
Expand Down Expand Up @@ -57,7 +58,7 @@
<StackPanel Orientation="Vertical"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Spacing="8">
helpers:StackPanelHelper.Spacing="8">
<ui:Button Icon="Wifi124"
Appearance="Secondary"
ToolTip="WiFi"/>
Expand Down Expand Up @@ -85,7 +86,7 @@

<!-- Górny pasek z akcjami -->
<ui:Card Grid.Row="0" Margin="0,0,0,12" Padding="12">
<StackPanel Orientation="Horizontal" Spacing="8">
<StackPanel Orientation="Horizontal" helpers:StackPanelHelper.Spacing="8">
<!-- Color Picker -->
<TextBlock Text="KOLOR:"
VerticalAlignment="Center"
Expand Down Expand Up @@ -180,7 +181,7 @@
<StackPanel Orientation="Vertical"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Spacing="8">
helpers:StackPanelHelper.Spacing="8">
<TextBlock Text="NARZĘDZIA"
FontWeight="SemiBold"
FontSize="12"
Expand Down Expand Up @@ -256,7 +257,7 @@
Grid.Row="1"
Margin="0,0,12,12"
Padding="12">
<StackPanel Orientation="Horizontal" Spacing="8">
<StackPanel Orientation="Horizontal" helpers:StackPanelHelper.Spacing="8">
<TextBlock Text="FORMATOWANIE TEKSTU:"
FontWeight="SemiBold"
VerticalAlignment="Center"
Expand Down
5 changes: 3 additions & 2 deletions Views/Windows/ScreenshotHistoryWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:PrettyScreenSHOT"
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
Title="Screenshot History"
Height="650"
Width="720"
Expand Down Expand Up @@ -98,7 +99,7 @@
<!-- Info -->
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
Spacing="4">
helpers:StackPanelHelper.Spacing="4">
<TextBlock Text="{Binding Filename}"
FontWeight="Medium"
FontSize="14"/>
Expand Down Expand Up @@ -135,7 +136,7 @@
<StackPanel Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center"
Spacing="8">
helpers:StackPanelHelper.Spacing="8">
<!-- Upload Button (if not uploaded) -->
<ui:Button Click="OnUploadClick"
Icon="ArrowUpload24"
Expand Down
12 changes: 6 additions & 6 deletions Views/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
Title="Ustawienia"
Height="650"
Width="720"
Expand All @@ -20,12 +21,11 @@
<ui:TitleBar Grid.Row="0"
x:Name="TitleText"
Title="Ustawienia"
Icon="pack://application:,,,/app.ico"
UseSnapLayout="True"/>
Icon="pack://application:,,,/app.ico"/>

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

<!-- Language -->
<ui:Card>
Expand Down Expand Up @@ -90,7 +90,7 @@

<!-- Image Quality -->
<ui:Card>
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="ImageQualityLabel" Text="Image Quality:"/>
<Grid>
<Grid.ColumnDefinitions>
Expand All @@ -116,7 +116,7 @@

<!-- Options -->
<ui:Card>
<StackPanel Spacing="12">
<StackPanel helpers:StackPanelHelper.Spacing="12">
<TextBlock Text="Options" FontSize="16" FontWeight="SemiBold"/>
<CheckBox x:Name="AutoSaveCheckBox" Content="Auto Save"/>
<CheckBox x:Name="CopyToClipboardCheckBox" Content="Copy to Clipboard"/>
Expand All @@ -141,7 +141,7 @@
<!-- Action Buttons -->
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8"
helpers:StackPanelHelper.Spacing="8"
Margin="0,16,0,0">
<ui:Button x:Name="ResetButton"
Content="Reset to Defaults"
Expand Down
33 changes: 17 additions & 16 deletions Views/Windows/TextInputWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:helpers="clr-namespace:PrettyScreenSHOT.Helpers"
Title="Dodaj Tekst"
Height="720"
Width="540"
Expand All @@ -26,11 +27,11 @@

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

<!-- Text Input Card -->
<ui:Card>
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="TextLabel"
Text="Text:"
FontWeight="SemiBold"/>
Expand All @@ -44,20 +45,20 @@

<!-- Font Settings Card -->
<ui:Card>
<StackPanel Spacing="16">
<StackPanel helpers:StackPanelHelper.Spacing="16">
<TextBlock Text="Ustawienia czcionki"
FontSize="16"
FontWeight="SemiBold"/>

<!-- Font Family -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock Text="Czcionka:" FontWeight="Medium"/>
<ComboBox x:Name="FontFamilyComboBox"
SelectionChanged="FontFamilyComboBox_SelectionChanged"/>
</StackPanel>

<!-- Font Size -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="FontSizeTextLabel"
Text="Rozmiar czcionki:"
FontWeight="Medium"/>
Expand All @@ -82,9 +83,9 @@
</StackPanel>

<!-- Text Alignment -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock Text="Wyrównanie:" FontWeight="Medium"/>
<StackPanel Orientation="Horizontal" Spacing="12">
<StackPanel Orientation="Horizontal" helpers:StackPanelHelper.Spacing="12">
<RadioButton x:Name="AlignLeftRadio"
Content="Lewo"
GroupName="Alignment"
Expand All @@ -102,7 +103,7 @@
</StackPanel>

<!-- Text Style Options -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock Text="Styl tekstu:" FontWeight="Medium"/>
<WrapPanel Orientation="Horizontal">
<CheckBox x:Name="BoldCheckBox"
Expand Down Expand Up @@ -132,13 +133,13 @@

<!-- Color Settings Card -->
<ui:Card>
<StackPanel Spacing="16">
<StackPanel helpers:StackPanelHelper.Spacing="16">
<TextBlock Text="Kolory"
FontSize="16"
FontWeight="SemiBold"/>

<!-- Text Color -->
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock Text="Kolor tekstu:" FontWeight="Medium"/>
<ComboBox x:Name="ColorComboBox"
SelectedIndex="0"
Expand All @@ -155,7 +156,7 @@
</StackPanel>

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

<!-- Stroke Settings Card -->
<ui:Card>
<StackPanel Spacing="16">
<StackPanel helpers:StackPanelHelper.Spacing="16">
<TextBlock Text="Obramowanie"
FontSize="16"
FontWeight="SemiBold"/>
Expand All @@ -186,7 +187,7 @@
</Grid.ColumnDefinitions>

<!-- Stroke Color -->
<StackPanel Grid.Column="0" Spacing="8" Margin="0,0,12,0">
<StackPanel Grid.Column="0" helpers:StackPanelHelper.Spacing="8" Margin="0,0,12,0">
<TextBlock Text="Kolor:" FontWeight="Medium"/>
<ComboBox x:Name="StrokeColorComboBox"
SelectedIndex="0"
Expand All @@ -199,7 +200,7 @@
</StackPanel>

<!-- Stroke Thickness -->
<StackPanel Grid.Column="1" Spacing="8" MinWidth="140">
<StackPanel Grid.Column="1" helpers:StackPanelHelper.Spacing="8" MinWidth="140">
<TextBlock Text="Grubość:" FontWeight="Medium"/>
<Grid>
<Grid.ColumnDefinitions>
Expand All @@ -226,7 +227,7 @@

<!-- Preview Card -->
<ui:Card>
<StackPanel Spacing="8">
<StackPanel helpers:StackPanelHelper.Spacing="8">
<TextBlock x:Name="PreviewLabel"
Text="Podgląd:"
FontWeight="SemiBold"/>
Expand All @@ -249,7 +250,7 @@
<!-- Action Buttons -->
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8"
helpers:StackPanelHelper.Spacing="8"
Margin="0,8,0,0">
<ui:Button x:Name="OkButton"
Content="OK"
Expand Down
Loading
Loading