private void openSettings() { var settingsView = new SettingsView(); var settingsVM = new SettingsVM(); foreach (var receiver in _detector.GetMailReceivers()) { settingsVM.Receivers.Add(new Receiver() { Name = receiver.Address }); } settingsVM.Interval = (int)_detector.GetUpdateInterval().TotalSeconds; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); settingsVM.ConfigurationPath = config.FilePath; settingsView.DataContext = settingsVM; if (settingsView.ShowDialog() == true) { _detector.ClearReceivers(); foreach (var receiver in settingsVM.Receivers) { try { _detector.AddMailReceiver(new System.Net.Mail.MailAddress(receiver.Name)); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } _detector.SetUpdateInterval(TimeSpan.FromSeconds(settingsVM.Interval)); }