|
1 | 1 | using System.Windows; |
2 | 2 | using System.Windows.Controls; |
3 | | -using Flow.Launcher.Plugin.Everything.Everything; |
| 3 | +using Flow.Launcher.Plugin.Everything.ViewModels; |
4 | 4 | using Microsoft.Win32; |
5 | 5 |
|
6 | 6 | namespace Flow.Launcher.Plugin.Everything |
7 | 7 | { |
8 | 8 | public partial class EverythingSettings : UserControl |
9 | 9 | { |
10 | | - public Settings _settings { get; } |
| 10 | + public Settings settings { get; } |
11 | 11 |
|
12 | | - public SortOption SortOption { get; set; } |
13 | | - public SortOption[] SortOptions { get; set; } |
| 12 | + private SettingsViewModel vm; |
14 | 13 |
|
15 | | - public EverythingSettings(Settings settings) |
| 14 | + public EverythingSettings(Settings settings, SettingsViewModel vm) |
16 | 15 | { |
17 | | - _settings = settings; |
18 | | - SortOption = settings.SortOption; |
19 | | - SortOptions = settings.SortOptions; |
20 | | - DataContext = this; |
| 16 | + this.settings = settings; |
| 17 | + this.vm = vm; |
| 18 | + DataContext = vm; |
21 | 19 | InitializeComponent(); |
22 | 20 | } |
23 | 21 |
|
24 | 22 | private void View_Loaded(object sender, RoutedEventArgs re) |
25 | 23 | { |
26 | | - UseLocationAsWorkingDir.IsChecked = _settings.UseLocationAsWorkingDir; |
| 24 | + UseLocationAsWorkingDir.IsChecked = settings.UseLocationAsWorkingDir; |
27 | 25 |
|
28 | 26 | UseLocationAsWorkingDir.Checked += (o, e) => |
29 | 27 | { |
30 | | - _settings.UseLocationAsWorkingDir = true; |
| 28 | + settings.UseLocationAsWorkingDir = true; |
31 | 29 | }; |
32 | 30 |
|
33 | 31 | UseLocationAsWorkingDir.Unchecked += (o, e) => |
34 | 32 | { |
35 | | - _settings.UseLocationAsWorkingDir = false; |
| 33 | + settings.UseLocationAsWorkingDir = false; |
36 | 34 | }; |
37 | 35 |
|
38 | | - LaunchHidden.IsChecked = _settings.LaunchHidden; |
| 36 | + LaunchHidden.IsChecked = settings.LaunchHidden; |
39 | 37 |
|
40 | 38 | LaunchHidden.Checked += (o, e) => |
41 | 39 | { |
42 | | - _settings.LaunchHidden = true; |
| 40 | + settings.LaunchHidden = true; |
43 | 41 | }; |
44 | 42 |
|
45 | 43 | LaunchHidden.Unchecked += (o, e) => |
46 | 44 | { |
47 | | - _settings.LaunchHidden = false; |
| 45 | + settings.LaunchHidden = false; |
48 | 46 | }; |
49 | 47 |
|
50 | | - EditorPath.Content = _settings.EditorPath; |
51 | | - CustomizeExplorerBox.Text = _settings.ExplorerPath; |
52 | | - CustomizeArgsBox.Text = _settings.ExplorerArgs; |
| 48 | + EditorPath.Content = settings.EditorPath; |
| 49 | + CustomizeExplorerBox.Text = settings.ExplorerPath; |
| 50 | + CustomizeArgsBox.Text = settings.ExplorerArgs; |
53 | 51 | } |
54 | 52 |
|
55 | 53 | private void EditorPath_Clicked(object sender, RoutedEventArgs e) |
56 | 54 | { |
57 | 55 | OpenFileDialog openFileDialog = new OpenFileDialog(); |
58 | 56 | openFileDialog.Filter = "Executable File(*.exe)| *.exe"; |
59 | | - if (!string.IsNullOrEmpty(_settings.EditorPath)) |
60 | | - openFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(_settings.EditorPath); |
| 57 | + if (!string.IsNullOrEmpty(settings.EditorPath)) |
| 58 | + openFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(settings.EditorPath); |
61 | 59 |
|
62 | 60 | if (openFileDialog.ShowDialog() == true) |
63 | 61 | { |
64 | | - _settings.EditorPath = openFileDialog.FileName; |
| 62 | + settings.EditorPath = openFileDialog.FileName; |
65 | 63 | } |
66 | 64 |
|
67 | | - EditorPath.Content = _settings.EditorPath; |
| 65 | + EditorPath.Content = settings.EditorPath; |
68 | 66 | } |
69 | 67 |
|
70 | 68 | private void CustomizeExplorer(object sender, TextChangedEventArgs e) |
71 | 69 | { |
72 | | - _settings.ExplorerPath = CustomizeExplorerBox.Text; |
| 70 | + settings.ExplorerPath = CustomizeExplorerBox.Text; |
73 | 71 | } |
74 | 72 |
|
75 | 73 | private void CustomizeExplorerArgs(object sender, TextChangedEventArgs e) |
76 | 74 | { |
77 | | - _settings.ExplorerArgs = CustomizeArgsBox.Text; |
| 75 | + settings.ExplorerArgs = CustomizeArgsBox.Text; |
| 76 | + } |
| 77 | + |
| 78 | + private void onSelectionChange(object sender, SelectionChangedEventArgs e) |
| 79 | + { |
| 80 | + // on load, tbFastSortWarning control will not have been loaded yet |
| 81 | + if (tbFastSortWarning is not null) |
| 82 | + { |
| 83 | + tbFastSortWarning.Visibility = vm.FastSortWarningVisibility; |
| 84 | + tbFastSortWarning.Text = vm.GetSortOptionWarningMessage; |
| 85 | + } |
78 | 86 | } |
79 | 87 | } |
80 | 88 | } |
0 commit comments