This commit is contained in:
2025-11-17 07:19:43 +01:00
parent 72a81e05ad
commit e584996043
29 changed files with 134 additions and 668 deletions

View File

@@ -0,0 +1,70 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using ModpackUpdater.Apps.Manager.Api.Model;
using PropertyChanged;
namespace ModpackUpdater.Apps.Manager.Ui.Models.MainWindow;
public class MainWindowViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
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
{
currentTreeNodes = null;
currentWorkspace = value;
}
}
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
{
currentGridRows = null;
selectedTreeNode = value;
}
}
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;
}
}
}