mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
move code to viewmodel
This commit is contained in:
parent
e2d50cd80b
commit
41b9cd496b
3 changed files with 15 additions and 6 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue