update
This commit is contained in:
@@ -4,38 +4,23 @@ using PropertyChanged;
|
|||||||
|
|
||||||
namespace ModpackUpdater.Apps.Manager.Ui.Models;
|
namespace ModpackUpdater.Apps.Manager.Ui.Models;
|
||||||
|
|
||||||
public class MainWindowGridRow : INotifyPropertyChanged
|
public class MainWindowGridRow(InstallAction action, IActionSet baseActions) : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
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<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<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 static Dictionary<UpdateActionType, string> UpdateActionTypes { get; } = Enum.GetValues<UpdateActionType>().ToDictionary(n => n, n => Enum.GetName(n)!);
|
||||||
|
|
||||||
public InstallAction Action => action;
|
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;
|
private InstallAction Inherited => Base ?? action;
|
||||||
|
|
||||||
public bool IsUpdate => action is UpdateAction;
|
public bool IsUpdate => action is UpdateAction;
|
||||||
public bool? IsValid { get; set; } = null;
|
public bool? IsValid { get; set; } = null;
|
||||||
|
|
||||||
[DependsOn(nameof(Id), nameof(InheritFrom))]
|
[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))]
|
[DependsOn(nameof(Side), nameof(InheritedId), nameof(Id))]
|
||||||
public string InheritedSide => Sides[Inherited.Side];
|
public string InheritedSide => Sides[Inherited.Side];
|
||||||
[DependsOn(nameof(UpdateType), nameof(InheritedId), nameof(Id))]
|
[DependsOn(nameof(UpdateType), nameof(InheritedId), nameof(Id))]
|
||||||
@@ -43,55 +28,24 @@ public class MainWindowGridRow : INotifyPropertyChanged
|
|||||||
[DependsOn(nameof(SourceType), nameof(InheritedId), nameof(Id))]
|
[DependsOn(nameof(SourceType), nameof(InheritedId), nameof(Id))]
|
||||||
public string InheritedSourceType => SourceTypes[Inherited.SourceType];
|
public string InheritedSourceType => SourceTypes[Inherited.SourceType];
|
||||||
[DependsOn(nameof(DestPath), nameof(InheritedId), nameof(Id))]
|
[DependsOn(nameof(DestPath), nameof(InheritedId), nameof(Id))]
|
||||||
public string? InheritedDestPath => Base != null ? Base.DestPath : actionDestPath;
|
public string? InheritedDestPath => Inherited.DestPath;
|
||||||
|
|
||||||
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? Id
|
public string? Id
|
||||||
{
|
{
|
||||||
get => actionId;
|
get => action.Id;
|
||||||
set => action.Id = (actionId = value)?.Trim().Nullify();
|
set => action.Id = value?.Trim().Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? Name
|
public string? Name
|
||||||
{
|
{
|
||||||
get => actionName;
|
get => action.Name;
|
||||||
set
|
set => action.Name = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionName = value;
|
|
||||||
action.Name = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? Website
|
public string? Website
|
||||||
{
|
{
|
||||||
get => actionWebsite;
|
get => action.Website;
|
||||||
set
|
set => action.Website = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionWebsite = value;
|
|
||||||
action.Website = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsZip
|
public bool IsZip
|
||||||
@@ -102,32 +56,20 @@ public class MainWindowGridRow : INotifyPropertyChanged
|
|||||||
|
|
||||||
public string? ZipPath
|
public string? ZipPath
|
||||||
{
|
{
|
||||||
get => actionZipPath;
|
get => action.ZipPath;
|
||||||
set
|
set => action.ZipPath = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionZipPath = value;
|
|
||||||
action.ZipPath = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? DestPath
|
public string? DestPath
|
||||||
{
|
{
|
||||||
get => actionDestPath;
|
get => action.DestPath;
|
||||||
set
|
set => action.DestPath = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionDestPath = value;
|
|
||||||
action.DestPath = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? SourceUrl
|
public string? SourceUrl
|
||||||
{
|
{
|
||||||
get => actionSourceUrl;
|
get => action.SourceUrl;
|
||||||
set
|
set => action.SourceUrl = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionSourceUrl = value;
|
|
||||||
action.SourceUrl = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceType SourceType
|
public SourceType SourceType
|
||||||
@@ -138,42 +80,26 @@ public class MainWindowGridRow : INotifyPropertyChanged
|
|||||||
|
|
||||||
public string? SourceOwner
|
public string? SourceOwner
|
||||||
{
|
{
|
||||||
get => actionSourceOwner;
|
get => action.SourceOwner;
|
||||||
set
|
set => action.SourceOwner = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionSourceOwner = value;
|
|
||||||
action.SourceOwner = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? SourceName
|
public string? SourceName
|
||||||
{
|
{
|
||||||
get => actionSourceName;
|
get => action.SourceName;
|
||||||
set
|
set => action.SourceName = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionSourceName = value;
|
|
||||||
action.SourceName = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? SourceRegex
|
public string? SourceRegex
|
||||||
{
|
{
|
||||||
get => actionSourceRegEx;
|
get => action.SourceRegex;
|
||||||
set
|
set => action.SourceRegex = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionSourceRegEx = value;
|
|
||||||
action.SourceRegex = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? SourceTag
|
public string? SourceTag
|
||||||
{
|
{
|
||||||
get => actionSourceTag;
|
get => action.SourceTag;
|
||||||
set
|
set => action.SourceTag = value?.Trim().Nullify();
|
||||||
{
|
|
||||||
actionSourceTag = value;
|
|
||||||
action.SourceTag = value?.Trim().Nullify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Side Side
|
public Side Side
|
||||||
@@ -200,10 +126,9 @@ public class MainWindowGridRow : INotifyPropertyChanged
|
|||||||
|
|
||||||
public string? SrcPath
|
public string? SrcPath
|
||||||
{
|
{
|
||||||
get => actionSrcPath;
|
get => (action as UpdateAction)?.SrcPath;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
actionSrcPath = value;
|
|
||||||
if (action is UpdateAction ua)
|
if (action is UpdateAction ua)
|
||||||
ua.SrcPath = value?.Trim().Nullify();
|
ua.SrcPath = value?.Trim().Nullify();
|
||||||
}
|
}
|
||||||
@@ -221,10 +146,9 @@ public class MainWindowGridRow : INotifyPropertyChanged
|
|||||||
|
|
||||||
public string? InheritFrom
|
public string? InheritFrom
|
||||||
{
|
{
|
||||||
get => actionInheritFrom;
|
get => (action as UpdateAction)?.InheritFrom;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
actionInheritFrom = value;
|
|
||||||
if (action is UpdateAction ua)
|
if (action is UpdateAction ua)
|
||||||
ua.InheritFrom = value?.Trim().Nullify();
|
ua.InheritFrom = value?.Trim().Nullify();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user