Skip to content

Commit 195dbdd

Browse files
committed
feat(ui): Sprint 1 - Fundamenty i porządki GUI
Wykonano wszystkie zadania Sprint 1 zgodnie z planem modernizacji UI: ## Migracja z WinForms do WPF/Wpf.Ui - Zastąpiono FolderBrowserDialog → Microsoft.Win32.OpenFolderDialog - Zastąpiono ColorDialog → nowy ColorPickerDialog (Wpf.Ui) - Utworzono MessageBoxHelper dla Wpf.Ui.Controls.MessageBox - Zunifikowano wszystkie wywołania MessageBox w projekcie ## Porządki w kodzie - Uporządkowano i usunięto nieużywane aliasy w plikach code-behind - Skonsolidowano konwertery w katalogu Converters/ - Zarejestrowano NullToVisibilityConverter globalnie w App.xaml ## Baza stylów Utworzono kompletną strukturę zasobów tematycznych: - Themes/Colors.xaml - definicje kolorów brandowych i statusowych - Themes/Typography.xaml - spójne style tekstowe - Themes/Spacing.xaml - wartości odstępów i zaokrągleń - Themes/Base.xaml - główny plik łączący wszystkie zasoby - Zaktualizowano App.xaml aby używał Base.xaml ## Nowe pliki - Converters/NullToVisibilityConverter.cs - Helpers/MessageBoxHelper.cs - Views/Dialogs/ColorPickerDialog.xaml[.cs] - Themes/Base.xaml, Colors.xaml, Typography.xaml, Spacing.xaml Wszystkie zmiany zgodne z dokumentacją w docs/planning/sprint-1-*.md
1 parent 53259d7 commit 195dbdd

15 files changed

Lines changed: 494 additions & 84 deletions

App.xaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
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:local="clr-namespace:PrettyScreenSHOT">
5+
xmlns:local="clr-namespace:PrettyScreenSHOT"
6+
xmlns:converters="clr-namespace:PrettyScreenSHOT.Converters">
67
<Application.Resources>
78
<ResourceDictionary>
89
<ResourceDictionary.MergedDictionaries>
910
<!-- WPF UI Theme Resources -->
1011
<ui:ThemesDictionary Theme="Dark" />
1112
<ui:ControlsDictionary />
1213

13-
<!-- Custom WPF UI Styles -->
14-
<ResourceDictionary Source="pack://application:,,,/Themes/WpfUiCustom.xaml"/>
14+
<!-- Application Base Theme (includes Colors, Typography, Spacing, and Custom Styles) -->
15+
<ResourceDictionary Source="pack://application:,,,/Themes/Base.xaml"/>
1516
</ResourceDictionary.MergedDictionaries>
17+
18+
<!-- Global Converters -->
19+
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
1620
</ResourceDictionary>
1721
</Application.Resources>
1822
</Application>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace PrettyScreenSHOT.Converters
7+
{
8+
/// <summary>
9+
/// Converts null or empty values to Visibility
10+
/// </summary>
11+
public class NullToVisibilityConverter : IValueConverter
12+
{
13+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14+
{
15+
bool isInverse = parameter?.ToString() == "Inverse";
16+
bool isNull = value == null || (value is string str && string.IsNullOrEmpty(str));
17+
18+
if (isInverse)
19+
return isNull ? Visibility.Visible : Visibility.Collapsed;
20+
else
21+
return !isNull ? Visibility.Visible : Visibility.Collapsed;
22+
}
23+
24+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25+
{
26+
throw new NotImplementedException();
27+
}
28+
}
29+
}

Helpers/DebugHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class DebugHelper
1313
[System.Diagnostics.Conditional("DEBUG")]
1414
public static void ShowMessage(string title, string message)
1515
{
16-
System.Windows.MessageBox.Show(message, title);
16+
MessageBoxHelper.Show(message, title);
1717
}
1818

1919
/// <summary>

Helpers/MessageBoxHelper.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System.Windows;
2+
using Wpf.Ui.Controls;
3+
4+
namespace PrettyScreenSHOT.Helpers
5+
{
6+
/// <summary>
7+
/// Helper for showing Wpf.Ui MessageBoxes with a simplified API
8+
/// </summary>
9+
public static class MessageBoxHelper
10+
{
11+
public static MessageBoxResult Show(
12+
string message,
13+
string title,
14+
MessageBoxButton button = MessageBoxButton.OK)
15+
{
16+
return Application.Current.Dispatcher.Invoke(() =>
17+
{
18+
var messageBox = new Wpf.Ui.Controls.MessageBox
19+
{
20+
Title = title,
21+
Content = message,
22+
ButtonLeftName = GetButtonName(button, true),
23+
ButtonRightName = GetButtonName(button, false)
24+
};
25+
26+
var result = messageBox.ShowDialogAsync().GetAwaiter().GetResult();
27+
return MapToMessageBoxResult(result, button);
28+
});
29+
}
30+
31+
private static string GetButtonName(MessageBoxButton button, bool isLeft)
32+
{
33+
return button switch
34+
{
35+
MessageBoxButton.OK => isLeft ? "OK" : string.Empty,
36+
MessageBoxButton.OKCancel => isLeft ? "OK" : "Cancel",
37+
MessageBoxButton.YesNo => isLeft ? "Yes" : "No",
38+
MessageBoxButton.YesNoCancel => isLeft ? "Yes" : (isLeft ? "No" : "Cancel"),
39+
_ => isLeft ? "OK" : string.Empty
40+
};
41+
}
42+
43+
private static MessageBoxResult MapToMessageBoxResult(
44+
Wpf.Ui.Controls.MessageBoxResult wpfUiResult,
45+
MessageBoxButton buttonType)
46+
{
47+
return buttonType switch
48+
{
49+
MessageBoxButton.OK => MessageBoxResult.OK,
50+
MessageBoxButton.OKCancel => wpfUiResult == Wpf.Ui.Controls.MessageBoxResult.Primary
51+
? MessageBoxResult.OK
52+
: MessageBoxResult.Cancel,
53+
MessageBoxButton.YesNo => wpfUiResult == Wpf.Ui.Controls.MessageBoxResult.Primary
54+
? MessageBoxResult.Yes
55+
: MessageBoxResult.No,
56+
MessageBoxButton.YesNoCancel => wpfUiResult switch
57+
{
58+
Wpf.Ui.Controls.MessageBoxResult.Primary => MessageBoxResult.Yes,
59+
Wpf.Ui.Controls.MessageBoxResult.Secondary => MessageBoxResult.No,
60+
_ => MessageBoxResult.Cancel
61+
},
62+
_ => MessageBoxResult.None
63+
};
64+
}
65+
}
66+
}

Themes/Base.xaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<!--
5+
Base Theme for PrettyScreenSHOT
6+
7+
This file merges all theme resources into a single dictionary.
8+
Include this in App.xaml to apply all custom styles and resources.
9+
-->
10+
11+
<ResourceDictionary.MergedDictionaries>
12+
<!-- Core theme resources -->
13+
<ResourceDictionary Source="pack://application:,,,/Themes/Colors.xaml"/>
14+
<ResourceDictionary Source="pack://application:,,,/Themes/Typography.xaml"/>
15+
<ResourceDictionary Source="pack://application:,,,/Themes/Spacing.xaml"/>
16+
17+
<!-- Custom WPF UI overrides -->
18+
<ResourceDictionary Source="pack://application:,,,/Themes/WpfUiCustom.xaml"/>
19+
</ResourceDictionary.MergedDictionaries>
20+
21+
</ResourceDictionary>

Themes/Colors.xaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<!--
5+
Color Definitions for PrettyScreenSHOT
6+
7+
These colors complement WPF UI's theme system and provide brand-specific colors.
8+
WPF UI provides automatic Light/Dark theme support through DynamicResource.
9+
-->
10+
11+
<!-- Brand Colors -->
12+
<SolidColorBrush x:Key="BrandPrimaryBrush" Color="#007ACC"/>
13+
<SolidColorBrush x:Key="BrandSecondaryBrush" Color="#005A9E"/>
14+
15+
<!-- Status Colors -->
16+
<SolidColorBrush x:Key="SuccessBrush" Color="#4CAF50"/>
17+
<SolidColorBrush x:Key="WarningBrush" Color="#FF9800"/>
18+
<SolidColorBrush x:Key="ErrorBrush" Color="#F44336"/>
19+
<SolidColorBrush x:Key="InfoBrush" Color="#2196F3"/>
20+
21+
<!-- Semantic Colors -->
22+
<SolidColorBrush x:Key="RecordingIndicatorBrush" Color="#F44336"/>
23+
<SolidColorBrush x:Key="SavedIndicatorBrush" Color="#4CAF50"/>
24+
25+
<!--
26+
Note: For theme-aware colors (that change with Light/Dark theme),
27+
use WPF UI's built-in DynamicResources like:
28+
- TextFillColorPrimaryBrush
29+
- TextFillColorSecondaryBrush
30+
- ControlFillColorDefaultBrush
31+
- etc.
32+
-->
33+
34+
</ResourceDictionary>

Themes/Spacing.xaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<!--
5+
Spacing Definitions for PrettyScreenSHOT
6+
7+
Defines consistent spacing values across the application.
8+
Use these values for margins, padding, and spacing between elements.
9+
-->
10+
11+
<!-- Spacing Values (System) -->
12+
<System:Double xmlns:System="clr-namespace:System;assembly=mscorlib" x:Key="SpacingXSmall">4</System:Double>
13+
<System:Double xmlns:System="clr-namespace:System;assembly=mscorlib" x:Key="SpacingSmall">8</System:Double>
14+
<System:Double xmlns:System="clr-namespace:System;assembly=mscorlib" x:Key="SpacingMedium">12</System:Double>
15+
<System:Double xmlns:System="clr-namespace:System;assembly=mscorlib" x:Key="SpacingLarge">16</System:Double>
16+
<System:Double xmlns:System="clr-namespace:System;assembly=mscorlib" x:Key="SpacingXLarge">20</System:Double>
17+
<System:Double xmlns:System="clr-namespace:System;assembly=mscorlib" x:Key="SpacingXXLarge">24</System:Double>
18+
19+
<!-- Thickness Values -->
20+
<Thickness x:Key="PaddingSmall">8</Thickness>
21+
<Thickness x:Key="PaddingMedium">12</Thickness>
22+
<Thickness x:Key="PaddingLarge">16</Thickness>
23+
<Thickness x:Key="PaddingXLarge">20</Thickness>
24+
25+
<Thickness x:Key="MarginSmall">0,0,0,8</Thickness>
26+
<Thickness x:Key="MarginMedium">0,0,0,12</Thickness>
27+
<Thickness x:Key="MarginLarge">0,0,0,16</Thickness>
28+
<Thickness x:Key="MarginXLarge">0,0,0,20</Thickness>
29+
30+
<!-- Border Thickness -->
31+
<Thickness x:Key="BorderThin">1</Thickness>
32+
<Thickness x:Key="BorderMedium">2</Thickness>
33+
<Thickness x:Key="BorderThick">3</Thickness>
34+
35+
<!-- Corner Radius -->
36+
<CornerRadius x:Key="CornerRadiusSmall">4</CornerRadius>
37+
<CornerRadius x:Key="CornerRadiusMedium">8</CornerRadius>
38+
<CornerRadius x:Key="CornerRadiusLarge">12</CornerRadius>
39+
<CornerRadius x:Key="CornerRadiusCircle">999</CornerRadius>
40+
41+
</ResourceDictionary>

Themes/Typography.xaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<!--
5+
Typography Definitions for PrettyScreenSHOT
6+
7+
Defines text styles for consistent typography across the application.
8+
-->
9+
10+
<!-- Title Styles -->
11+
<Style x:Key="TitleLargeText" TargetType="TextBlock">
12+
<Setter Property="FontSize" Value="28"/>
13+
<Setter Property="FontWeight" Value="SemiBold"/>
14+
<Setter Property="Margin" Value="0,0,0,16"/>
15+
</Style>
16+
17+
<Style x:Key="TitleText" TargetType="TextBlock">
18+
<Setter Property="FontSize" Value="24"/>
19+
<Setter Property="FontWeight" Value="SemiBold"/>
20+
<Setter Property="Margin" Value="0,0,0,12"/>
21+
</Style>
22+
23+
<Style x:Key="SubtitleText" TargetType="TextBlock">
24+
<Setter Property="FontSize" Value="20"/>
25+
<Setter Property="FontWeight" Value="SemiBold"/>
26+
<Setter Property="Margin" Value="0,0,0,12"/>
27+
</Style>
28+
29+
<!-- Header Styles -->
30+
<Style x:Key="HeaderText" TargetType="TextBlock">
31+
<Setter Property="FontSize" Value="18"/>
32+
<Setter Property="FontWeight" Value="SemiBold"/>
33+
<Setter Property="Margin" Value="0,0,0,8"/>
34+
</Style>
35+
36+
<Style x:Key="SubheaderText" TargetType="TextBlock">
37+
<Setter Property="FontSize" Value="16"/>
38+
<Setter Property="FontWeight" Value="Medium"/>
39+
<Setter Property="Margin" Value="0,0,0,8"/>
40+
</Style>
41+
42+
<!-- Body Styles -->
43+
<Style x:Key="BodyLargeText" TargetType="TextBlock">
44+
<Setter Property="FontSize" Value="15"/>
45+
<Setter Property="FontWeight" Value="Regular"/>
46+
</Style>
47+
48+
<Style x:Key="BodyText" TargetType="TextBlock">
49+
<Setter Property="FontSize" Value="14"/>
50+
<Setter Property="FontWeight" Value="Regular"/>
51+
</Style>
52+
53+
<Style x:Key="BodySmallText" TargetType="TextBlock">
54+
<Setter Property="FontSize" Value="13"/>
55+
<Setter Property="FontWeight" Value="Regular"/>
56+
</Style>
57+
58+
<!-- Caption/Label Styles -->
59+
<Style x:Key="CaptionText" TargetType="TextBlock">
60+
<Setter Property="FontSize" Value="12"/>
61+
<Setter Property="FontWeight" Value="Regular"/>
62+
<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}"/>
63+
</Style>
64+
65+
<Style x:Key="LabelText" TargetType="TextBlock">
66+
<Setter Property="FontSize" Value="13"/>
67+
<Setter Property="FontWeight" Value="SemiBold"/>
68+
<Setter Property="Margin" Value="0,0,0,4"/>
69+
</Style>
70+
71+
<!-- Monospace Styles -->
72+
<Style x:Key="MonospaceText" TargetType="TextBlock">
73+
<Setter Property="FontFamily" Value="Consolas, Courier New, monospace"/>
74+
<Setter Property="FontSize" Value="13"/>
75+
</Style>
76+
77+
</ResourceDictionary>

0 commit comments

Comments
 (0)