Skip to content

Commit 07847af

Browse files
committed
refactored dev tab
1 parent ac044ff commit 07847af

File tree

5 files changed

+209
-265
lines changed

5 files changed

+209
-265
lines changed

src/Avalonia.Desktop/Controls/CampaignsControl.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<helpers:ImagePathToBitmapConverter x:Key="ImagePathToBitmapConverter"/>
1515
</UserControl.Resources>
1616

17+
1718
<Grid RowDefinitions="auto,*,auto" ColumnDefinitions="2*,*">
1819

1920
<Grid ColumnDefinitions="auto,*,auto"

src/Avalonia.Desktop/Helpers/Converters.cs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Avalonia.Data;
22
using Avalonia.Data.Converters;
33
using Avalonia.Media.Imaging;
4+
using Common.Enums;
45
using Common.Helpers;
56
using System.Globalization;
67

@@ -27,6 +28,54 @@ public sealed class ImagePathToBitmapConverter : IValueConverter
2728

2829
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
2930
{
30-
return new BindingNotification(new NotImplementedException("ConvertBack method for ImagePathToBitmapConverter is not implemented."));
31+
return new BindingNotification(new NotImplementedException($"ConvertBack method for {nameof(ImagePathToBitmapConverter)} is not implemented."));
32+
}
33+
}
34+
35+
public sealed class GameStringToEnumConverter : IValueConverter
36+
{
37+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
38+
{
39+
if (value is not GameEnum valueEnum)
40+
{
41+
return false;
42+
}
43+
44+
if (parameter is not string paramStr)
45+
{
46+
throw new NotImplementedException();
47+
}
48+
49+
if (!Enum.TryParse<GameEnum>(paramStr, out var gameEnum))
50+
{
51+
throw new NotImplementedException();
52+
}
53+
54+
return valueEnum == gameEnum;
55+
}
56+
57+
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
58+
{
59+
if (value is not bool valueBool)
60+
{
61+
return AvaloniaProperty.UnsetValue;
62+
}
63+
64+
if (parameter is not string paramStr)
65+
{
66+
throw new NotImplementedException();
67+
}
68+
69+
if (!valueBool)
70+
{
71+
return AvaloniaProperty.UnsetValue;
72+
}
73+
74+
if (!Enum.TryParse<GameEnum>(paramStr, out var gameEnum))
75+
{
76+
throw new NotImplementedException();
77+
}
78+
79+
return gameEnum;
3180
}
3281
}

0 commit comments

Comments
 (0)