Move firewall checkmark to device

This commit is contained in:
Tim Young 2016-11-12 07:42:42 -07:00
parent 721efb7fe3
commit 4068f49f5a
6 changed files with 43 additions and 28 deletions

View File

@ -48,6 +48,7 @@
this.btnDHCP = new System.Windows.Forms.Button();
this.btnVLAN = new System.Windows.Forms.Button();
this.btnFirewall = new System.Windows.Forms.Button();
this.cbFirewall = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// tbHostname
@ -210,7 +211,7 @@
// cbDHCP
//
this.cbDHCP.AutoSize = true;
this.cbDHCP.Location = new System.Drawing.Point(13, 35);
this.cbDHCP.Location = new System.Drawing.Point(15, 34);
this.cbDHCP.Name = "cbDHCP";
this.cbDHCP.Size = new System.Drawing.Size(114, 21);
this.cbDHCP.TabIndex = 18;
@ -248,6 +249,17 @@
this.btnFirewall.UseVisualStyleBackColor = true;
this.btnFirewall.Click += new System.EventHandler(this.btnFirewall_Click);
//
// cbFirewall
//
this.cbFirewall.AutoSize = true;
this.cbFirewall.Location = new System.Drawing.Point(15, 56);
this.cbFirewall.Name = "cbFirewall";
this.cbFirewall.Size = new System.Drawing.Size(77, 21);
this.cbFirewall.TabIndex = 23;
this.cbFirewall.Text = "Firewall";
this.cbFirewall.UseVisualStyleBackColor = true;
this.cbFirewall.CheckedChanged += new System.EventHandler(this.cbFirewall_CheckedChanged);
//
// DeviceConfig
//
this.AcceptButton = this.btnOK;
@ -255,6 +267,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(471, 365);
this.Controls.Add(this.cbFirewall);
this.Controls.Add(this.btnFirewall);
this.Controls.Add(this.btnVLAN);
this.Controls.Add(this.btnDHCP);
@ -305,5 +318,6 @@
private System.Windows.Forms.Button btnDHCP;
private System.Windows.Forms.Button btnVLAN;
private System.Windows.Forms.Button btnFirewall;
private System.Windows.Forms.CheckBox cbFirewall;
}
}

View File

@ -96,7 +96,7 @@ namespace EduNetworkBuilder
nicLocked = true;
interfacesLocked = true;
}
if (theNet.FirewallEnabled && ndCLonedItem.DoesFirewall())
if (ndCLonedItem.HasAdvFirewall && ndCLonedItem.DoesFirewall())
btnFirewall.Visible = true;
else
btnFirewall.Visible = false;
@ -527,5 +527,15 @@ namespace EduNetworkBuilder
FEditor.ShowDialog();
}
}
private void cbFirewall_CheckedChanged(object sender, EventArgs e)
{
if (NB.GetComponentType(ClonedItem) == GeneralComponentType.device)
{
NetworkDevice ndClonedItem = (NetworkDevice)ClonedItem;
ndClonedItem.SetAdvFirewall(cbFirewall.Checked);
}
UpdateForm();
}
}
}

View File

@ -28,7 +28,6 @@ namespace EduNetworkBuilder
public bool ShowLabelsHere = false;
public bool VLANsEnabled = false;
public bool VLANPacketColors = false;
public bool FirewallEnabled = false;
public LanguageStrings NetMessage;
public LanguageStrings NetTitle;
List<NetworkComponent> NetComponents = new List<NetworkComponent>();
@ -138,9 +137,6 @@ namespace EduNetworkBuilder
case "vlansenabled":
bool.TryParse(Individual.InnerText, out VLANsEnabled);
break;
case "firewallenabled":
bool.TryParse(Individual.InnerText, out FirewallEnabled);
break;
case "vlanpacketcolors":
bool.TryParse(Individual.InnerText, out VLANPacketColors);
if (VLANPacketColors)
@ -292,7 +288,6 @@ namespace EduNetworkBuilder
writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString());
writer.WriteElementString("startinghelplevel", StartingHelpLevel.ToString());
writer.WriteElementString("vlansenabled", VLANsEnabled.ToString());
writer.WriteElementString("firewallenabled", FirewallEnabled.ToString());
writer.WriteElementString("VLANPacketColors", VLANPacketColors.ToString());
//Save all the devices
for (int loop = 0; loop < NetComponents.Count; loop++)

View File

@ -31,6 +31,7 @@ namespace EduNetworkBuilder
public bool CanUseDHCP = false;
public bool MustUseDHCP = false;
public bool CanAddNics = false;
public bool HasAdvFirewall = false;
public Color BackgroundColor = Color.Empty;
protected Color MorphColor = Color.Empty;
public List<FirewallRule> FirewallRules = new List<FirewallRule>();
@ -373,6 +374,9 @@ namespace EduNetworkBuilder
IPAddress dhcpip = new IPAddress(Individual);
DHCPRanges.Add(dhcpip);
break;
case "hasadvfirewall":
bool.TryParse(Individual.InnerText, out HasAdvFirewall);
break;
case "firwallrule":
FirewallRule fwr = new FirewallRule(Individual);
FirewallRules.Add(fwr);
@ -396,7 +400,9 @@ namespace EduNetworkBuilder
writer.WriteElementString("mytype", myType.ToString());
writer.WriteElementString("isdns", isDNSServer.ToString());
writer.WriteElementString("isdhcp", isDHCPServer.ToString());
if(MorphColor != Color.Empty)
if(HasAdvFirewall)
writer.WriteElementString("hasadvfirewall", HasAdvFirewall.ToString());
if (MorphColor != Color.Empty)
writer.WriteElementString("morphcolor", MorphColor.Name);
DefaultGW.Save(writer, "gateway");
foreach (NetworkCard nic in NICs)
@ -411,11 +417,13 @@ namespace EduNetworkBuilder
{
dhcp.Save(writer, "dhcprange");
}
foreach (FirewallRule fwr in FirewallRules)
if (HasAdvFirewall)
{
fwr.Save(writer, "firwallrule");
foreach (FirewallRule fwr in FirewallRules)
{
fwr.Save(writer, "firwallrule");
}
}
writer.WriteEndElement();
}
@ -428,6 +436,11 @@ namespace EduNetworkBuilder
return isDNSServer;
}
public void SetAdvFirewall(bool AdvFirewall)
{
HasAdvFirewall = AdvFirewall;
}
public void SetDHCPServer(bool isDHCP)
{
isDHCPServer = isDHCP;

View File

@ -51,7 +51,6 @@
this.lblStartingHelp = new System.Windows.Forms.Label();
this.cbVLANs = new System.Windows.Forms.CheckBox();
this.cb_ColoredPackets = new System.Windows.Forms.CheckBox();
this.cbFirewallEnabled = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// btnDone
@ -259,24 +258,12 @@
this.cb_ColoredPackets.Text = "VLAN Colored Packets";
this.cb_ColoredPackets.UseVisualStyleBackColor = true;
//
// cbFirewallEnabled
//
this.cbFirewallEnabled.AutoSize = true;
this.cbFirewallEnabled.Location = new System.Drawing.Point(518, 276);
this.cbFirewallEnabled.Name = "cbFirewallEnabled";
this.cbFirewallEnabled.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cbFirewallEnabled.Size = new System.Drawing.Size(165, 21);
this.cbFirewallEnabled.TabIndex = 23;
this.cbFirewallEnabled.Text = "Adv. Firewall Enabled";
this.cbFirewallEnabled.UseVisualStyleBackColor = true;
//
// OptionsWindow
//
this.AcceptButton = this.btnDone;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(836, 307);
this.Controls.Add(this.cbFirewallEnabled);
this.Controls.Add(this.cb_ColoredPackets);
this.Controls.Add(this.cbVLANs);
this.Controls.Add(this.lblStartingHelp);
@ -332,6 +319,5 @@
private System.Windows.Forms.Label lblStartingHelp;
private System.Windows.Forms.CheckBox cbVLANs;
private System.Windows.Forms.CheckBox cb_ColoredPackets;
private System.Windows.Forms.CheckBox cbFirewallEnabled;
}
}

View File

@ -65,7 +65,6 @@ namespace EduNetworkBuilder
lblStartingHelp.Text = NB.Translate("OW_lblStartingHelp");
cbVLANs.Text = NB.Translate("OW_cbVLANs");
cb_ColoredPackets.Text = NB.Translate("OW_OWVLANColoredPackets");
cbFirewallEnabled.Text = NB.Translate("OW_cbFirewallEnabled");
Text = NB.Translate("OW_Form");
}
@ -77,7 +76,6 @@ namespace EduNetworkBuilder
tbNetworkTitle.Text = myNet.NetTitle.GetText();
cbDisplayTitles.Checked = myNet.OptionShowLabels;
cbVLANs.Checked = myNet.VLANsEnabled;
cbFirewallEnabled.Checked = myNet.FirewallEnabled;
cb_ColoredPackets.Checked = myNet.VLANPacketColors;
tbNetworkX.Text = myNet.myWidth.ToString();
tbNetworkY.Text = myNet.myHeight.ToString();
@ -117,7 +115,6 @@ namespace EduNetworkBuilder
myNet.OptionShowLabels = cbDisplayTitles.Checked;
myNet.VLANsEnabled = cbVLANs.Checked;
myNet.VLANPacketColors = cb_ColoredPackets.Checked;
myNet.FirewallEnabled = cbFirewallEnabled.Checked;
myNet.ShowLabelsHere = myNet.OptionShowLabels;
int.TryParse(tbNetworkX.Text, out myNet.myWidth);
int.TryParse(tbNetworkY.Text, out myNet.myHeight);