work
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Avalonia.Media;
|
||||
using PropertyChanged;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui.Models.MainWindow;
|
||||
|
||||
public abstract class MainWindowTreeNode : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public abstract string DisplayText { get; }
|
||||
public virtual IImage? Image { get; set; }
|
||||
public ObservableCollection<MainWindowTreeNode> Nodes { get; init; } = [];
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||
field = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleMainWindowTreeNode(string text) : MainWindowTreeNode
|
||||
{
|
||||
public override string DisplayText => text;
|
||||
}
|
||||
|
||||
public class ActionSetTreeNode(IActionSetInfos infos) : MainWindowTreeNode
|
||||
{
|
||||
private string editVersion = infos.Version?.ToString() ?? string.Empty;
|
||||
|
||||
public override string DisplayText => infos.Version.ToString();
|
||||
public IActionSetInfos Infos => infos;
|
||||
public override IImage? Image => AppGlobals.Symbols.GetImageSource(infos.IsPublic ? AppSymbols.eye : AppSymbols.invisible);
|
||||
|
||||
[AlsoNotifyFor(nameof(DisplayText))]
|
||||
public string Version
|
||||
{
|
||||
get => editVersion;
|
||||
set
|
||||
{
|
||||
infos.Version = System.Version.TryParse(value, out var v) ? v : new();
|
||||
editVersion = value;
|
||||
}
|
||||
}
|
||||
|
||||
[AlsoNotifyFor(nameof(Image))]
|
||||
public bool IsPublic
|
||||
{
|
||||
get => infos.IsPublic;
|
||||
set => infos.IsPublic = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user