a lot of work

This commit is contained in:
2025-11-15 17:17:52 +01:00
parent 336b6ad1fd
commit b9ddc20b7d
42 changed files with 1453 additions and 3346 deletions

View File

@@ -1,24 +1,72 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Avalonia.Controls;
using ModpackUpdater.Apps.Manager.Api.Model;
using PropertyChanged;
namespace ModpackUpdater.Apps.Manager.Ui.Models;
public class MainWindowViewModel : INotifyPropertyChanged
{
#region Implementation of INotifyPropertyChanged
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion Implementation of INotifyPropertyChanged
public bool IsUpdate { get; set; }
public List<InstallActionViewModel> Actions { get; } = [];
public InstallActionViewModel? SelectedAction { get; set; }
private ObservableCollection<MainWindowTreeNode>? currentTreeNodes;
private ObservableCollection<MainWindowGridRow>? currentGridRows;
private MainWindowTreeNode? selectedTreeNode;
private IWorkspace? currentWorkspace;
public bool IsUpdate => selectedTreeNode is ActionSetTreeNode node && node.Infos is UpdateInfo;
public MainWindowGridRow? SelectedGridRow { get; set; }
[AlsoNotifyFor(nameof(CurrentTreeNodes))]
public IWorkspace? CurrentWorkspace
{
get => currentWorkspace;
set
{
currentWorkspace = value;
currentTreeNodes = null;
}
}
public ObservableCollection<MainWindowTreeNode>? CurrentTreeNodes
{
get
{
if (currentTreeNodes == null && currentWorkspace?.InstallInfos != null && currentWorkspace?.UpdateInfos != null)
currentTreeNodes =
[
new ActionSetTreeNode(currentWorkspace.InstallInfos),
new SimpleMainWindowTreeNode("Updates")
{
Image = AppGlobals.Symbols.GetImageSource(AppSymbols.update_done),
Nodes = [.. currentWorkspace.UpdateInfos.Updates.Select(n => new ActionSetTreeNode(n))],
},
];
return currentTreeNodes;
}
}
[AlsoNotifyFor(nameof(CurrentGridRows))]
public MainWindowTreeNode? SelectedTreeNode
{
get => selectedTreeNode;
set
{
selectedTreeNode = value;
currentGridRows = null;
}
}
public ObservableCollection<MainWindowGridRow>? CurrentGridRows
{
get
{
if (currentGridRows == null && CurrentWorkspace?.InstallInfos != null && selectedTreeNode is ActionSetTreeNode node)
currentGridRows = [.. node.Infos.Actions.Select(n => new MainWindowGridRow(n, CurrentWorkspace.InstallInfos))];
return currentGridRows;
}
}
}