Flow.Launcher/Flow.Launcher/SelectBrowserWindow.xaml.cs

46 lines
1.3 KiB
C#
Raw Normal View History

2025-05-21 04:58:55 +00:00
using System.Windows;
2021-11-08 09:40:20 +00:00
using System.Windows.Controls;
2025-05-21 04:58:55 +00:00
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.ViewModel;
2021-11-08 09:40:20 +00:00
namespace Flow.Launcher
{
public partial class SelectBrowserWindow : Window
2021-11-08 09:40:20 +00:00
{
2025-05-21 04:58:55 +00:00
private readonly SelectBrowserViewModel _viewModel;
2021-11-16 03:09:20 +00:00
2025-05-21 04:58:55 +00:00
public SelectBrowserWindow()
2021-11-08 09:40:20 +00:00
{
2025-05-21 04:58:55 +00:00
_viewModel = Ioc.Default.GetRequiredService<SelectBrowserViewModel>();
DataContext = _viewModel;
2021-11-08 09:40:20 +00:00
InitializeComponent();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
2021-11-16 03:09:20 +00:00
Close();
2021-11-08 09:40:20 +00:00
}
private void btnDone_Click(object sender, RoutedEventArgs e)
{
2025-05-21 04:58:55 +00:00
if (_viewModel.SaveSettings())
2021-11-16 03:09:20 +00:00
{
2025-05-21 04:58:55 +00:00
Close();
}
2021-11-08 09:40:20 +00:00
}
2021-11-16 03:09:20 +00:00
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
2025-05-21 11:39:46 +00:00
var selectedFilePath = _viewModel.SelectFile();
if (!string.IsNullOrEmpty(selectedFilePath))
2021-11-16 03:09:20 +00:00
{
2025-05-21 04:58:55 +00:00
var path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
2025-05-21 11:39:46 +00:00
path.Text = selectedFilePath;
2021-11-16 03:09:20 +00:00
path.Focus();
((Button)sender).Focus();
}
}
}
2021-11-08 09:40:20 +00:00
}