Refactor with VS helper

master
Sean McArdle 2017-08-22 14:27:46 -07:00
parent de8d834372
commit 104163410d
2 changed files with 17 additions and 15 deletions

View File

@ -40,10 +40,11 @@ namespace WifiSitterGui.ViewModel
public MainWindowViewModel (IEventAggregator eventAggregator) {
_eventAggregator = eventAggregator;
_refreshProperties = new Timer();
_refreshProperties.Interval = 1000 * 5;
_refreshProperties.AutoReset = true;
_refreshProperties = new Timer() {
Interval = 1000 * 5,
AutoReset = true
};
_refreshProperties.Elapsed += (o, e) => {
this.OnPropertyChanged("ServiceState");
};
@ -135,10 +136,8 @@ namespace WifiSitterGui.ViewModel
public ICommand ReloadWhitelist {
get {
return (_reloadWhitelistCommand != null)
? _reloadWhitelistCommand
: _reloadWhitelistCommand = new RelayCommand(
() => { _eventAggregator?.GetEvent<ReloadWhitelistEvent>().Publish(); });
return _reloadWhitelistCommand ?? (_reloadWhitelistCommand = new RelayCommand(
() => { _eventAggregator?.GetEvent<ReloadWhitelistEvent>().Publish(); }));
}
}

View File

@ -65,9 +65,10 @@ namespace WifiSitterGui.ViewModel
RequestNetworkState();
// Intermittent network state polling
_netstateCheckTimer = new System.Timers.Timer();
_netstateCheckTimer.AutoReset = true;
_netstateCheckTimer.Interval = 30 * 1000; // 30 seconds
_netstateCheckTimer = new System.Timers.Timer() {
AutoReset = true,
Interval = 30 * 1000 // 30 seconds
};
_netstateCheckTimer.Elapsed += (o, e) => { RequestNetworkState(); };
_netstateCheckTimer.Start();
@ -180,8 +181,9 @@ namespace WifiSitterGui.ViewModel
}
if (_poller == null) {
_poller = new NetMQPoller();
_poller.Add(_mqClient);
_poller = new NetMQPoller {
_mqClient
};
}
if (!_poller.IsRunning) {
@ -209,8 +211,9 @@ namespace WifiSitterGui.ViewModel
if (_launchWindowCommand == null) {
_launchWindowCommand = new RelayCommand(() => {
if (_statusGui == null) {
_statusGui = new MainWindow();
_statusGui.DataContext = WindowVM;
_statusGui = new MainWindow() {
DataContext = WindowVM
};
_statusGui.Closed += (s, e) => { _statusGui = null; };
_statusGui.Show();
}