-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotifyIconViewModel.cs
43 lines (42 loc) · 1.07 KB
/
NotifyIconViewModel.cs
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
using System;
using System.Windows;
using System.Windows.Input;
namespace D2RoshTimer {
public class NotifyIconViewModel {
public ICommand ShowWindowCommand {
get {
return new DelegateCommand {
CommandAction = () => {
Application.Current.MainWindow.Show();
}
};
}
}
public ICommand HideWindowCommand {
get {
return new DelegateCommand {
CommandAction = () => Application.Current.MainWindow.Close(),
};
}
}
public ICommand ExitApplicationCommand {
get {
return new DelegateCommand {CommandAction = () => Application.Current.Shutdown()};
}
}
}
public class DelegateCommand : ICommand {
public Action CommandAction { get; set; }
public Func<bool> CanExecuteFunc { get; set; }
public void Execute(object parameter) {
CommandAction();
}
public bool CanExecute(object parameter) {
return CanExecuteFunc == null || CanExecuteFunc();
}
public event EventHandler CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
}
}