diff --git a/src/Helpers/Constants.cs b/src/Helpers/Constants.cs index 6ae1228..f79ea1c 100644 --- a/src/Helpers/Constants.cs +++ b/src/Helpers/Constants.cs @@ -7,6 +7,9 @@ class Constants { public static string AppVersion = "1.2.0"; + public static string[] AllowedFileExtensionPatterns = [ "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp", "*.pdf", "*.heic", ]; + public static string[] AllowedFileExtensionsNoStar = [ "png", "jpg", "jpeg", "gif", "bmp", "webp", "pdf", "heic", ]; + public static string[] GetQuotes() { // sources: diff --git a/src/ViewModels/MainViewModel.cs b/src/ViewModels/MainViewModel.cs index de5fad3..f03be1b 100644 --- a/src/ViewModels/MainViewModel.cs +++ b/src/ViewModels/MainViewModel.cs @@ -280,18 +280,6 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown } } - private string[] GetAllowedFileExtensionPatterns() - { - // update GetAllowedFileExtensionPatternsWithoutStar if this is edited - return [ "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp", "*.pdf", "*.heic", ]; - } - - private string[] GetAllowedFileExtensionPatternsWithoutStar() - { - // update GetAllowedFileExtensionPatterns if this is edited - return [ "png", "jpg", "jpeg", "gif", "bmp", "webp", "pdf", "heic", ]; - } - public async void AddItem() { var topLevel = TopLevelGrabber?.GetTopLevel(); @@ -304,7 +292,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown FileTypeFilter = [ new FilePickerFileType("All Types") { - Patterns = GetAllowedFileExtensionPatterns(), + Patterns = Constants.AllowedFileExtensionPatterns, AppleUniformTypeIdentifiers = [ "public.image", "com.adobe.pdf", "public.heic" ], MimeTypes = [ "image/*", "application/pdf", "image/heic" ] }, @@ -334,7 +322,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown if (!string.IsNullOrWhiteSpace(filePath) && File.Exists(filePath) && !filePath.EndsWith(".DS_Store")) { // make sure extensions are OK - var fileExtensions = GetAllowedFileExtensionPatternsWithoutStar(); + var fileExtensions = Constants.AllowedFileExtensionsNoStar; var didMatch = false; foreach (var fileExtension in fileExtensions) { @@ -390,7 +378,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown FileTypeFilter = [ new FilePickerFileType("All Types") { - Patterns = GetAllowedFileExtensionPatterns(), + Patterns = Constants.AllowedFileExtensionPatterns, AppleUniformTypeIdentifiers = [ "public.image", "com.adobe.pdf", "public.heic" ], MimeTypes = [ "image/*", "application/pdf", "image/heic" ] },