Skip to content

Commit

Permalink
fix: Savedialog
Browse files Browse the repository at this point in the history
  • Loading branch information
furesoft committed Sep 29, 2024
1 parent 93cf431 commit 23eb616
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/MimaSim/MimaSim/ViewModels/ExecutionTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ public ExecutionTabViewModel()

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

var lifetime = App.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime;

LoadCommand = ReactiveCommand.Create(async () =>
{
var lifetime = App.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime;
if (!lifetime.MainWindow.StorageProvider.CanOpen)
{
DialogService.Open(new TextBlock(){Text = "cannot open file"});
}
var filenames = await lifetime.MainWindow.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
{
Title = "Programm laden"
Expand All @@ -60,14 +55,10 @@ public ExecutionTabViewModel()

SaveCommand = ReactiveCommand.Create(async () =>
{
var svd = new SaveFileDialog();
svd.Title = "Programm speichern";
var window = App.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime;
var filename = await svd.ShowAsync(window.MainWindow);
var file = await lifetime.MainWindow.StorageProvider.SaveFilePickerAsync(new() { Title = "Programm speichern" });
await using var writer = new StreamWriter(await file.OpenWriteAsync());
File.WriteAllText(filename, Source);
writer.Write(Source);
});

RunCodeCommand = ReactiveCommand.Create(() =>
Expand Down

0 comments on commit 23eb616

Please sign in to comment.