Add project files
This commit is contained in:
commit
97cafcfa18
16 files changed
+1540
No files matched your search
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using NexvaneHub.Models;
|
||||
|
||||
namespace NexvaneHub.ViewModels;
|
||||
|
||||
public enum HubSection
|
||||
{
|
||||
Projects,
|
||||
Sdk,
|
||||
Packages,
|
||||
}
|
||||
|
||||
public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
_projects = new ObservableCollection<ProjectItemViewModel>
|
||||
{
|
||||
new(new ProjectModel
|
||||
{
|
||||
Name = "Project A",
|
||||
LastModified = new DateTime(2026, 9, 6),
|
||||
Directory = @"C:\Dev\ProjectA",
|
||||
ProjectVersion = "1.2.0",
|
||||
SdkVersion = "1.4.2",
|
||||
DefaultCompiler = "MSVC",
|
||||
DefaultArchitecture = "Auto",
|
||||
}),
|
||||
new(new ProjectModel
|
||||
{
|
||||
Name = "Project B",
|
||||
LastModified = new DateTime(2026, 8, 2),
|
||||
Directory = @"C:\Dev\ProjectB",
|
||||
ProjectVersion = "0.9.4",
|
||||
SdkVersion = "1.3.0",
|
||||
DefaultCompiler = "Clang",
|
||||
DefaultArchitecture = "x64",
|
||||
}),
|
||||
new(new ProjectModel
|
||||
{
|
||||
Name = "Project C",
|
||||
LastModified = new DateTime(2026, 6, 18),
|
||||
Directory = @"C:\Dev\ProjectC",
|
||||
ProjectVersion = "1.0.0",
|
||||
SdkVersion = "1.4.2",
|
||||
DefaultCompiler = "MSVC",
|
||||
DefaultArchitecture = "Auto",
|
||||
}),
|
||||
new(new ProjectModel
|
||||
{
|
||||
Name = "Project D",
|
||||
LastModified = new DateTime(2026, 5, 30),
|
||||
Directory = @"C:\Dev\ProjectD",
|
||||
ProjectVersion = "0.4.1",
|
||||
SdkVersion = "1.2.7",
|
||||
DefaultCompiler = "GCC",
|
||||
DefaultArchitecture = "ARM64",
|
||||
}),
|
||||
};
|
||||
|
||||
_selectedProject = _projects.Count > 0 ? _projects[0] : null;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private HubSection _currentSection = HubSection.Projects;
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ProjectItemViewModel> _projects;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenProjectCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(DeleteProjectCommand))]
|
||||
private ProjectItemViewModel? _selectedProject;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isProjectSectionExpanded = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isSdkSectionExpanded = true;
|
||||
|
||||
[RelayCommand]
|
||||
private void NavigateTo(HubSection section)
|
||||
{
|
||||
CurrentSection = section;
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(HasSelectedProject))]
|
||||
private void OpenProject()
|
||||
{
|
||||
// TODO: hook this up to actually launching the editor process
|
||||
// against SelectedProject.Directory.
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(HasSelectedProject))]
|
||||
private void DeleteProject()
|
||||
{
|
||||
if (SelectedProject is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Projects.IndexOf(SelectedProject);
|
||||
Projects.Remove(SelectedProject);
|
||||
|
||||
SelectedProject = Projects.Count == 0
|
||||
? null
|
||||
: Projects[Math.Min(index, Projects.Count - 1)];
|
||||
}
|
||||
|
||||
private bool HasSelectedProject() => SelectedProject is not null;
|
||||
|
||||
[RelayCommand]
|
||||
private void CreateNewProject()
|
||||
{
|
||||
var project = new ProjectItemViewModel(new ProjectModel
|
||||
{
|
||||
Name = $"New Project {Projects.Count + 1}",
|
||||
LastModified = DateTime.Now,
|
||||
Directory = @"C:\Dev\NewProject",
|
||||
});
|
||||
|
||||
Projects.Insert(0, project);
|
||||
SelectedProject = project;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using NexvaneHub.Models;
|
||||
|
||||
namespace NexvaneHub.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// Editable wrapper around a ProjectModel. Every property here is a live,
|
||||
/// bindable field that writes straight back onto the wrapped Model when
|
||||
/// changed - except Directory, which stays read-only since it's tied to the
|
||||
/// project's location on disk rather than something you'd retype.
|
||||
/// </summary>
|
||||
public partial class ProjectItemViewModel : ViewModelBase
|
||||
{
|
||||
public ProjectItemViewModel(ProjectModel model)
|
||||
{
|
||||
Model = model;
|
||||
|
||||
_name = model.Name;
|
||||
_lastModified = model.LastModified;
|
||||
_directory = model.Directory;
|
||||
_thumbnailPath = model.ThumbnailPath;
|
||||
_projectVersion = model.ProjectVersion;
|
||||
_sdkVersion = model.SdkVersion;
|
||||
_defaultCompiler = model.DefaultCompiler;
|
||||
_defaultArchitecture = model.DefaultArchitecture;
|
||||
}
|
||||
|
||||
public ProjectModel Model { get; }
|
||||
|
||||
public string LastModifiedDisplay => LastModified.ToString("dd-MM-yyyy");
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(LastModifiedDisplay))]
|
||||
private DateTime _lastModified;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _name;
|
||||
|
||||
/// <summary>Read-only in the UI - displayed via a plain field, not a TextBox.</summary>
|
||||
[ObservableProperty]
|
||||
private string _directory;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _thumbnailPath;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _projectVersion;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _sdkVersion;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _defaultCompiler;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _defaultArchitecture;
|
||||
|
||||
partial void OnNameChanged(string value) => Model.Name = value;
|
||||
partial void OnThumbnailPathChanged(string value) => Model.ThumbnailPath = value;
|
||||
partial void OnProjectVersionChanged(string value) => Model.ProjectVersion = value;
|
||||
partial void OnSdkVersionChanged(string value) => Model.SdkVersion = value;
|
||||
partial void OnDefaultCompilerChanged(string value) => Model.DefaultCompiler = value;
|
||||
partial void OnDefaultArchitectureChanged(string value) => Model.DefaultArchitecture = value;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace NexvaneHub.ViewModels;
|
||||
|
||||
public abstract class ViewModelBase : ObservableObject
|
||||
{
|
||||
}
|
||||
Reference in new issue
Block a user