From c2b265afd13d9ccebe066fa7fd3c53319ce28b78 Mon Sep 17 00:00:00 2001 From: Torben Nehmer Date: Sun, 22 Sep 2024 22:12:46 +0200 Subject: [PATCH] Started UI separation --- Stars Assistant/ViewModels/BuColViewModel.cs | 27 +++++++++++++++++++ .../ViewModels/MainWindowViewModel.cs | 6 ++--- Stars Assistant/Views/BuColView.axaml | 23 ++++++++++++++++ Stars Assistant/Views/BuColView.axaml.cs | 25 +++++++++++++++++ Stars Assistant/Views/MainWindow.axaml | 17 +++--------- 5 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 Stars Assistant/ViewModels/BuColViewModel.cs create mode 100644 Stars Assistant/Views/BuColView.axaml create mode 100644 Stars Assistant/Views/BuColView.axaml.cs diff --git a/Stars Assistant/ViewModels/BuColViewModel.cs b/Stars Assistant/ViewModels/BuColViewModel.cs new file mode 100644 index 0000000..5009287 --- /dev/null +++ b/Stars Assistant/ViewModels/BuColViewModel.cs @@ -0,0 +1,27 @@ +using System.Collections.ObjectModel; +using System.Reactive.Disposables; +using System.Reactive.Linq; + +using ReactiveUI; +using ReactiveUI.SourceGenerators; +using Splat; + +namespace StarsAssistant.ViewModels; + +public partial class BuColViewModel : ViewModelBase, IActivatableViewModel +{ + public ViewModelActivator Activator { get; } = new ViewModelActivator(); + + public BuColViewModel() + { + this.WhenActivated((CompositeDisposable disposables) => + { + // /* handle activation */ + // Disposable + // .Create(() => { /* handle deactivation */ }) + // .DisposeWith(disposables); + }); + } + + public ObservableCollection Planets { get; } = PlanetViewModel.LoadAll(); +} diff --git a/Stars Assistant/ViewModels/MainWindowViewModel.cs b/Stars Assistant/ViewModels/MainWindowViewModel.cs index fbed864..4e6184f 100644 --- a/Stars Assistant/ViewModels/MainWindowViewModel.cs +++ b/Stars Assistant/ViewModels/MainWindowViewModel.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; + using System.Reactive.Disposables; using System.Reactive.Linq; using ReactiveUI; @@ -28,8 +28,8 @@ public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel // .Create(() => { /* handle deactivation */ }) // .DisposeWith(disposables); }); - } + } - public ObservableCollection Planets { get; } = PlanetViewModel.LoadAll(); + } diff --git a/Stars Assistant/Views/BuColView.axaml b/Stars Assistant/Views/BuColView.axaml new file mode 100644 index 0000000..809c530 --- /dev/null +++ b/Stars Assistant/Views/BuColView.axaml @@ -0,0 +1,23 @@ + + + + + + + + + + + diff --git a/Stars Assistant/Views/BuColView.axaml.cs b/Stars Assistant/Views/BuColView.axaml.cs new file mode 100644 index 0000000..246a676 --- /dev/null +++ b/Stars Assistant/Views/BuColView.axaml.cs @@ -0,0 +1,25 @@ +using System.Reactive.Disposables; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; +using ReactiveUI; +using StarsAssistant.ViewModels; + +namespace StarsAssistant.Views; + +public partial class BuColView : ReactiveUserControl +{ + public BuColView() + { + /* + this.WhenActivated(disposables => + { + }); + */ + + this.ViewModel = new BuColViewModel(); + + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Stars Assistant/Views/MainWindow.axaml b/Stars Assistant/Views/MainWindow.axaml index bcaadb7..2185686 100644 --- a/Stars Assistant/Views/MainWindow.axaml +++ b/Stars Assistant/Views/MainWindow.axaml @@ -1,8 +1,9 @@ - - - - - - - + +