-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathApp.Commands.cs
More file actions
97 lines (83 loc) · 2.74 KB
/
App.Commands.cs
File metadata and controls
97 lines (83 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Windows.Input;
using Avalonia.Controls.ApplicationLifetimes;
namespace SourceGit
{
public partial class App
{
public class Command : ICommand
{
public event EventHandler CanExecuteChanged
{
add { }
remove { }
}
public Command(Action<object> action)
{
_action = action;
}
public bool CanExecute(object parameter) => _action != null;
public void Execute(object parameter) => _action?.Invoke(parameter);
private Action<object> _action = null;
}
public static bool IsCheckForUpdateCommandVisible
{
get
{
#if DISABLE_UPDATE_DETECTION
return false;
#else
return true;
#endif
}
}
public static readonly Command OpenPreferencesCommand = new Command(async _ =>
{
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
{
var dialog = new Views.Preferences();
await dialog.ShowDialog(owner);
}
});
public static readonly Command OpenHotkeysCommand = new Command(async _ =>
{
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
{
var dialog = new Views.Hotkeys();
await dialog.ShowDialog(owner);
}
});
public static readonly Command OpenAppDataDirCommand = new Command(_ =>
{
Native.OS.OpenInFileManager(Native.OS.DataDir);
});
public static readonly Command OpenAboutCommand = new Command(async _ =>
{
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
{
var dialog = new Views.About();
await dialog.ShowDialog(owner);
}
});
public static readonly Command CheckForUpdateCommand = new Command(_ =>
{
(Current as App)?.Check4Update(true);
});
public static readonly Command QuitCommand = new Command(_ =>
{
Quit(0);
});
public static readonly Command HideAppCommand = new Command(_ =>
{
Native.OS.HideSelf();
});
public static readonly Command HideOtherApplicationsCommand = new Command(_ =>
{
Native.OS.HideOtherApplications();
});
public static readonly Command ShowAllApplicationsCommand = new Command(_ =>
{
Native.OS.ShowAllApplications();
});
}
}