diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 811733925..5d30b740d 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -904,5 +904,19 @@ namespace Flow.Launcher.Infrastructure } #endregion + + #region File / Folder Dialog + + public static string SelectFile() + { + var dlg = new OpenFileDialog(); + var result = dlg.ShowDialog(); + if (result == true) + return dlg.FileName; + + return string.Empty; + } + + #endregion } } diff --git a/Flow.Launcher/SelectBrowserWindow.xaml.cs b/Flow.Launcher/SelectBrowserWindow.xaml.cs index 8ef50ca75..290712aad 100644 --- a/Flow.Launcher/SelectBrowserWindow.xaml.cs +++ b/Flow.Launcher/SelectBrowserWindow.xaml.cs @@ -1,6 +1,7 @@ using System.Windows; using System.Windows.Controls; using CommunityToolkit.Mvvm.DependencyInjection; +using Flow.Launcher.Infrastructure; using Flow.Launcher.ViewModel; namespace Flow.Launcher @@ -31,7 +32,7 @@ namespace Flow.Launcher private void btnBrowseFile_Click(object sender, RoutedEventArgs e) { - var selectedFilePath = SelectFile(); + var selectedFilePath = Win32Helper.SelectFile(); if (!string.IsNullOrEmpty(selectedFilePath)) { @@ -41,15 +42,5 @@ namespace Flow.Launcher ((Button)sender).Focus(); } } - - private static string SelectFile() - { - var dlg = new Microsoft.Win32.OpenFileDialog(); - var result = dlg.ShowDialog(); - if (result == true) - return dlg.FileName; - - return string.Empty; - } } } diff --git a/Flow.Launcher/SelectFileManagerWindow.xaml.cs b/Flow.Launcher/SelectFileManagerWindow.xaml.cs index d9c672aff..5143f9a56 100644 --- a/Flow.Launcher/SelectFileManagerWindow.xaml.cs +++ b/Flow.Launcher/SelectFileManagerWindow.xaml.cs @@ -2,6 +2,7 @@ using System.Windows.Controls; using System.Windows.Navigation; using CommunityToolkit.Mvvm.DependencyInjection; +using Flow.Launcher.Infrastructure; using Flow.Launcher.ViewModel; namespace Flow.Launcher @@ -32,13 +33,13 @@ namespace Flow.Launcher private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) { - _viewModel.OpenUrl(e.Uri.AbsoluteUri); + App.API.OpenUrl(e.Uri.AbsoluteUri); e.Handled = true; } private void btnBrowseFile_Click(object sender, RoutedEventArgs e) { - var selectedFilePath = _viewModel.SelectFile(); + var selectedFilePath = Win32Helper.SelectFile(); if (!string.IsNullOrEmpty(selectedFilePath)) { diff --git a/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs b/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs index 77f004980..253f74b47 100644 --- a/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs +++ b/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs @@ -98,21 +98,6 @@ public partial class SelectFileManagerViewModel : BaseModel } } - internal void OpenUrl(string absoluteUri) - { - App.API.OpenUrl(absoluteUri); - } - - internal string SelectFile() - { - var dlg = new Microsoft.Win32.OpenFileDialog(); - var result = dlg.ShowDialog(); - if (result == true) - return dlg.FileName; - - return string.Empty; - } - [RelayCommand] private void Add() {