2021-11-16 03:09:20 +00:00
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
|
|
|
|
using Flow.Launcher.ViewModel;
|
|
|
|
|
|
using System;
|
2021-11-08 09:40:20 +00:00
|
|
|
|
using System.Collections.Generic;
|
2021-11-16 03:09:20 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.ComponentModel;
|
2021-11-08 09:40:20 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Flow.Launcher
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// SelectBrowserWindow.xaml에 대한 상호 작용 논리
|
|
|
|
|
|
/// </summary>
|
2021-11-16 03:09:20 +00:00
|
|
|
|
public partial class SelectBrowserWindow : Window, INotifyPropertyChanged
|
2021-11-08 09:40:20 +00:00
|
|
|
|
{
|
2021-11-16 03:09:20 +00:00
|
|
|
|
private int selectedCustomExplorerIndex;
|
|
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
public Settings Settings { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public int SelectedCustomBrowserIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => selectedCustomExplorerIndex; set
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedCustomExplorerIndex = value;
|
|
|
|
|
|
PropertyChanged?.Invoke(this, new(nameof(CustomExplorer)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public ObservableCollection<CustomBrowserViewModel> CustomBrowsers { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public CustomBrowserViewModel CustomExplorer => CustomBrowsers[SelectedCustomBrowserIndex];
|
|
|
|
|
|
public SelectBrowserWindow(Settings settings)
|
2021-11-08 09:40:20 +00:00
|
|
|
|
{
|
2021-11-16 03:09:20 +00:00
|
|
|
|
Settings = settings;
|
|
|
|
|
|
CustomBrowsers = new ObservableCollection<CustomBrowserViewModel>(Settings.CustomBrowserList.Select(x => x.Copy()));
|
|
|
|
|
|
SelectedCustomBrowserIndex = Settings.CustomExplorerIndex;
|
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)
|
|
|
|
|
|
{
|
2021-11-16 03:09:20 +00:00
|
|
|
|
Settings.CustomBrowserList = CustomBrowsers.ToList();
|
|
|
|
|
|
Settings.CustomBrowserIndex = SelectedCustomBrowserIndex;
|
|
|
|
|
|
Close();
|
2021-11-08 09:40:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2021-11-16 03:09:20 +00:00
|
|
|
|
CustomBrowsers.Add(new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "New Profile"
|
|
|
|
|
|
});
|
|
|
|
|
|
SelectedCustomBrowserIndex = CustomBrowsers.Count - 1;
|
2021-11-08 09:40:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnDelete_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2021-11-16 03:09:20 +00:00
|
|
|
|
CustomBrowsers.RemoveAt(SelectedCustomBrowserIndex--);
|
2021-11-08 09:40:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-16 03:09:20 +00:00
|
|
|
|
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
|
|
|
|
|
|
Nullable<bool> result = dlg.ShowDialog();
|
2021-11-08 09:40:20 +00:00
|
|
|
|
|
2021-11-16 03:09:20 +00:00
|
|
|
|
if (result == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
TextBox path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
|
|
|
|
|
|
path.Text = dlg.FileName;
|
|
|
|
|
|
path.Focus();
|
|
|
|
|
|
((Button)sender).Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-11-08 09:40:20 +00:00
|
|
|
|
}
|