1
1
using System ;
2
- using System . Diagnostics ;
3
2
using System . IO ;
4
3
using System . Windows ;
5
4
using System . Windows . Input ;
@@ -21,17 +20,17 @@ public partial class SettingWindow
21
20
{
22
21
private const string StartupPath = "SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Run" ;
23
22
24
- public readonly IPublicAPI _api ;
25
- private Settings _settings ;
26
- private SettingWindowViewModel _viewModel ;
23
+ public readonly IPublicAPI API ;
24
+ private Settings settings ;
25
+ private SettingWindowViewModel viewModel ;
27
26
28
27
public SettingWindow ( IPublicAPI api , SettingWindowViewModel viewModel )
29
28
{
30
29
InitializeComponent ( ) ;
31
- _settings = viewModel . Settings ;
30
+ settings = viewModel . Settings ;
32
31
DataContext = viewModel ;
33
- _viewModel = viewModel ;
34
- _api = api ;
32
+ this . viewModel = viewModel ;
33
+ API = api ;
35
34
}
36
35
37
36
#region General
@@ -94,7 +93,7 @@ private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
94
93
var pythonPath = Path . Combine ( pythonDirectory , PluginsLoader . PythonExecutable ) ;
95
94
if ( File . Exists ( pythonPath ) )
96
95
{
97
- _settings . PluginSettings . PythonDirectory = pythonDirectory ;
96
+ settings . PluginSettings . PythonDirectory = pythonDirectory ;
98
97
MessageBox . Show ( "Remember to restart Flow Launcher use new Python path" ) ;
99
98
}
100
99
else
@@ -111,7 +110,7 @@ private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
111
110
112
111
private void OnHotkeyControlLoaded ( object sender , RoutedEventArgs e )
113
112
{
114
- HotkeyControl . SetHotkey ( _viewModel . Settings . Hotkey , false ) ;
113
+ HotkeyControl . SetHotkey ( viewModel . Settings . Hotkey , false ) ;
115
114
}
116
115
117
116
void OnHotkeyChanged ( object sender , EventArgs e )
@@ -129,8 +128,8 @@ void OnHotkeyChanged(object sender, EventArgs e)
129
128
Application . Current . MainWindow . Visibility = Visibility . Hidden ;
130
129
}
131
130
} ) ;
132
- RemoveHotkey ( _settings . Hotkey ) ;
133
- _settings . Hotkey = HotkeyControl . CurrentHotkey . ToString ( ) ;
131
+ RemoveHotkey ( settings . Hotkey ) ;
132
+ settings . Hotkey = HotkeyControl . CurrentHotkey . ToString ( ) ;
134
133
}
135
134
}
136
135
@@ -159,7 +158,7 @@ void RemoveHotkey(string hotkeyStr)
159
158
160
159
private void OnDeleteCustomHotkeyClick ( object sender , RoutedEventArgs e )
161
160
{
162
- var item = _viewModel . SelectedCustomPluginHotkey ;
161
+ var item = viewModel . SelectedCustomPluginHotkey ;
163
162
if ( item == null )
164
163
{
165
164
MessageBox . Show ( InternationalizationManager . Instance . GetTranslation ( "pleaseSelectAnItem" ) ) ;
@@ -173,17 +172,17 @@ private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e)
173
172
MessageBox . Show ( deleteWarning , InternationalizationManager . Instance . GetTranslation ( "delete" ) ,
174
173
MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
175
174
{
176
- _settings . CustomPluginHotkeys . Remove ( item ) ;
175
+ settings . CustomPluginHotkeys . Remove ( item ) ;
177
176
RemoveHotkey ( item . Hotkey ) ;
178
177
}
179
178
}
180
179
181
180
private void OnnEditCustomHotkeyClick ( object sender , RoutedEventArgs e )
182
181
{
183
- var item = _viewModel . SelectedCustomPluginHotkey ;
182
+ var item = viewModel . SelectedCustomPluginHotkey ;
184
183
if ( item != null )
185
184
{
186
- CustomQueryHotkeySetting window = new CustomQueryHotkeySetting ( this , _settings ) ;
185
+ CustomQueryHotkeySetting window = new CustomQueryHotkeySetting ( this , settings ) ;
187
186
window . UpdateItem ( item ) ;
188
187
window . ShowDialog ( ) ;
189
188
}
@@ -195,7 +194,7 @@ private void OnnEditCustomHotkeyClick(object sender, RoutedEventArgs e)
195
194
196
195
private void OnAddCustomeHotkeyClick ( object sender , RoutedEventArgs e )
197
196
{
198
- new CustomQueryHotkeySetting ( this , _settings ) . ShowDialog ( ) ;
197
+ new CustomQueryHotkeySetting ( this , settings ) . ShowDialog ( ) ;
199
198
}
200
199
201
200
#endregion
@@ -204,17 +203,17 @@ private void OnAddCustomeHotkeyClick(object sender, RoutedEventArgs e)
204
203
205
204
private void OnPluginToggled ( object sender , RoutedEventArgs e )
206
205
{
207
- var id = _viewModel . SelectedPlugin . PluginPair . Metadata . ID ;
206
+ var id = viewModel . SelectedPlugin . PluginPair . Metadata . ID ;
208
207
// used to sync the current status from the plugin manager into the setting to keep consistency after save
209
- _settings . PluginSettings . Plugins [ id ] . Disabled = _viewModel . SelectedPlugin . PluginPair . Metadata . Disabled ;
208
+ settings . PluginSettings . Plugins [ id ] . Disabled = viewModel . SelectedPlugin . PluginPair . Metadata . Disabled ;
210
209
}
211
210
212
211
private void OnPluginActionKeywordsClick ( object sender , MouseButtonEventArgs e )
213
212
{
214
213
if ( e . ChangedButton == MouseButton . Left )
215
214
{
216
- var id = _viewModel . SelectedPlugin . PluginPair . Metadata . ID ;
217
- ActionKeywords changeKeywordsWindow = new ActionKeywords ( id , _settings , _viewModel . SelectedPlugin ) ;
215
+ var id = viewModel . SelectedPlugin . PluginPair . Metadata . ID ;
216
+ ActionKeywords changeKeywordsWindow = new ActionKeywords ( id , settings , viewModel . SelectedPlugin ) ;
218
217
changeKeywordsWindow . ShowDialog ( ) ;
219
218
}
220
219
}
@@ -223,7 +222,7 @@ private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
223
222
{
224
223
if ( e . ChangedButton == MouseButton . Left )
225
224
{
226
- var website = _viewModel . SelectedPlugin . PluginPair . Metadata . Website ;
225
+ var website = viewModel . SelectedPlugin . PluginPair . Metadata . Website ;
227
226
if ( ! string . IsNullOrEmpty ( website ) )
228
227
{
229
228
var uri = new Uri ( website ) ;
@@ -239,7 +238,7 @@ private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e)
239
238
{
240
239
if ( e . ChangedButton == MouseButton . Left )
241
240
{
242
- var directory = _viewModel . SelectedPlugin . PluginPair . Metadata . PluginDirectory ;
241
+ var directory = viewModel . SelectedPlugin . PluginPair . Metadata . PluginDirectory ;
243
242
if ( ! string . IsNullOrEmpty ( directory ) )
244
243
FilesFolders . OpenPath ( directory ) ;
245
244
}
@@ -250,15 +249,15 @@ private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e)
250
249
251
250
private void OnTestProxyClick ( object sender , RoutedEventArgs e )
252
251
{ // TODO: change to command
253
- var msg = _viewModel . TestProxy ( ) ;
252
+ var msg = viewModel . TestProxy ( ) ;
254
253
MessageBox . Show ( msg ) ; // TODO: add message box service
255
254
}
256
255
257
256
#endregion
258
257
259
258
private async void OnCheckUpdates ( object sender , RoutedEventArgs e )
260
259
{
261
- _viewModel . UpdateApp ( ) ; // TODO: change to command
260
+ viewModel . UpdateApp ( ) ; // TODO: change to command
262
261
}
263
262
264
263
private void OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
@@ -269,7 +268,7 @@ private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
269
268
270
269
private void OnClosed ( object sender , EventArgs e )
271
270
{
272
- _viewModel . Save ( ) ;
271
+ viewModel . Save ( ) ;
273
272
}
274
273
275
274
private void OnCloseExecuted ( object sender , ExecutedRoutedEventArgs e )
0 commit comments