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:
47
Ghost.Editor/View/Windows/LandingWindow.xaml.cs
Normal file
47
Ghost.Editor/View/Windows/LandingWindow.xaml.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
using Ghost.Editor.View.Pages.Landing;
|
||||
using Ghost.Editor.ViewModel.Windows;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
|
||||
namespace Ghost.Editor.View.Windows;
|
||||
|
||||
internal sealed partial class LandingWindow : Window
|
||||
{
|
||||
public LandingViewModel ViewModel
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
private int _previousSelectedIndex;
|
||||
|
||||
public LandingWindow(LandingViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
AppWindow.Resize(new(1200, 900));
|
||||
}
|
||||
|
||||
private void SelectorBar_SelectionChanged(SelectorBar sender, SelectorBarSelectionChangedEventArgs e)
|
||||
{
|
||||
var selectedItem = sender.SelectedItem;
|
||||
var currentSelectedIndex = sender.Items.IndexOf(selectedItem);
|
||||
var pageType = currentSelectedIndex switch
|
||||
{
|
||||
1 => typeof(CreateProjectPage),
|
||||
_ => typeof(OpenProjectPage),
|
||||
};
|
||||
|
||||
var slideNavigationTransitionEffect = currentSelectedIndex - _previousSelectedIndex > 0 ?
|
||||
SlideNavigationTransitionEffect.FromRight : SlideNavigationTransitionEffect.FromLeft;
|
||||
|
||||
ContentFrame.Navigate(pageType, null, new SlideNavigationTransitionInfo() { Effect = slideNavigationTransitionEffect });
|
||||
|
||||
_previousSelectedIndex = currentSelectedIndex;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user