From d2a454aca005c80183c96b5e1e20c1bdb8340f5f Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Sat, 15 Nov 2025 18:38:17 +0100 Subject: [PATCH] update --- .../Ui/Models/MainWindowGridRow.cs | 128 ++++-------------- 1 file changed, 26 insertions(+), 102 deletions(-) diff --git a/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowGridRow.cs b/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowGridRow.cs index 2691aad..8546670 100644 --- a/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowGridRow.cs +++ b/ModpackUpdater.Apps.Manager/Ui/Models/MainWindowGridRow.cs @@ -4,38 +4,23 @@ using PropertyChanged; namespace ModpackUpdater.Apps.Manager.Ui.Models; -public class MainWindowGridRow : INotifyPropertyChanged +public class MainWindowGridRow(InstallAction action, IActionSet baseActions) : INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; - private string? actionId; - private string? actionName; - private string? actionWebsite; - private string? actionZipPath; - private string? actionDestPath; - private string? actionSourceUrl; - private string? actionSourceOwner; - private string? actionSourceName; - private string? actionSourceRegEx; - private string? actionSourceTag; - private string? actionSrcPath; - private string? actionInheritFrom; - private readonly InstallAction action; - private readonly IActionSet baseActions; - public static Dictionary SourceTypes { get; } = Enum.GetValues().ToDictionary(n => n, n => Enum.GetName(n)!); public static Dictionary Sides { get; } = Enum.GetValues().ToDictionary(n => n, n => Enum.GetName(n)!); public static Dictionary UpdateActionTypes { get; } = Enum.GetValues().ToDictionary(n => n, n => Enum.GetName(n)!); public InstallAction Action => action; - private InstallAction? Base => action is UpdateAction ua ? baseActions.Actions.FirstOrDefault(n => n.Id == actionInheritFrom) : null; + private InstallAction? Base => action is UpdateAction ua ? baseActions.Actions.FirstOrDefault(n => n.Id == ua.InheritFrom) : null; private InstallAction Inherited => Base ?? action; public bool IsUpdate => action is UpdateAction; public bool? IsValid { get; set; } = null; [DependsOn(nameof(Id), nameof(InheritFrom))] - public string? InheritedId => action is UpdateAction ua && !string.IsNullOrWhiteSpace(actionInheritFrom) ? actionInheritFrom : actionId; + public string? InheritedId => action is UpdateAction ua && !string.IsNullOrWhiteSpace(ua.InheritFrom) ? ua.InheritFrom : action.Id; [DependsOn(nameof(Side), nameof(InheritedId), nameof(Id))] public string InheritedSide => Sides[Inherited.Side]; [DependsOn(nameof(UpdateType), nameof(InheritedId), nameof(Id))] @@ -43,55 +28,24 @@ public class MainWindowGridRow : INotifyPropertyChanged [DependsOn(nameof(SourceType), nameof(InheritedId), nameof(Id))] public string InheritedSourceType => SourceTypes[Inherited.SourceType]; [DependsOn(nameof(DestPath), nameof(InheritedId), nameof(Id))] - public string? InheritedDestPath => Base != null ? Base.DestPath : actionDestPath; - - public MainWindowGridRow(InstallAction action, IActionSet baseActions) - { - this.action = action; - this.baseActions = baseActions; - Invalidate(); - } - - public void Invalidate() - { - actionId = action.Id; - actionName = action.Name; - actionWebsite = action.Website; - actionZipPath = action.ZipPath; - actionDestPath = action.DestPath; - actionSourceUrl = action.SourceUrl; - actionSourceOwner = action.SourceOwner; - actionSourceName = action.SourceName; - actionSourceRegEx = action.SourceRegex; - actionSourceTag = action.SourceTag; - actionSrcPath = (action as UpdateAction)?.SrcPath; - actionInheritFrom = (action as UpdateAction)?.InheritFrom; - } + public string? InheritedDestPath => Inherited.DestPath; public string? Id { - get => actionId; - set => action.Id = (actionId = value)?.Trim().Nullify(); + get => action.Id; + set => action.Id = value?.Trim().Nullify(); } public string? Name { - get => actionName; - set - { - actionName = value; - action.Name = value?.Trim().Nullify(); - } + get => action.Name; + set => action.Name = value?.Trim().Nullify(); } public string? Website { - get => actionWebsite; - set - { - actionWebsite = value; - action.Website = value?.Trim().Nullify(); - } + get => action.Website; + set => action.Website = value?.Trim().Nullify(); } public bool IsZip @@ -102,32 +56,20 @@ public class MainWindowGridRow : INotifyPropertyChanged public string? ZipPath { - get => actionZipPath; - set - { - actionZipPath = value; - action.ZipPath = value?.Trim().Nullify(); - } + get => action.ZipPath; + set => action.ZipPath = value?.Trim().Nullify(); } public string? DestPath { - get => actionDestPath; - set - { - actionDestPath = value; - action.DestPath = value?.Trim().Nullify(); - } + get => action.DestPath; + set => action.DestPath = value?.Trim().Nullify(); } public string? SourceUrl { - get => actionSourceUrl; - set - { - actionSourceUrl = value; - action.SourceUrl = value?.Trim().Nullify(); - } + get => action.SourceUrl; + set => action.SourceUrl = value?.Trim().Nullify(); } public SourceType SourceType @@ -138,42 +80,26 @@ public class MainWindowGridRow : INotifyPropertyChanged public string? SourceOwner { - get => actionSourceOwner; - set - { - actionSourceOwner = value; - action.SourceOwner = value?.Trim().Nullify(); - } + get => action.SourceOwner; + set => action.SourceOwner = value?.Trim().Nullify(); } public string? SourceName { - get => actionSourceName; - set - { - actionSourceName = value; - action.SourceName = value?.Trim().Nullify(); - } + get => action.SourceName; + set => action.SourceName = value?.Trim().Nullify(); } public string? SourceRegex { - get => actionSourceRegEx; - set - { - actionSourceRegEx = value; - action.SourceRegex = value?.Trim().Nullify(); - } + get => action.SourceRegex; + set => action.SourceRegex = value?.Trim().Nullify(); } public string? SourceTag { - get => actionSourceTag; - set - { - actionSourceTag = value; - action.SourceTag = value?.Trim().Nullify(); - } + get => action.SourceTag; + set => action.SourceTag = value?.Trim().Nullify(); } public Side Side @@ -200,10 +126,9 @@ public class MainWindowGridRow : INotifyPropertyChanged public string? SrcPath { - get => actionSrcPath; + get => (action as UpdateAction)?.SrcPath; set { - actionSrcPath = value; if (action is UpdateAction ua) ua.SrcPath = value?.Trim().Nullify(); } @@ -221,10 +146,9 @@ public class MainWindowGridRow : INotifyPropertyChanged public string? InheritFrom { - get => actionInheritFrom; + get => (action as UpdateAction)?.InheritFrom; set { - actionInheritFrom = value; if (action is UpdateAction ua) ua.InheritFrom = value?.Trim().Nullify(); }