update
This commit is contained in:
@@ -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<SourceType, string> SourceTypes { get; } = Enum.GetValues<SourceType>().ToDictionary(n => n, n => Enum.GetName(n)!);
|
||||
public static Dictionary<Side, string> Sides { get; } = Enum.GetValues<Side>().ToDictionary(n => n, n => Enum.GetName(n)!);
|
||||
public static Dictionary<UpdateActionType, string> UpdateActionTypes { get; } = Enum.GetValues<UpdateActionType>().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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user