forked from Misaki/GhostEngine
Refactor application structure and add database support
Changed App.xaml.cs to implement dependency injection with Microsoft.Extensions.Hosting, initializing services for LandingWindow and LandingViewModel. Removed MainWindow.xaml and MainWindow.xaml.cs, shifting to a new landing window structure. Added Ghost.Database project with necessary database functionality and created ProjectRepository for project management. Added ProjectInfo and TemplateInfo data models for project attributes. Added CreateProjectViewModel and LandingViewModel for managing view models using Community Toolkit for MVVM. Created new XAML pages for project creation, opening projects, and the landing window, along with their corresponding code-behind files. Added AssemblyInfo.cs for internal visibility to facilitate testing.
This commit is contained in:
41
Ghost.Editor/View/Pages/Landing/OpenProjectPage.xaml.cs
Normal file
41
Ghost.Editor/View/Pages/Landing/OpenProjectPage.xaml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Ghost.Database.DataContext;
|
||||
using Ghost.Database.Models.Projects;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace Ghost.Editor.View.Pages.Landing;
|
||||
|
||||
internal sealed partial class OpenProjectPage : Page
|
||||
{
|
||||
public readonly ObservableCollection<ProjectInfo> projects = new();
|
||||
|
||||
public OpenProjectPage()
|
||||
{
|
||||
foreach (var project in ProjectRepository.LoadProjects())
|
||||
{
|
||||
projects.Add(project);
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
if (projects.Count == 0)
|
||||
{
|
||||
PlaceHolderText.Visibility = Visibility.Visible;
|
||||
ProjectListView.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListView_ItemClick(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
if (e.ClickedItem is not ProjectInfo project)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: Load project
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user