Skip to content

Commit 07f77f0

Browse files
committed
move calls to viewmodel
1 parent 9a692a8 commit 07f77f0

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Flow.Launcher/SelectFileManagerWindow.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ private void btnDone_Click(object sender, RoutedEventArgs e)
3232

3333
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
3434
{
35-
App.API.OpenUrl(e.Uri.AbsoluteUri);
35+
_viewModel.OpenUrl(e.Uri.AbsoluteUri);
3636
e.Handled = true;
3737
}
3838

3939
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
4040
{
41-
var dlg = new Microsoft.Win32.OpenFileDialog();
42-
var result = dlg.ShowDialog();
43-
if (result == true)
41+
var selectedFilePath = _viewModel.SelectFile();
42+
43+
if (!string.IsNullOrEmpty(selectedFilePath))
4444
{
4545
var path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
46-
path.Text = dlg.FileName;
46+
path.Text = selectedFilePath;
4747
path.Focus();
4848
((Button)sender).Focus();
4949
}

Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ private static bool IsFileManagerValid(string path)
9898
}
9999
}
100100

101+
internal void OpenUrl(string absoluteUri)
102+
{
103+
App.API.OpenUrl(absoluteUri);
104+
}
105+
106+
internal string SelectFile()
107+
{
108+
var dlg = new Microsoft.Win32.OpenFileDialog();
109+
var result = dlg.ShowDialog();
110+
if (result == true)
111+
{
112+
return dlg.FileName;
113+
}
114+
115+
return string.Empty;
116+
}
117+
101118
[RelayCommand]
102119
private void Add()
103120
{

0 commit comments

Comments
 (0)