Files
bluflame/intromat/Intromat/ViewModels/ProjectViewModel.cs
2026-04-18 22:31:51 +02:00

66 lines
1.9 KiB
C#

using System.Collections.ObjectModel;
using System.IO;
using Intromat.Interfaces;
using ReactiveUI;
namespace Intromat.ViewModels
{
public class ProjectViewModel : ReactiveObject, IFile, ITreeItem
{
private string _fullPath;
private bool _isDirty;
private string _name;
private bool _isExpanded;
private bool _isSelected;
public ProjectViewModel(string name, string fullPath)
{
_name = name;
_fullPath = fullPath;
TreeRoot = new[] { this };
_isExpanded = true;
}
public string FullPath
{
get => _fullPath;
set => this.RaiseAndSetIfChanged(ref _fullPath, value);
}
public string Name
{
get => _name;
set => this.RaiseAndSetIfChanged(ref _name, value);
}
public bool IsExpanded
{
get => _isExpanded;
set => this.RaiseAndSetIfChanged(ref _isExpanded, value);
}
public bool IsSelected
{
get => _isSelected;
set => this.RaiseAndSetIfChanged(ref _isSelected, value);
}
public ProjectViewModel[] TreeRoot { get; init; }
public ObservableCollection<ModuleViewModel> Modules { get; } = new();
public bool IsDirty
{
get => _isDirty;
set => this.RaiseAndSetIfChanged(ref _isDirty, value);
}
public static ProjectViewModel CreateDefault(MainViewModel mainVm, string fullPath, string name = "Project")
{
var project = new ProjectViewModel(name, Path.GetFullPath(fullPath));
var directory = Path.GetDirectoryName(fullPath)!;
project.Modules.Add(ModuleViewModel.CreateDefault(mainVm, project, Path.Combine(directory, "Module1")));
return project;
}
}
}