sa/Stars Assistant/ViewModels/MainWindowViewModel.cs

36 lines
1.1 KiB
C#
Raw Normal View History

using System.Collections.ObjectModel;
2024-09-14 16:47:59 +00:00
using System.Reactive.Disposables;
using System.Reactive.Linq;
2024-09-13 19:09:33 +00:00
using ReactiveUI;
2024-09-14 16:47:59 +00:00
using ReactiveUI.SourceGenerators;
using Splat;
using StarsAssistant.Model;
2024-07-23 07:40:10 +00:00
2024-08-15 19:46:43 +00:00
namespace StarsAssistant.ViewModels;
2024-09-13 19:09:33 +00:00
public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel
2024-07-23 07:40:10 +00:00
{
2024-09-13 19:09:33 +00:00
public ViewModelActivator Activator { get; } = new ViewModelActivator();
2024-09-14 16:47:59 +00:00
[ObservableAsProperty]
private string _dbPath = "";
2024-09-14 16:47:59 +00:00
public MainWindowViewModel()
{
using var db = Locator.Current.GetService<StarsDatabase>()!;
_dbPathHelper = Observable.Return(Path.GetFullPath(db.DbPath))
.ToProperty(this, x => x.DbPath);
2024-09-14 16:47:59 +00:00
this.WhenActivated((CompositeDisposable disposables) =>
{
// /* handle activation */
// Disposable
// .Create(() => { /* handle deactivation */ })
// .DisposeWith(disposables);
});
}
public ObservableCollection<PlanetViewModel> Planets { get; } = PlanetViewModel.LoadAll();
2024-07-23 07:40:10 +00:00
}