Skip to content

Commit 41b9cd4

Browse files
committed
move code to viewmodel
1 parent e2d50cd commit 41b9cd4

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Flow.Launcher/SelectBrowserWindow.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ private void btnDone_Click(object sender, RoutedEventArgs e)
3131

3232
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
3333
{
34-
var dlg = new Microsoft.Win32.OpenFileDialog();
35-
var result = dlg.ShowDialog();
36-
if (result == true)
34+
var selectedFilePath = _viewModel.SelectFile();
35+
36+
if (!string.IsNullOrEmpty(selectedFilePath))
3737
{
3838
var path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
39-
path.Text = dlg.FileName;
39+
path.Text = selectedFilePath;
4040
path.Focus();
4141
((Button)sender).Focus();
4242
}

Flow.Launcher/ViewModel/SelectBrowserViewModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.ObjectModel;
22
using System.Linq;
3+
using System.Windows;
34
using CommunityToolkit.Mvvm.Input;
45
using Flow.Launcher.Infrastructure.UserSettings;
56
using Flow.Launcher.Plugin;
@@ -40,6 +41,16 @@ public bool SaveSettings()
4041
return true;
4142
}
4243

44+
internal string SelectFile()
45+
{
46+
var dlg = new Microsoft.Win32.OpenFileDialog();
47+
var result = dlg.ShowDialog();
48+
if (result == true)
49+
return dlg.FileName;
50+
51+
return string.Empty;
52+
}
53+
4354
[RelayCommand]
4455
private void Add()
4556
{

Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ internal string SelectFile()
108108
var dlg = new Microsoft.Win32.OpenFileDialog();
109109
var result = dlg.ShowDialog();
110110
if (result == true)
111-
{
112111
return dlg.FileName;
113-
}
114112

115113
return string.Empty;
116114
}

0 commit comments

Comments
 (0)