1111using NETworkManager . Models . Settings ;
1212using System . Windows . Threading ;
1313using System . Linq ;
14+ using System . Windows ;
15+ using MahApps . Metro . Controls ;
1416using NETworkManager . Models . Export ;
1517
1618namespace NETworkManager . ViewModels
@@ -224,7 +226,12 @@ private void LoadSettings()
224226 #region ICommands & Actions
225227 public ICommand RefreshCommand
226228 {
227- get { return new RelayCommand ( p => RefreshAction ( ) ) ; }
229+ get { return new RelayCommand ( p => RefreshAction ( ) , Refresh_CanExecute ) ; }
230+ }
231+
232+ private bool Refresh_CanExecute ( object paramter )
233+ {
234+ return Application . Current . MainWindow != null && ! ( ( MetroWindow ) Application . Current . MainWindow ) . IsAnyDialogOpen ;
228235 }
229236
230237 private void RefreshAction ( )
@@ -236,7 +243,12 @@ private void RefreshAction()
236243
237244 public ICommand DeleteTableCommand
238245 {
239- get { return new RelayCommand ( p => DeleteTableAction ( ) ) ; }
246+ get { return new RelayCommand ( p => DeleteTableAction ( ) , DeleteTable_CanExecute ) ; }
247+ }
248+
249+ private bool DeleteTable_CanExecute ( object paramter )
250+ {
251+ return Application . Current . MainWindow != null && ! ( ( MetroWindow ) Application . Current . MainWindow ) . IsAnyDialogOpen ;
240252 }
241253
242254 private async void DeleteTableAction ( )
@@ -262,7 +274,12 @@ private async void DeleteTableAction()
262274
263275 public ICommand DeleteEntryCommand
264276 {
265- get { return new RelayCommand ( p => DeleteEntryAction ( ) ) ; }
277+ get { return new RelayCommand ( p => DeleteEntryAction ( ) , DeleteEntry_CanExecute ) ; }
278+ }
279+
280+ private bool DeleteEntry_CanExecute ( object paramter )
281+ {
282+ return Application . Current . MainWindow != null && ! ( ( MetroWindow ) Application . Current . MainWindow ) . IsAnyDialogOpen ;
266283 }
267284
268285 private async void DeleteEntryAction ( )
@@ -288,7 +305,12 @@ private async void DeleteEntryAction()
288305
289306 public ICommand AddEntryCommand
290307 {
291- get { return new RelayCommand ( p => AddEntryAction ( ) ) ; }
308+ get { return new RelayCommand ( p => AddEntryAction ( ) , AddEntry_CanExecute ) ; }
309+ }
310+
311+ private bool AddEntry_CanExecute ( object paramter )
312+ {
313+ return Application . Current . MainWindow != null && ! ( ( MetroWindow ) Application . Current . MainWindow ) . IsAnyDialogOpen ;
292314 }
293315
294316 private async void AddEntryAction ( )
0 commit comments