mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-29 07:27:36 +08:00
🐛 FilePicker2
This commit is contained in:
+1
-1
Submodule ref/Common updated: 5e73ea70e3...a7b6b65810
+1
-1
Submodule ref/DirectoryPackages updated: 222cdce33d...7e9b98628d
+23
-1
@@ -25,7 +25,13 @@ sealed class AvaloniaFilePickerPlatformService : BaseService, IServiceBase, IOpe
|
||||
UTType.PNG, UTType.JPEG, "jpeg",
|
||||
});
|
||||
#else
|
||||
FilePickerFileType.Parse(FileEx.Images);
|
||||
FilePickerFileType.Parse(new[] {
|
||||
FileEx.WebP,
|
||||
FileEx.Png,
|
||||
FileEx.JPG,
|
||||
FileEx.JPEG,
|
||||
//FileEx.Gif,
|
||||
});
|
||||
#endif
|
||||
|
||||
IFilePickerFileType IInternalFilePickerPlatformService.Png => FilePickerFileType.Parse(new string[] {
|
||||
@@ -80,6 +86,22 @@ sealed class AvaloniaFilePickerPlatformService : BaseService, IServiceBase, IOpe
|
||||
{
|
||||
#if IOS || MACOS || MACCATALYST
|
||||
AppleUniformTypeIdentifiers = extensions?.ToArray(),
|
||||
#elif WINDOWS
|
||||
Patterns = extensions?.Select(x =>
|
||||
{
|
||||
if (x.StartsWith('.'))
|
||||
{
|
||||
return $"*{x}";
|
||||
}
|
||||
else if (x.StartsWith('*'))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"*.{x}";
|
||||
}
|
||||
}).ToArray(),
|
||||
#else
|
||||
Patterns = IServiceBase.FormatExtensions(extensions, trimLeadingPeriod: true).ToArray(),
|
||||
#endif
|
||||
|
||||
@@ -74,7 +74,7 @@ public sealed class CustomFilePicker : ContentControl
|
||||
this.Tapped += CustomFilePicker_Tapped;
|
||||
}
|
||||
|
||||
private async void CustomFilePicker_Tapped(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
private async void CustomFilePicker_Tapped(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
//if (string.IsNullOrEmpty(FileExtensions) || FileExtensions == "*")
|
||||
//{
|
||||
|
||||
@@ -41,11 +41,6 @@ public sealed partial class PlatformAccount
|
||||
|
||||
SetAccountAvatarCommand = ReactiveCommand.Create<IAccount>(async acc =>
|
||||
{
|
||||
FilePickerFileType fileTypes = new ValueTuple<string, string[]>[]
|
||||
{
|
||||
("Image Files", FileEx.Images.Select(s => $"*{s}").ToArray()),
|
||||
};
|
||||
|
||||
await FilePicker2.PickAsync((path) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(acc.AccountName))
|
||||
@@ -54,7 +49,7 @@ public sealed partial class PlatformAccount
|
||||
File.Copy(path, imagePath, true);
|
||||
acc.ImagePath = imagePath;
|
||||
}
|
||||
}, fileTypes);
|
||||
}, IFilePickerFileType.Images());
|
||||
});
|
||||
EditRemarkCommand = ReactiveCommand.Create<IAccount>(async acc =>
|
||||
{
|
||||
|
||||
@@ -41,12 +41,13 @@ public sealed partial class SettingsPageViewModel : TabItemViewModel
|
||||
|
||||
SelectImage_Click = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
FilePickerFileType fileTypes = new ValueTuple<string, string[]>[]
|
||||
{
|
||||
("Image Files", FileEx.Images.Select(s => $"*{s}").ToArray()),
|
||||
//("All Files", new[] { "*", }),
|
||||
};
|
||||
await FilePicker2.PickAsync(SetBackgroundImagePath, fileTypes);
|
||||
//FilePickerFileType fileTypes = new ValueTuple<string, string[]>[]
|
||||
//{
|
||||
// ("Image Files", FileEx.Images.Select(s => $"*{s}").ToArray()),
|
||||
// //("All Files", new[] { "*", }),
|
||||
//};
|
||||
//await FilePicker2.PickAsync(SetBackgroundImagePath, fileTypes);
|
||||
await FilePicker2.PickAsync(SetBackgroundImagePath, IFilePickerFileType.Images());
|
||||
});
|
||||
|
||||
ResetImage_Click = ReactiveCommand.Create(() => SetBackgroundImagePath(null));
|
||||
|
||||
Reference in New Issue
Block a user