private void setDictionary(ArrayList arr) { list.Clear(); titleList.Clear(); patternList.Clear(); foreach(string temp in arr) { if (string.IsNullOrEmpty(temp)) break; if (temp.Trim().IndexOf(Util.DELIMITER_INFO) == 0) { titleList.Add(temp.Trim()); continue; } HostItem it = new HostItem(temp.Trim().Split(',')); if (it.error == 0) { list[it.Before] = it; if (it.isPattern()) { patternList[it.Before] = it.After; } } } }
public int setHost(HostItem it) { int ret = 0; if (list.ContainsKey(it.Before)) { ret = 1; } list[it.Before] = it; if (it.isPattern()) { patternList[it.Before] = it.After; } return ret; }
void BtnEditClick(object sender, System.EventArgs e) { listView1.Focus(); PolicyForm dialog = new PolicyForm(); HostItem hostitem = new HostItem(); if (listView1.SelectedItems.Count > 0) { foreach (ListViewItem item in listView1.SelectedItems) { string key = item.SubItems[1].Text; hostitem = PLink.host.getHostItem(key); break; } } dialog.Modify = true; if (hostitem.type == 0) { MessageBox.Show("Check Host!", "Alert"); return ; } dialog.SetHostItem(hostitem); if (dialog.ShowDialog(this) == DialogResult.OK) { PLink.host.removeHost(hostitem.Before); PLink.host.setHost(new HostItem(hostitem.Checked, dialog.TypeNo, dialog.Pattern, dialog.Change, dialog.Description)); dialog.Init(); reloadListView(); } }
void BtnPlusPolicyClick(object sender, EventArgs e) { listView1.Focus(); PolicyForm dialog = new PolicyForm(); HostItem hostitem = new HostItem(); if (listView1.SelectedItems.Count > 0) { foreach (ListViewItem item in listView1.SelectedItems) { string key = item.SubItems[1].Text; hostitem = PLink.host.getHostItem(key); break; } } dialog.SetHostItem(hostitem); if (dialog.ShowDialog(this) == DialogResult.OK) { HostItem it = PLink.host.getHostItem(dialog.Pattern); if (it.type == 0) { PLink.host.setHost(new HostItem(true, dialog.TypeNo, dialog.Pattern, dialog.Change, dialog.Description)); dialog.Init(); reloadListView(); } else { MessageBox.Show("Already same host exists : " + dialog.Pattern, "Error"); } } }
public void SetHostItem(HostItem item) { if (item.type > 0) { TypeNo = item.type - 1; Pattern = item.Before; Change = item.After; Description = item.Message; } }