void btnAdd_Click(object sender, EventArgs e) { ServerInfoForm form = new ServerInfoForm(); if (form.ShowDialog() != DialogResult.OK) { return; } ListViewItem item = CreateListViewItem(form.ServerInfo); listView.Items.Add(item); Global.SystemConfig.ServerList[form.ServerInfo.Name] = form.ServerInfo; SaveConfig(); }
void btnEdit_Click(object sender, EventArgs e) { if (listView.FocusedItem == null) { return; } ListViewItem focusedItem = listView.FocusedItem; ServerInfo serverInfo = (ServerInfo)focusedItem.Tag; ServerInfoForm form = new ServerInfoForm(serverInfo); if (form.ShowDialog() != DialogResult.OK) { return; } UpdateListViewItem(form.ServerInfo, focusedItem); Global.SystemConfig.ServerList[form.ServerInfo.Name] = form.ServerInfo; SaveConfig(); }