2024-07-23 18:20:01 +00:00
|
|
|
|
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;
|
2024-09-15 20:10:44 +00:00
|
|
|
|
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-07-23 18:20:01 +00:00
|
|
|
|
|
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-07-23 18:20:01 +00:00
|
|
|
|
|
2024-09-14 16:47:59 +00:00
|
|
|
|
[ObservableAsProperty]
|
2024-09-15 20:10:44 +00:00
|
|
|
|
private string _dbPath = "";
|
2024-09-14 16:47:59 +00:00
|
|
|
|
|
|
|
|
|
public MainWindowViewModel()
|
|
|
|
|
{
|
2024-09-15 20:10:44 +00:00
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-23 18:20:01 +00:00
|
|
|
|
public ObservableCollection<PlanetViewModel> Planets { get; } = PlanetViewModel.LoadAll();
|
|
|
|
|
|
2024-07-23 07:40:10 +00:00
|
|
|
|
}
|