mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
code_style: simplify static commands used by styles and main menu; run dotnet format
This commit is contained in:
parent
e27d2d6a3f
commit
998230edff
10 changed files with 35 additions and 52 deletions
|
@ -6,7 +6,7 @@ namespace SourceGit
|
|||
{
|
||||
public partial class App
|
||||
{
|
||||
public class SimpleCommand : ICommand
|
||||
public class Command : ICommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
|
@ -14,26 +14,7 @@ namespace SourceGit
|
|||
remove { }
|
||||
}
|
||||
|
||||
public SimpleCommand(Action action)
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter) => _action != null;
|
||||
public void Execute(object parameter) => _action?.Invoke();
|
||||
|
||||
private Action _action = null;
|
||||
}
|
||||
|
||||
public class ParameterCommand : ICommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public ParameterCommand(Action<object> action)
|
||||
public Command(Action<object> action)
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
@ -44,22 +25,12 @@ namespace SourceGit
|
|||
private Action<object> _action = null;
|
||||
}
|
||||
|
||||
public static readonly SimpleCommand OpenPreferenceCommand = new SimpleCommand(() => OpenDialog(new Views.Preference()));
|
||||
public static readonly SimpleCommand OpenHotkeysCommand = new SimpleCommand(() => OpenDialog(new Views.Hotkeys()));
|
||||
public static readonly SimpleCommand OpenAppDataDirCommand = new SimpleCommand(() => Native.OS.OpenInFileManager(Native.OS.DataDir));
|
||||
public static readonly SimpleCommand OpenAboutCommand = new SimpleCommand(() => OpenDialog(new Views.About()));
|
||||
public static readonly SimpleCommand CheckForUpdateCommand = new SimpleCommand(() => Check4Update(true));
|
||||
public static readonly SimpleCommand QuitCommand = new SimpleCommand(() => Quit(0));
|
||||
|
||||
public static readonly ParameterCommand CopyTextCommand = new ParameterCommand(param =>
|
||||
{
|
||||
if (param is TextBlock textBlock)
|
||||
{
|
||||
if (textBlock.Inlines is { Count: > 0 } inlines)
|
||||
CopyText(inlines.Text);
|
||||
else
|
||||
CopyText(textBlock.Text);
|
||||
}
|
||||
});
|
||||
public static readonly Command OpenPreferenceCommand = new Command(_ => OpenDialog(new Views.Preference()));
|
||||
public static readonly Command OpenHotkeysCommand = new Command(_ => OpenDialog(new Views.Hotkeys()));
|
||||
public static readonly Command OpenAppDataDirCommand = new Command(_ => Native.OS.OpenInFileManager(Native.OS.DataDir));
|
||||
public static readonly Command OpenAboutCommand = new Command(_ => OpenDialog(new Views.About()));
|
||||
public static readonly Command CheckForUpdateCommand = new Command(_ => Check4Update(true));
|
||||
public static readonly Command QuitCommand = new Command(_ => Quit(0));
|
||||
public static readonly Command CopyTextBlockCommand = new Command(p => CopyTextBlock(p as TextBlock));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue