Flow.Launcher/Flow.Launcher/SelectFileManagerWindow.xaml.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2025-05-21 04:58:55 +00:00
using System.Windows;
2021-10-30 18:49:23 +00:00
using System.Windows.Controls;
2025-05-21 03:59:24 +00:00
using System.Windows.Navigation;
2025-05-21 04:58:55 +00:00
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.ViewModel;
2021-10-30 18:49:23 +00:00
namespace Flow.Launcher
{
public partial class SelectFileManagerWindow : Window
2021-10-30 18:49:23 +00:00
{
2025-05-21 04:58:55 +00:00
private readonly SelectFileManagerViewModel _viewModel;
2021-11-02 20:07:11 +00:00
2025-05-21 04:58:55 +00:00
public SelectFileManagerWindow()
2021-11-05 19:16:20 +00:00
{
2025-05-21 04:58:55 +00:00
_viewModel = Ioc.Default.GetRequiredService<SelectFileManagerViewModel>();
DataContext = _viewModel;
2021-10-30 18:49:23 +00:00
InitializeComponent();
}
2021-11-05 19:16:20 +00:00
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void btnDone_Click(object sender, RoutedEventArgs e)
{
2025-05-21 04:58:55 +00:00
if (_viewModel.SaveSettings())
{
2025-05-21 04:58:55 +00:00
Close();
}
2021-11-05 19:16:20 +00:00
}
2021-11-06 06:04:37 +00:00
2021-11-09 23:30:10 +00:00
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
var selectedFilePath = Win32Helper.SelectFile();
2025-05-21 11:30:47 +00:00
if (!string.IsNullOrEmpty(selectedFilePath))
2021-11-09 23:30:10 +00:00
{
2025-05-21 04:58:55 +00:00
var path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
2025-05-21 11:30:47 +00:00
path.Text = selectedFilePath;
2021-11-09 23:30:10 +00:00
path.Focus();
((Button)sender).Focus();
}
}
2021-10-30 18:49:23 +00:00
}
}