diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index b709916..993e78c 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -2,11 +2,14 @@ name: .NET env: PACK_ID: Sims1WidescreenPatcher - PACK_VER: 3.6.0 + PACK_VER: 3.7.0 on: push: + branches: ["master"] pull_request: + branches: ["master"] + workflow_dispatch: jobs: linux: diff --git a/README.md b/README.md index c0998b5..9b15290 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This program patches **The Sims 1** to a custom resolution. -![The Sims 1 Widescreen Patcher](https://i.imgur.com/PdKHV0k.png) +![The Sims 1 Widescreen Patcher](https://i.imgur.com/b8BU9lG.png) ## Requirements diff --git a/Sims1WidescreenPatcher.Core/Models/AspectRatio.cs b/Sims1WidescreenPatcher.Core/Models/AspectRatio.cs new file mode 100644 index 0000000..40b5088 --- /dev/null +++ b/Sims1WidescreenPatcher.Core/Models/AspectRatio.cs @@ -0,0 +1,84 @@ +using System.Numerics; + +namespace Sims1WidescreenPatcher.Core.Models; + +public class AspectRatio : IEqualityComparer, IComparable +{ + protected bool Equals(AspectRatio other) + { + return Numerator == other.Numerator && Denominator == other.Denominator; + } + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((AspectRatio) obj); + } + + public override int GetHashCode() + { + unchecked + { + return (Numerator * 397) ^ Denominator; + } + } + + public int Numerator; + public int Denominator; + + public AspectRatio(int width, int height) + { + CalculateAspectRatio(width, height); + } + + public override string ToString() + { + return $"{Numerator}:{Denominator}"; + } + + public static bool operator ==(AspectRatio obj1, AspectRatio obj2) + { + return (obj1.Numerator == obj2.Numerator + && obj1.Denominator == obj2.Denominator); + } + + public static bool operator !=(AspectRatio obj1, AspectRatio obj2) + { + return !(obj1 == obj2); + } + + private void CalculateAspectRatio(int width, int height) + { + var gcd = BigInteger.GreatestCommonDivisor(width, height); + Numerator = width / (int)gcd; + Denominator = height / (int)gcd; + } + + public bool Equals(AspectRatio x, AspectRatio y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + return x.Numerator == y.Numerator && x.Denominator == y.Denominator; + } + + public int GetHashCode(AspectRatio obj) + { + unchecked + { + return (obj.Numerator * 397) ^ obj.Denominator; + } + } + + public int CompareTo(AspectRatio? other) + { + if (ReferenceEquals(this, other)) return 0; + if (ReferenceEquals(null, other)) return 1; + var numeratorComparison = Numerator.CompareTo(other.Numerator); + if (numeratorComparison != 0) return numeratorComparison; + return Denominator.CompareTo(other.Denominator); + } +} \ No newline at end of file diff --git a/Sims1WidescreenPatcher.Core/Models/Resolution.cs b/Sims1WidescreenPatcher.Core/Models/Resolution.cs index 05e5173..b1899f5 100644 --- a/Sims1WidescreenPatcher.Core/Models/Resolution.cs +++ b/Sims1WidescreenPatcher.Core/Models/Resolution.cs @@ -1,6 +1,8 @@ -namespace Sims1WidescreenPatcher.Core.Models; +using System.Numerics; -public class Resolution +namespace Sims1WidescreenPatcher.Core.Models; + +public class Resolution : IComparable { private sealed class WidthHeightEqualityComparer : IEqualityComparer { @@ -25,21 +27,27 @@ public int GetHashCode(Resolution obj) public static IEqualityComparer? WidthHeightComparer { get; } = new WidthHeightEqualityComparer(); public int Width { get; } - public int Height { get; } + public AspectRatio AspectRatio { get; } public Resolution(int width, int height) { Width = width; Height = height; + AspectRatio = new AspectRatio(width, height); } public override string ToString() { - if (Width == -1 && Height == -1) - { - return @""; - } - return $"{Width}x{Height}"; + return $"{Width}x{Height} ({AspectRatio})"; + } + + public int CompareTo(Resolution? other) + { + if (ReferenceEquals(this, other)) return 0; + if (ReferenceEquals(null, other)) return 1; + var widthComparison = Width.CompareTo(other.Width); + if (widthComparison != 0) return widthComparison; + return Height.CompareTo(other.Height); } } \ No newline at end of file diff --git a/Sims1WidescreenPatcher.Core/Sims1WidescreenPatcher.Core.csproj b/Sims1WidescreenPatcher.Core/Sims1WidescreenPatcher.Core.csproj index 6a401a8..7047264 100644 --- a/Sims1WidescreenPatcher.Core/Sims1WidescreenPatcher.Core.csproj +++ b/Sims1WidescreenPatcher.Core/Sims1WidescreenPatcher.Core.csproj @@ -8,8 +8,9 @@ - - + + + diff --git a/Sims1WidescreenPatcher.Core/ViewModels/CustomResolutionDialogViewModel.cs b/Sims1WidescreenPatcher.Core/ViewModels/CustomResolutionDialogViewModel.cs index dd7a881..d3d0529 100644 --- a/Sims1WidescreenPatcher.Core/ViewModels/CustomResolutionDialogViewModel.cs +++ b/Sims1WidescreenPatcher.Core/ViewModels/CustomResolutionDialogViewModel.cs @@ -1,15 +1,17 @@ using System.Reactive; +using System.Reactive.Linq; using ReactiveUI; using Sims1WidescreenPatcher.Core.Models; namespace Sims1WidescreenPatcher.Core.ViewModels; -public class CustomResolutionDialogViewModel : ViewModelBase +public class CustomResolutionDialogViewModel : ViewModelBase, ICustomResolutionDialogViewModel { #region Fields private string _width = ""; private string _height = ""; + private readonly ObservableAsPropertyHelper _aspectRatio; #endregion @@ -18,6 +20,17 @@ public class CustomResolutionDialogViewModel : ViewModelBase public CustomResolutionDialogViewModel() { OkCommand = ReactiveCommand.Create(() => new Resolution(int.Parse(Width), int.Parse(Height))); + _aspectRatio = this + .WhenAnyValue(x => x.Width, x => x.Height, (w, h) => + { + if (!int.TryParse(w, out var width) || !int.TryParse(h, out var height)) + { + return null; + } + return new AspectRatio(width, height); + }) + .Throttle(TimeSpan.FromMilliseconds(100)) + .ToProperty(this, x => x.AspectRatio); } #endregion @@ -42,5 +55,7 @@ public string Height set => this.RaiseAndSetIfChanged(ref _height, value); } + public AspectRatio? AspectRatio => _aspectRatio.Value; + #endregion } \ No newline at end of file diff --git a/Sims1WidescreenPatcher.Core/ViewModels/ICustomResolutionDialogViewModel.cs b/Sims1WidescreenPatcher.Core/ViewModels/ICustomResolutionDialogViewModel.cs new file mode 100644 index 0000000..355e41f --- /dev/null +++ b/Sims1WidescreenPatcher.Core/ViewModels/ICustomResolutionDialogViewModel.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; +using System.Reactive; +using ReactiveUI; +using Sims1WidescreenPatcher.Core.Models; + +namespace Sims1WidescreenPatcher.Core.ViewModels; + +public interface ICustomResolutionDialogViewModel +{ + ReactiveCommand OkCommand { get; } + string Width { get; set; } + string Height { get; set; } + AspectRatio? AspectRatio { get; } + IObservable> Changing { get; } + IObservable> Changed { get; } + IObservable ThrownExceptions { get; } + IDisposable SuppressChangeNotifications(); + bool AreChangeNotificationsEnabled(); + IDisposable DelayChangeNotifications(); + event PropertyChangingEventHandler? PropertyChanging; + event PropertyChangedEventHandler? PropertyChanged; +} \ No newline at end of file diff --git a/Sims1WidescreenPatcher.Core/ViewModels/IMainWindowViewModel.cs b/Sims1WidescreenPatcher.Core/ViewModels/IMainWindowViewModel.cs new file mode 100644 index 0000000..5456872 --- /dev/null +++ b/Sims1WidescreenPatcher.Core/ViewModels/IMainWindowViewModel.cs @@ -0,0 +1,41 @@ +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Reactive; +using System.Windows.Input; +using Avalonia.Collections; +using Avalonia.Platform.Storage; +using ReactiveUI; +using Sims1WidescreenPatcher.Core.Models; +using Sims1WidescreenPatcher.Utilities.Models; + +namespace Sims1WidescreenPatcher.Core.ViewModels; + +public interface IMainWindowViewModel +{ + ICommand PatchCommand { get; } + ICommand UninstallCommand { get; } + ICommand OpenFile { get; } + Interaction ShowOpenFileDialog { get; } + ICommand CustomResolutionCommand { get; } + Interaction ShowCustomResolutionDialog { get; } + Interaction ShowCustomYesNoDialog { get; } + Interaction ShowCustomInformationDialog { get; } + string Path { get; set; } + AspectRatio? SelectedAspectRatio { get; set; } + bool SortByAspectRatio { get; set; } + bool IsResolutionsColored { get; set; } + ReadOnlyObservableCollection AspectRatios { get; } + ReadOnlyObservableCollection FilteredResolutions { get; } + Resolution? SelectedResolution { get; set; } + AvaloniaList Wrappers { get; } + int SelectedWrapperIndex { get; set; } + double Progress { get; } + IObservable> Changing { get; } + IObservable> Changed { get; } + IObservable ThrownExceptions { get; } + IDisposable SuppressChangeNotifications(); + bool AreChangeNotificationsEnabled(); + IDisposable DelayChangeNotifications(); + event PropertyChangingEventHandler? PropertyChanging; + event PropertyChangedEventHandler? PropertyChanged; +} \ No newline at end of file diff --git a/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs b/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs index 637b871..40d921e 100644 --- a/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs +++ b/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs @@ -1,8 +1,11 @@ -using System.Reactive; +using System.Collections.ObjectModel; +using System.Reactive; using System.Reactive.Linq; using System.Windows.Input; using Avalonia.Collections; using Avalonia.Platform.Storage; +using DynamicData; +using DynamicData.Binding; using ReactiveUI; using Sims1WidescreenPatcher.Core.Enums; using Sims1WidescreenPatcher.Core.Models; @@ -13,22 +16,28 @@ namespace Sims1WidescreenPatcher.Core.ViewModels; -public class MainWindowViewModel : ViewModelBase +public class MainWindowViewModel : ViewModelBase, IMainWindowViewModel { #region Fields private readonly CustomYesNoDialogViewModel _customYesNoDialogViewModel; - private readonly CustomResolutionDialogViewModel _customResolutionDialogViewModel; + private readonly ICustomResolutionDialogViewModel _customResolutionDialogViewModel; private int _selectedWrapperIndex; private Resolution? _selectedResolution; + private Resolution? _previousResolution; + private AspectRatio? _selectedSelectedAspectRatio; private string _path = ""; private bool _isBusy; + private bool _isResolutionsColored = true; + private bool _sortByAspectRatio; private readonly ObservableAsPropertyHelper _hasBackup; private readonly ObservableAsPropertyHelper _isValidSimsExe; private readonly List _previouslyPatched = new(); private readonly IProgressService _progressService; private readonly ObservableAsPropertyHelper _progress; - private readonly IFindSimsPathService _findSimsPathService; + private readonly SourceList _resolutionSource = new(); + private readonly ReadOnlyObservableCollection _filteredResolutions; + private readonly ReadOnlyObservableCollection _aspectRatios; #endregion @@ -36,14 +45,15 @@ public class MainWindowViewModel : ViewModelBase public MainWindowViewModel(IResolutionsService resolutionsService, CustomYesNoDialogViewModel customYesNoDialogViewModel, - CustomResolutionDialogViewModel customResolutionDialogViewModel, + ICustomResolutionDialogViewModel customResolutionDialogViewModel, IProgressService progressService, IFindSimsPathService findSimsPathService) { _progressService = progressService; _customYesNoDialogViewModel = customYesNoDialogViewModel; _customResolutionDialogViewModel = customResolutionDialogViewModel; - this.WhenAnyValue(x => x.Path).Subscribe(x => System.Diagnostics.Debug.WriteLine(x)); + this.WhenAnyValue(x => x.Path) + .Subscribe(x => System.Diagnostics.Debug.WriteLine(x)); _hasBackup = this .WhenAnyValue(x => x.Path, x => x.IsBusy, (path, _) => PatchUtility.SimsBackupExists(path)) .ToProperty(this, x => x.HasBackup, deferSubscription: true); @@ -57,31 +67,58 @@ public MainWindowViewModel(IResolutionsService resolutionsService, !hasBackup && validSimsExe && !_previouslyPatched.Contains(path) && - !isBusy - ).DistinctUntilChanged(); + !isBusy) + .DistinctUntilChanged(); var canUninstall = this .WhenAnyValue(x => x.IsBusy, x => x.Path, x => x.HasBackup, (isBusy, path, hasBackup) => !string.IsNullOrWhiteSpace(path) && !isBusy && - hasBackup - ).DistinctUntilChanged(); + hasBackup) + .DistinctUntilChanged(); PatchCommand = ReactiveCommand.CreateFromTask(OnClickedPatch, canPatch); UninstallCommand = ReactiveCommand.CreateFromTask(OnClickedUninstall, canUninstall); OpenFile = ReactiveCommand.CreateFromTask(OpenFileAsync); ShowOpenFileDialog = new Interaction(); - Resolutions = new AvaloniaList(resolutionsService.GetResolutions()) - { new(-1, -1) }; - SelectedResolution = Resolutions.FirstOrDefault() ?? new Resolution(1920, 1080); + var resolutionFilter = this + .WhenAnyValue(x => x.SelectedAspectRatio) + .Select(CreateResolutionPredicate); + var resolutionSort = this + .WhenAnyValue(x => x.SortByAspectRatio) + .Select(x => x + ? SortExpressionComparer + .Ascending(r => r.AspectRatio.Numerator) + .ThenByAscending(r => r.AspectRatio.Denominator) + .ThenByAscending(r => r.Width) + .ThenByAscending(r => r.Height) + : SortExpressionComparer + .Ascending(r => r.Width) + .ThenByAscending(r => r.Height)); + _resolutionSource + .Connect() + .Filter(resolutionFilter) + .Sort(resolutionSort) + .Bind(out _filteredResolutions) + .Subscribe(GetNewSelectedResolution); + _resolutionSource + .Connect() + .DistinctValues(x => x.AspectRatio) + .Sort(Comparer.Default) + .Bind(out _aspectRatios) + .Subscribe(); + + _resolutionSource.AddRange(resolutionsService.GetResolutions()); + SelectedResolution = FilteredResolutions.First(); SelectedWrapperIndex = 0; - ShowCustomResolutionDialog = new Interaction(); + SelectedAspectRatio = null; + ShowCustomResolutionDialog = new Interaction(); CustomResolutionCommand = ReactiveCommand.CreateFromTask(OpenCustomResolutionDialogAsync); ShowCustomYesNoDialog = new Interaction(); ShowCustomInformationDialog = new Interaction(); - _findSimsPathService = findSimsPathService; - Path = _findSimsPathService.FindSimsPath(); - - var progressPct = Observable.FromEventPattern(_progressService, "NewProgressEventHandler"); + Path = findSimsPathService.FindSimsPath(); + + var progressPct = Observable + .FromEventPattern(_progressService, "NewProgressEventHandler"); progressPct .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(async e => @@ -104,7 +141,7 @@ public MainWindowViewModel(IResolutionsService resolutionsService, public ICommand OpenFile { get; } public Interaction ShowOpenFileDialog { get; } public ICommand CustomResolutionCommand { get; } - public Interaction ShowCustomResolutionDialog { get; } + public Interaction ShowCustomResolutionDialog { get; } public Interaction ShowCustomYesNoDialog { get; } public Interaction ShowCustomInformationDialog { get; } @@ -127,21 +164,38 @@ private bool IsBusy private bool HasBackup => _hasBackup.Value; private bool IsValidSimsExe => _isValidSimsExe.Value; - public AvaloniaList Resolutions { get; } + public AspectRatio? SelectedAspectRatio + { + get => _selectedSelectedAspectRatio; + set => this.RaiseAndSetIfChanged(ref _selectedSelectedAspectRatio, value); + } + + public bool SortByAspectRatio + { + get => _sortByAspectRatio; + set => this.RaiseAndSetIfChanged(ref _sortByAspectRatio, value); + } + + public bool IsResolutionsColored + { + get => _isResolutionsColored; + set => this.RaiseAndSetIfChanged(ref _isResolutionsColored, value); + } + + public ReadOnlyObservableCollection AspectRatios => _aspectRatios; + + public ReadOnlyObservableCollection FilteredResolutions => _filteredResolutions; public Resolution? SelectedResolution { get => _selectedResolution; set { - if (value is { Width: -1, Height: -1 }) - { - CustomResolutionCommand.Execute(null); - } - else + if (value is null) { - this.RaiseAndSetIfChanged(ref _selectedResolution, value); + _previousResolution = _selectedResolution; } + this.RaiseAndSetIfChanged(ref _selectedResolution, value); } } @@ -158,7 +212,57 @@ public int SelectedWrapperIndex #endregion #region Methods + + private void GetNewSelectedResolution(IChangeSet changeSet) + { + if (changeSet.Moves > 0) + { + SelectedResolution ??= _previousResolution; + return; + } + foreach (var change in changeSet) + { + switch (change.Reason) + { + case ListChangeReason.Add: + SelectedResolution = change.Item.Current; + break; + case ListChangeReason.AddRange: + if (FilteredResolutions.All(x => x != SelectedResolution)) + { + SelectedResolution = change.Range.First(); + return; + } + break; + case ListChangeReason.Replace: + break; + case ListChangeReason.Remove: + break; + case ListChangeReason.RemoveRange: + SelectedResolution = FilteredResolutions.First(); + return; + case ListChangeReason.Refresh: + break; + case ListChangeReason.Moved: + break; + case ListChangeReason.Clear: + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + } + + private Func CreateResolutionPredicate(AspectRatio? ar) + { + if (ar is null) + { + return _ => true; + } + return resolution => resolution.AspectRatio == ar; + } + private async Task OpenCustomInformationDialogAsync(string title, string message) { var vm = new CustomInformationDialogViewModel(title, message); @@ -176,11 +280,12 @@ private async Task OpenCustomInformationDialogAsync(string title, string message private async Task OpenCustomResolutionDialogAsync() { var res = await ShowCustomResolutionDialog.Handle(_customResolutionDialogViewModel); - if (res is { Width: > 0, Height: > 0 }) + if (res is null) { - Resolutions.Insert(Resolutions.Count - 1, res); - SelectedResolution = res; + return; } + + _resolutionSource.Add(res); } private async Task OpenFileAsync() diff --git a/Sims1WidescreenPatcher.Images/Sims1WidescreenPatcher.Images.csproj b/Sims1WidescreenPatcher.Images/Sims1WidescreenPatcher.Images.csproj index d8cbb99..b3956b5 100644 --- a/Sims1WidescreenPatcher.Images/Sims1WidescreenPatcher.Images.csproj +++ b/Sims1WidescreenPatcher.Images/Sims1WidescreenPatcher.Images.csproj @@ -8,7 +8,7 @@ - + diff --git a/Sims1WidescreenPatcher.UI/App.axaml.cs b/Sims1WidescreenPatcher.UI/App.axaml.cs index 00f5235..86e4d80 100644 --- a/Sims1WidescreenPatcher.UI/App.axaml.cs +++ b/Sims1WidescreenPatcher.UI/App.axaml.cs @@ -2,6 +2,7 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Sims1WidescreenPatcher.UI.Views; +using Splat; namespace Sims1WidescreenPatcher.UI; @@ -16,7 +17,7 @@ public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new MainWindow(); + desktop.MainWindow = Locator.Current.GetService(); } base.OnFrameworkInitializationCompleted(); diff --git a/Sims1WidescreenPatcher.UI/Converters/ResolutionColorCodingConverter.cs b/Sims1WidescreenPatcher.UI/Converters/ResolutionColorCodingConverter.cs new file mode 100644 index 0000000..3329afc --- /dev/null +++ b/Sims1WidescreenPatcher.UI/Converters/ResolutionColorCodingConverter.cs @@ -0,0 +1,154 @@ +using System; +using System.Globalization; +using Avalonia; +using Avalonia.Data.Converters; +using Avalonia.Media; +using Avalonia.Styling; +using Sims1WidescreenPatcher.Core.Models; + +namespace Sims1WidescreenPatcher.UI.Converters; + +public class ResolutionColorCodingConverter : IValueConverter +{ + private static readonly IBrush BackgroundGoodLight = Brush.Parse("#97ef7f"); + private static readonly IBrush BackgroundGoodDark = Brush.Parse("#165607"); + private static readonly IBrush BackgroundBadLight = Brush.Parse("#f66"); + private static readonly IBrush BackgroundBadDark = Brush.Parse("#be1e1e"); + + private static readonly IBrush PointeroverGoodLight = Brush.Parse("#4ca43a"); + private static readonly IBrush PointeroverGoodDark = Brush.Parse("#4c893a"); + private static readonly IBrush PointeroverBadLight = Brush.Parse("#cd3740"); + private static readonly IBrush PointeroverBadDark = Brush.Parse("#fd5e4b"); + + private static readonly IBrush SelectedGoodLight = Brush.Parse("#7bd265"); + private static readonly IBrush SelectedGoodDark = Brush.Parse("#326f22"); + private static readonly IBrush SelectedBadLight = Brush.Parse("#e0494e"); + private static readonly IBrush SelectedBadDark = Brush.Parse("#dd4034"); + + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is not Resolution r) + { + return null; + } + + if (parameter is not string s) + { + return null; + } + + if (s == "Background") + { + if (r.Width == 1600) + { + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return BackgroundBadLight; + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return BackgroundBadDark; + } + } + + if (r.AspectRatio is { Numerator: 4, Denominator: 3 }) + { + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return BackgroundGoodLight; + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return BackgroundGoodDark; + } + } + } + + if (s == "Pointerover") + { + if (r.Width == 1600) + { + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return PointeroverBadLight; + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return PointeroverBadDark; + } + } + + if (r.AspectRatio is { Numerator: 4, Denominator: 3 }) + { + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return PointeroverGoodLight; + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return PointeroverGoodDark; + } + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return Brush.Parse("#19000000"); + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return Brush.Parse("#19FFFFFF"); + } + } + + if (s == "Selected") + { + if (r.Width == 1600) + { + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return SelectedBadLight; + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return SelectedBadDark; + } + } + + if (r.AspectRatio is { Numerator: 4, Denominator: 3 }) + { + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return SelectedGoodLight; + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return SelectedGoodDark; + } + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Light) + { + return Brush.Parse("#29000000"); + } + + if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark) + { + return Brush.Parse("#09FFFFFF"); + } + } + + return null; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Sims1WidescreenPatcher.UI/Dialogs/CustomResolutionDialog.axaml b/Sims1WidescreenPatcher.UI/Dialogs/CustomResolutionDialog.axaml index efcb433..c0bd21d 100644 --- a/Sims1WidescreenPatcher.UI/Dialogs/CustomResolutionDialog.axaml +++ b/Sims1WidescreenPatcher.UI/Dialogs/CustomResolutionDialog.axaml @@ -11,7 +11,8 @@ d:DesignHeight="80" x:Class="Sims1WidescreenPatcher.UI.Views.CustomResolutionDialog" Title="Enter Custom Resolution" - SizeToContent="Height"> + SizeToContent="Height" + Icon="/Assets/SimsICO.ico"> @@ -33,14 +34,20 @@