diff --git a/Flow.Launcher/SelectBrowserWindow.xaml.cs b/Flow.Launcher/SelectBrowserWindow.xaml.cs index 2d200fe98..565b4cbc3 100644 --- a/Flow.Launcher/SelectBrowserWindow.xaml.cs +++ b/Flow.Launcher/SelectBrowserWindow.xaml.cs @@ -31,12 +31,12 @@ namespace Flow.Launcher private void btnBrowseFile_Click(object sender, RoutedEventArgs e) { - var dlg = new Microsoft.Win32.OpenFileDialog(); - var result = dlg.ShowDialog(); - if (result == true) + var selectedFilePath = _viewModel.SelectFile(); + + if (!string.IsNullOrEmpty(selectedFilePath)) { var path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox"); - path.Text = dlg.FileName; + path.Text = selectedFilePath; path.Focus(); ((Button)sender).Focus(); } diff --git a/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs b/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs index 12f43d752..1eee6dba5 100644 --- a/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs +++ b/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs @@ -1,5 +1,6 @@ using System.Collections.ObjectModel; using System.Linq; +using System.Windows; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; @@ -40,6 +41,16 @@ public partial class SelectBrowserViewModel : BaseModel return true; } + 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() { diff --git a/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs b/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs index a72eff280..77f004980 100644 --- a/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs +++ b/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs @@ -108,9 +108,7 @@ public partial class SelectFileManagerViewModel : BaseModel var dlg = new Microsoft.Win32.OpenFileDialog(); var result = dlg.ShowDialog(); if (result == true) - { return dlg.FileName; - } return string.Empty; }