using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml; namespace EduNetworkBuilder { public partial class FirewallEditor : Form { NetworkDevice FirewallDevice = null; public FirewallEditor(NetworkDevice WhatToEdit) { InitializeComponent(); FirewallDevice = WhatToEdit; UpdateForm(); Icon = Properties.Resources.NBIco; } void UpdateForm() { if (lbRules.SelectedIndex > 0) btnDel.Visible = true; else btnDel.Visible = false; int selected = lbRules.SelectedIndex; lbRules.Items.Clear(); foreach (FirewallRule FW in FirewallDevice.FirewallRules) { string OneLine = FW.Action.ToString() + " " + FW.Source + " -> " + FW.Destination; lbRules.Items.Add(OneLine); } if (selected >= 0 && selected < lbRules.Items.Count) lbRules.SelectedIndex = selected; else { if (lbRules.Items.Count > 0) lbRules.SelectedIndex = 0; } } private void btnNew_Click(object sender, EventArgs e) { FirewallRule FW = new FirewallRule("","",FirewallRuleType.Drop); NetTestEditor NTE = new NetTestEditor(FW,FirewallDevice); NTE.ShowDialog(); if(FW.Source!="" && FW.Destination != "") { FirewallDevice.FirewallRules.Add(FW); } UpdateForm(); } private void btnDel_Click(object sender, EventArgs e) { } private void btnDone_Click(object sender, EventArgs e) { Close(); } } }