-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystemBarViewModel.cs
146 lines (135 loc) · 4.27 KB
/
SystemBarViewModel.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace Worksly
{
class SystemBarViewModel
{
/// <summary>
/// Shows a window, if none is already open.
/// </summary>
public ICommand ShowWindowCommand
{
get
{
return new DelegateCommand
{
//CanExecuteFunc = () => Application.Current.MainWindow == null,
CommandAction = () =>
{
//Application.Current.MainWindow = new MainWindow();
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Activate();
}
};
}
}
//public ICommand CheckForUpdateCommand
//{
// get
// {
// return new DelegateCommand
// {
// //CanExecuteFunc = () => Application.Current.MainWindow == null,
// CommandAction = () =>
// {
// //Application.Current.MainWindow = new MainWindow();
// HelperTags.InstallUpdateSyncWithInfo();
// }
// };
// }
//}
/// <summary>
/// Hides the main window. This command is only enabled if a window is open.
/// </summary>
public ICommand HideWindowCommand
{
get
{
return new DelegateCommand
{
CommandAction = () => Application.Current.MainWindow.Hide(),
CanExecuteFunc = () => Application.Current.MainWindow != null
};
}
}
/// <summary>
/// Hides the main window if open and opens the EOD window
/// </summary>
public ICommand EODWindowCommand
{
get
{
return new DelegateCommand
{
CommandAction = () =>
{
if (Application.Current.Windows.OfType<EODWindow>().Any()) { return; }
if (Application.Current.MainWindow != null) { Application.Current.MainWindow.Hide(); }
EODWindow window1 = new EODWindow();
window1.Show();
}
};
}
}
/// <summary>
/// Open settings menu
/// </summary>
public ICommand SettingsWindow
{
get
{
return new DelegateCommand
{
CommandAction = () =>
{
Settings window1;
if (Application.Current.Windows.OfType<Settings>().Any())
{
window1 = Application.Current.Windows.OfType<Settings>().First();
window1.Show();
window1.Activate();
}
window1 = new Settings();
window1.Show();
}
};
}
}
/// <summary>
/// Shuts down the application.
/// </summary>
public ICommand ExitApplicationCommand
{
get
{
return new DelegateCommand { CommandAction = () => Application.Current.Shutdown() };
}
}
}
/// <summary>
/// Simplistic delegate command for the demo.
/// </summary>
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; }
}
}
}