Skip to content

Commit

Permalink
refactor: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
furesoft committed Oct 1, 2024
1 parent 623d339 commit eab548b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/MimaSim/MimaSim/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Reflection;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Avalonia.Platform.Storage;
using MimaSim.MIMA.Components;
using MimaSim.Views;
using ReactiveUI;
Expand All @@ -28,13 +30,16 @@ public override void OnFrameworkInitializationCompleted()
{
//DataContext = new MainViewModel()
};
Locator.CurrentMutable.Register<IStorageProvider>(() => desktop.MainWindow.StorageProvider);

}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
//DataContext = new MainViewModel()
};
Locator.CurrentMutable.Register<IStorageProvider>(() => TopLevel.GetTopLevel(singleViewPlatform.MainView)!.StorageProvider);
}

base.OnFrameworkInitializationCompleted();
Expand Down
16 changes: 2 additions & 14 deletions src/MimaSim/MimaSim/ViewModels/ExecutionTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Windows.Input;
using Avalonia.Platform.Storage;
using MimaSim.ViewModels.Mima;
using Splat;

namespace MimaSim.ViewModels;

Expand All @@ -39,20 +40,7 @@ public ExecutionTabViewModel()

OpenMemoryPopupCommand = DialogService.CreateOpenCommand(new MemoryPopupControl(), new MemoryPopupViewModel());

IStorageProvider storage;

if (App.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
storage = desktop.MainWindow!.StorageProvider;
}
else if (App.Current.ApplicationLifetime is ISingleViewApplicationLifetime singleView)
{
storage = TopLevel.GetTopLevel(singleView.MainView)!.StorageProvider;
}
else
{
throw new Exception("No storage");
}
IStorageProvider storage = Locator.Current.GetService<IStorageProvider>();

LoadCommand = ReactiveCommand.Create(async () =>
{
Expand Down

0 comments on commit eab548b

Please sign in to comment.