Skip to content

Commit a9364cb

Browse files
committed
Improve code quality
1 parent 5c1c6e9 commit a9364cb

File tree

7 files changed

+587
-613
lines changed

7 files changed

+587
-613
lines changed
Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Flow.Launcher.Plugin.Sys
3+
namespace Flow.Launcher.Plugin.Sys;
4+
5+
public class Command : BaseModel
46
{
5-
public class Command : BaseModel
6-
{
7-
public string Key { get; set; }
7+
public string Key { get; set; }
88

9-
private string name;
10-
[JsonIgnore]
11-
public string Name
9+
private string name;
10+
[JsonIgnore]
11+
public string Name
12+
{
13+
get => name;
14+
set
1215
{
13-
get => name;
14-
set
15-
{
16-
name = value;
17-
OnPropertyChanged();
18-
}
16+
name = value;
17+
OnPropertyChanged();
1918
}
19+
}
2020

21-
private string description;
22-
[JsonIgnore]
23-
public string Description
21+
private string description;
22+
[JsonIgnore]
23+
public string Description
24+
{
25+
get => description;
26+
set
2427
{
25-
get => description;
26-
set
27-
{
28-
description = value;
29-
OnPropertyChanged();
30-
}
28+
description = value;
29+
OnPropertyChanged();
3130
}
31+
}
3232

33-
private string keyword;
34-
public string Keyword
33+
private string keyword;
34+
public string Keyword
35+
{
36+
get => keyword;
37+
set
3538
{
36-
get => keyword;
37-
set
38-
{
39-
keyword = value;
40-
OnPropertyChanged();
41-
}
39+
keyword = value;
40+
OnPropertyChanged();
4241
}
4342
}
4443
}
Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
using System.Windows;
22

3-
namespace Flow.Launcher.Plugin.Sys
3+
namespace Flow.Launcher.Plugin.Sys;
4+
5+
public partial class CommandKeywordSettingWindow
46
{
5-
public partial class CommandKeywordSettingWindow
7+
private readonly Command _oldSearchSource;
8+
9+
public CommandKeywordSettingWindow(Command old)
610
{
7-
private readonly Command _oldSearchSource;
8-
private readonly PluginInitContext _context;
11+
_oldSearchSource = old;
12+
InitializeComponent();
13+
CommandKeyword.Text = old.Keyword;
14+
CommandKeywordTips.Text = string.Format(Main.Context.API.GetTranslation("flowlauncher_plugin_sys_custom_command_keyword_tip"), old.Name);
15+
}
916

10-
public CommandKeywordSettingWindow(PluginInitContext context, Command old)
11-
{
12-
_context = context;
13-
_oldSearchSource = old;
14-
InitializeComponent();
15-
CommandKeyword.Text = old.Keyword;
16-
CommandKeywordTips.Text = string.Format(_context.API.GetTranslation("flowlauncher_plugin_sys_custom_command_keyword_tip"), old.Name);
17-
}
17+
private void OnCancelButtonClick(object sender, RoutedEventArgs e)
18+
{
19+
Close();
20+
}
1821

19-
private void OnCancelButtonClick(object sender, RoutedEventArgs e)
22+
private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
23+
{
24+
var keyword = CommandKeyword.Text;
25+
if (string.IsNullOrEmpty(keyword))
2026
{
21-
Close();
27+
var warning = Main.Context.API.GetTranslation("flowlauncher_plugin_sys_input_command_keyword");
28+
Main.Context.API.ShowMsgBox(warning);
2229
}
23-
24-
private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
30+
else
2531
{
26-
var keyword = CommandKeyword.Text;
27-
if (string.IsNullOrEmpty(keyword))
28-
{
29-
var warning = _context.API.GetTranslation("flowlauncher_plugin_sys_input_command_keyword");
30-
_context.API.ShowMsgBox(warning);
31-
}
32-
else
33-
{
34-
_oldSearchSource.Keyword = keyword;
35-
Close();
36-
}
32+
_oldSearchSource.Keyword = keyword;
33+
Close();
3734
}
35+
}
3836

39-
private void OnResetButtonClick(object sender, RoutedEventArgs e)
40-
{
41-
// Key is the default value of this command
42-
CommandKeyword.Text = _oldSearchSource.Key;
43-
}
37+
private void OnResetButtonClick(object sender, RoutedEventArgs e)
38+
{
39+
// Key is the default value of this command
40+
CommandKeyword.Text = _oldSearchSource.Key;
4441
}
4542
}

0 commit comments

Comments
 (0)