Skip to content

Commit

Permalink
Automated JetBrains cleanup
Browse files Browse the repository at this point in the history
Co-authored-by:  <+@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Nov 25, 2024
1 parent 55eee41 commit adad00e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
15 changes: 9 additions & 6 deletions src/Consolonia.Core/Controls/FileSavePicker.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,26 @@ private async void OnOK(object sender, RoutedEventArgs e)
ArgumentNullException.ThrowIfNull(lifetime.MainWindow);
ArgumentNullException.ThrowIfNull(lifetime.MainWindow.StorageProvider);

var savePath = ViewModel.SavePath;
string savePath = ViewModel.SavePath;
if (!Path.IsPathFullyQualified(ViewModel.SavePath))
{
savePath = Path.GetFullPath(Path.Combine(ViewModel.CurrentFolder.Path.LocalPath, ViewModel.SavePath));
}

var file = await lifetime.MainWindow.StorageProvider.TryGetFileFromPathAsync(new Uri($"file://{savePath}"));
IStorageFile file =
await lifetime.MainWindow.StorageProvider.TryGetFileFromPathAsync(new Uri($"file://{savePath}"));
if (file == null)
{
var folder = await lifetime.MainWindow.StorageProvider.TryGetFolderFromPathAsync(new Uri($"file://{Path.GetDirectoryName(savePath)}"));
IStorageFolder folder =
await lifetime.MainWindow.StorageProvider.TryGetFolderFromPathAsync(
new Uri($"file://{Path.GetDirectoryName(savePath)}"));
if (folder == null)
{
CloseDialog();
return;
}
file = await folder.CreateFileAsync(Path.GetFileName(savePath));

file = await folder.CreateFileAsync(Path.GetFileName(savePath));
}

CloseDialog(file);
}

Expand Down
16 changes: 7 additions & 9 deletions src/Consolonia.Core/Controls/FileSavePickerViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using System.ComponentModel;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;

namespace Consolonia.Core.Controls
{
public partial class FileSavePickerViewModel : PickerViewModelBase<FilePickerSaveOptions>
{
[ObservableProperty] private string _savePath=string.Empty;
[ObservableProperty] private string _savePath = string.Empty;

[ObservableProperty] [NotifyPropertyChangedFor(nameof(SelectedFile))]
private IStorageItem _selectedItem;
Expand All @@ -15,19 +16,16 @@ public FileSavePickerViewModel(FilePickerSaveOptions options)
: base(options)
{
ArgumentNullException.ThrowIfNull(options, nameof(options));
this.PropertyChanged += FileSavePickerViewModel_PropertyChanged;
PropertyChanged += FileSavePickerViewModel_PropertyChanged;
}

private void FileSavePickerViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
public IStorageFile SelectedFile => SelectedItem as IStorageFile;

private void FileSavePickerViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SelectedFile))
{
SavePath = SelectedFile.Path.LocalPath;
}
if (e.PropertyName == nameof(SelectedFile)) SavePath = SelectedFile.Path.LocalPath;
}

public IStorageFile SelectedFile => SelectedItem as IStorageFile;

protected override bool FilterItem(IStorageItem item)
{
return true;
Expand Down

0 comments on commit adad00e

Please sign in to comment.