AvaloniaUI / XamlPlayground

Avalonia Xaml Playground
https://play.avaloniaui.net/
MIT License
58 stars 17 forks source link

Adjustable editor font size, open/save file functionality. #3

Closed hummy123 closed 2 years ago

hummy123 commented 2 years ago

Worth noting perhaps that the open and save file dialog commands take in a new Window() in their ShowAsync method instead of using the parent window, which works absolutely fine from my manual tests.

I wasn't able to send the parent window to the MainViewModel in all cases because I couldn't find a way to access the main window in the else-statement below.

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
  desktop.MainWindow = new MainWindow {
    DataContext = new MainViewModel()
  };
} else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform) {
  singleViewPlatform.MainView = new MainView {
    DataContext = new MainViewModel()
  };
}

Happy to make any changes if requested.

wieslawsoltes commented 2 years ago

You need to use new Avalonia api IStorageProvider https://github.com/wieslawsoltes/SvgToXaml/blob/09495e9120e19dce91b65ad5e53d4990a0114dd8/src/SvgToXaml.Base/ViewModels/StorageService.cs#L58-L75 and file picker api: https://github.com/wieslawsoltes/SvgToXaml/blob/09495e9120e19dce91b65ad5e53d4990a0114dd8/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs#L172-L250

hummy123 commented 2 years ago

Thanks for the feedback. I got a deprecation warning in the IDE for the Open/SaveFileDialog APIs, but thought that was about the APIs being deprecated in WPF (not sure if the Avalonia documentation mentions the new APIs).

I'll get to it soon hopefully.

wieslawsoltes commented 2 years ago

Thanks for the feedback. I got a deprecation warning in the IDE for the Open/SaveFileDialog APIs, but thought that was about the APIs being deprecated in WPF (not sure if the Avalonia documentation mentions the new APIs).

I'll get to it soon hopefully.

I use preview version so docs are not yet updated.

wieslawsoltes commented 2 years ago

@hummy123 I am in middle of updating my project to new Avalonia version ,this project was next in line, I will push some updates to main branch.

hummy123 commented 2 years ago

@hummy123 I am in middle of updating my project to new Avalonia version ,this project was next in line, I will push some updates to main branch.

Thanks for letting me know. I'll wait until the upgrade is done to fix the conflicts (the new APIs you linked to are done on my side) and let you know when I think it's in a state to be merged.

wieslawsoltes commented 2 years ago

I have fixed conflicts