private void ConfigureServerButtonClick(object sender, EventArgs e) { if (serversListBox.SelectedItem != null) { var server = serversListBox.SelectedItem as Server; if (server == null) { return; } var addServerWindow = new AddServerWindow( new ServerViewModel { Id = server.Id, ServerAddress = new Uri(server.Address), FriendlyName = server.Name, Username = server.Username, Password = server.PlaintextPassword }); addServerWindow.ShowDialog(this); if (addServerWindow.DialogResult == DialogResult.OK) { var newServerDetails = GetServerFromViewModel(addServerWindow.Model); var oldServerDetails = _settingsService.TraySettings.Servers.FirstOrDefault(x => x.Id == newServerDetails.Id); UpdateServerModel(oldServerDetails, newServerDetails); _settingsService.SaveTraySettings(); serversListBox.DataSource = null; serversListBox.DisplayMember = "Name"; serversListBox.DataSource = _settingsService.TraySettings.Servers; } } }
private void AddServerButtonClick(object sender, EventArgs e) { var addServerWindow = new AddServerWindow(); addServerWindow.ShowDialog(this); if (addServerWindow.DialogResult == DialogResult.OK) { var server = GetServerFromViewModel(addServerWindow.Model); _settingsService.TraySettings.Servers.Add(server); _settingsService.SaveTraySettings(); serversListBox.DataSource = _settingsService.TraySettings.Servers; } }