From 171642d3027683cac1b6d31befc944e8c3640a29 Mon Sep 17 00:00:00 2001 From: netquick Date: Wed, 17 Jul 2024 23:18:12 +0200 Subject: [PATCH] FavoriteStar fixed, visual fixes, settings added for gamepath --- DeFRaG_Helper/App.xaml | 2 + .../Converters/BoolToVisibilityConverter.cs | 44 +++++++++--- .../Converters/IntToBoolConverter.cs | 21 ++++++ DeFRaG_Helper/CustomStyles.xaml | 71 ++++++++++++++++--- DeFRaG_Helper/Helpers/CreateAndUpdateDB.cs | 8 ++- .../UserControls/DropDownButton.xaml.cs | 6 +- DeFRaG_Helper/UserControls/HighLightCard.xaml | 20 ++++-- DeFRaG_Helper/UserControls/MapCard.xaml | 27 ++++--- DeFRaG_Helper/UserControls/MapCard.xaml.cs | 61 ++++++++++++++-- DeFRaG_Helper/ViewModels/MapViewModel.cs | 4 ++ DeFRaG_Helper/ViewModels/ServerViewModel.cs | 5 +- DeFRaG_Helper/Views/Maps.xaml | 4 +- DeFRaG_Helper/Views/Settings.xaml | 34 ++------- DeFRaG_Helper/Views/Settings.xaml.cs | 58 +++++++++++++++ 14 files changed, 290 insertions(+), 75 deletions(-) create mode 100644 DeFRaG_Helper/Converters/IntToBoolConverter.cs diff --git a/DeFRaG_Helper/App.xaml b/DeFRaG_Helper/App.xaml index 7daa918..05a33b3 100644 --- a/DeFRaG_Helper/App.xaml +++ b/DeFRaG_Helper/App.xaml @@ -13,6 +13,8 @@ + + diff --git a/DeFRaG_Helper/Converters/BoolToVisibilityConverter.cs b/DeFRaG_Helper/Converters/BoolToVisibilityConverter.cs index e697a06..b988859 100644 --- a/DeFRaG_Helper/Converters/BoolToVisibilityConverter.cs +++ b/DeFRaG_Helper/Converters/BoolToVisibilityConverter.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Data; @@ -13,15 +9,45 @@ public class BoolToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - // Assuming the value is a boolean and targetType is Visibility - bool isVisible = (bool)value; + bool isVisible; + + if (value is int intValue) + { + isVisible = intValue != 0; // Treat non-zero integers as true + } + else if (value is bool boolValue) + { + isVisible = boolValue; + } + else + { + throw new InvalidOperationException("Unsupported type"); + } + + bool invert = parameter != null && bool.Parse((string)parameter); + + if (invert) isVisible = !isVisible; + return isVisible ? Visibility.Visible : Visibility.Collapsed; } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - // ConvertBack is not necessary for this use case - throw new NotImplementedException(); + if (value is bool boolValue) + { + // Convert boolean back to integer (0 or 1) for SQLite storage. + return boolValue ? 1 : 0; + } + else + { + throw new ArgumentException("Expected value to be of type Boolean", nameof(value)); + } } + + + + } + } diff --git a/DeFRaG_Helper/Converters/IntToBoolConverter.cs b/DeFRaG_Helper/Converters/IntToBoolConverter.cs new file mode 100644 index 0000000..b55ef7a --- /dev/null +++ b/DeFRaG_Helper/Converters/IntToBoolConverter.cs @@ -0,0 +1,21 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace DeFRaG_Helper.Converters +{ + public class IntToBoolConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + // Assuming 1 represents true/favorite, and 0 (or null) represents false/not favorite + return value is int intValue && intValue == 1; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + // Convert back to integer representation for the database + return value is bool boolValue && boolValue ? 1 : 0; + } + } +} diff --git a/DeFRaG_Helper/CustomStyles.xaml b/DeFRaG_Helper/CustomStyles.xaml index 398c80b..1caa895 100644 --- a/DeFRaG_Helper/CustomStyles.xaml +++ b/DeFRaG_Helper/CustomStyles.xaml @@ -817,16 +817,48 @@ + + + + + + + -