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.btnDHCP = new System.Windows.Forms.Button();
this.btnVLAN = new System.Windows.Forms.Button(); this.btnVLAN = new System.Windows.Forms.Button();
this.btnFirewall = new System.Windows.Forms.Button(); this.btnFirewall = new System.Windows.Forms.Button();
this.cbFirewall = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// tbHostname // tbHostname
@ -210,7 +211,7 @@
// cbDHCP // cbDHCP
// //
this.cbDHCP.AutoSize = true; 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.Name = "cbDHCP";
this.cbDHCP.Size = new System.Drawing.Size(114, 21); this.cbDHCP.Size = new System.Drawing.Size(114, 21);
this.cbDHCP.TabIndex = 18; this.cbDHCP.TabIndex = 18;
@ -248,6 +249,17 @@
this.btnFirewall.UseVisualStyleBackColor = true; this.btnFirewall.UseVisualStyleBackColor = true;
this.btnFirewall.Click += new System.EventHandler(this.btnFirewall_Click); 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 // DeviceConfig
// //
this.AcceptButton = this.btnOK; this.AcceptButton = this.btnOK;
@ -255,6 +267,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel; this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(471, 365); this.ClientSize = new System.Drawing.Size(471, 365);
this.Controls.Add(this.cbFirewall);
this.Controls.Add(this.btnFirewall); this.Controls.Add(this.btnFirewall);
this.Controls.Add(this.btnVLAN); this.Controls.Add(this.btnVLAN);
this.Controls.Add(this.btnDHCP); this.Controls.Add(this.btnDHCP);
@ -305,5 +318,6 @@
private System.Windows.Forms.Button btnDHCP; private System.Windows.Forms.Button btnDHCP;
private System.Windows.Forms.Button btnVLAN; private System.Windows.Forms.Button btnVLAN;
private System.Windows.Forms.Button btnFirewall; private System.Windows.Forms.Button btnFirewall;
private System.Windows.Forms.CheckBox cbFirewall;
} }
} }

View File

@ -96,7 +96,7 @@ namespace EduNetworkBuilder
nicLocked = true; nicLocked = true;
interfacesLocked = true; interfacesLocked = true;
} }
if (theNet.FirewallEnabled && ndCLonedItem.DoesFirewall()) if (ndCLonedItem.HasAdvFirewall && ndCLonedItem.DoesFirewall())
btnFirewall.Visible = true; btnFirewall.Visible = true;
else else
btnFirewall.Visible = false; btnFirewall.Visible = false;
@ -527,5 +527,15 @@ namespace EduNetworkBuilder
FEditor.ShowDialog(); 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 ShowLabelsHere = false;
public bool VLANsEnabled = false; public bool VLANsEnabled = false;
public bool VLANPacketColors = false; public bool VLANPacketColors = false;
public bool FirewallEnabled = false;
public LanguageStrings NetMessage; public LanguageStrings NetMessage;
public LanguageStrings NetTitle; public LanguageStrings NetTitle;
List<NetworkComponent> NetComponents = new List<NetworkComponent>(); List<NetworkComponent> NetComponents = new List<NetworkComponent>();
@ -138,9 +137,6 @@ namespace EduNetworkBuilder
case "vlansenabled": case "vlansenabled":
bool.TryParse(Individual.InnerText, out VLANsEnabled); bool.TryParse(Individual.InnerText, out VLANsEnabled);
break; break;
case "firewallenabled":
bool.TryParse(Individual.InnerText, out FirewallEnabled);
break;
case "vlanpacketcolors": case "vlanpacketcolors":
bool.TryParse(Individual.InnerText, out VLANPacketColors); bool.TryParse(Individual.InnerText, out VLANPacketColors);
if (VLANPacketColors) if (VLANPacketColors)
@ -292,7 +288,6 @@ namespace EduNetworkBuilder
writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString()); writer.WriteElementString("uniqueidentifier", UniqueIdentifier.ToString());
writer.WriteElementString("startinghelplevel", StartingHelpLevel.ToString()); writer.WriteElementString("startinghelplevel", StartingHelpLevel.ToString());
writer.WriteElementString("vlansenabled", VLANsEnabled.ToString()); writer.WriteElementString("vlansenabled", VLANsEnabled.ToString());
writer.WriteElementString("firewallenabled", FirewallEnabled.ToString());
writer.WriteElementString("VLANPacketColors", VLANPacketColors.ToString()); writer.WriteElementString("VLANPacketColors", VLANPacketColors.ToString());
//Save all the devices //Save all the devices
for (int loop = 0; loop < NetComponents.Count; loop++) for (int loop = 0; loop < NetComponents.Count; loop++)

View File

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

View File

@ -51,7 +51,6 @@
this.lblStartingHelp = new System.Windows.Forms.Label(); this.lblStartingHelp = new System.Windows.Forms.Label();
this.cbVLANs = new System.Windows.Forms.CheckBox(); this.cbVLANs = new System.Windows.Forms.CheckBox();
this.cb_ColoredPackets = new System.Windows.Forms.CheckBox(); this.cb_ColoredPackets = new System.Windows.Forms.CheckBox();
this.cbFirewallEnabled = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnDone // btnDone
@ -259,24 +258,12 @@
this.cb_ColoredPackets.Text = "VLAN Colored Packets"; this.cb_ColoredPackets.Text = "VLAN Colored Packets";
this.cb_ColoredPackets.UseVisualStyleBackColor = true; 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 // OptionsWindow
// //
this.AcceptButton = this.btnDone; this.AcceptButton = this.btnDone;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(836, 307); this.ClientSize = new System.Drawing.Size(836, 307);
this.Controls.Add(this.cbFirewallEnabled);
this.Controls.Add(this.cb_ColoredPackets); this.Controls.Add(this.cb_ColoredPackets);
this.Controls.Add(this.cbVLANs); this.Controls.Add(this.cbVLANs);
this.Controls.Add(this.lblStartingHelp); this.Controls.Add(this.lblStartingHelp);
@ -332,6 +319,5 @@
private System.Windows.Forms.Label lblStartingHelp; private System.Windows.Forms.Label lblStartingHelp;
private System.Windows.Forms.CheckBox cbVLANs; private System.Windows.Forms.CheckBox cbVLANs;
private System.Windows.Forms.CheckBox cb_ColoredPackets; 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"); lblStartingHelp.Text = NB.Translate("OW_lblStartingHelp");
cbVLANs.Text = NB.Translate("OW_cbVLANs"); cbVLANs.Text = NB.Translate("OW_cbVLANs");
cb_ColoredPackets.Text = NB.Translate("OW_OWVLANColoredPackets"); cb_ColoredPackets.Text = NB.Translate("OW_OWVLANColoredPackets");
cbFirewallEnabled.Text = NB.Translate("OW_cbFirewallEnabled");
Text = NB.Translate("OW_Form"); Text = NB.Translate("OW_Form");
} }
@ -77,7 +76,6 @@ namespace EduNetworkBuilder
tbNetworkTitle.Text = myNet.NetTitle.GetText(); tbNetworkTitle.Text = myNet.NetTitle.GetText();
cbDisplayTitles.Checked = myNet.OptionShowLabels; cbDisplayTitles.Checked = myNet.OptionShowLabels;
cbVLANs.Checked = myNet.VLANsEnabled; cbVLANs.Checked = myNet.VLANsEnabled;
cbFirewallEnabled.Checked = myNet.FirewallEnabled;
cb_ColoredPackets.Checked = myNet.VLANPacketColors; cb_ColoredPackets.Checked = myNet.VLANPacketColors;
tbNetworkX.Text = myNet.myWidth.ToString(); tbNetworkX.Text = myNet.myWidth.ToString();
tbNetworkY.Text = myNet.myHeight.ToString(); tbNetworkY.Text = myNet.myHeight.ToString();
@ -117,7 +115,6 @@ namespace EduNetworkBuilder
myNet.OptionShowLabels = cbDisplayTitles.Checked; myNet.OptionShowLabels = cbDisplayTitles.Checked;
myNet.VLANsEnabled = cbVLANs.Checked; myNet.VLANsEnabled = cbVLANs.Checked;
myNet.VLANPacketColors = cb_ColoredPackets.Checked; myNet.VLANPacketColors = cb_ColoredPackets.Checked;
myNet.FirewallEnabled = cbFirewallEnabled.Checked;
myNet.ShowLabelsHere = myNet.OptionShowLabels; myNet.ShowLabelsHere = myNet.OptionShowLabels;
int.TryParse(tbNetworkX.Text, out myNet.myWidth); int.TryParse(tbNetworkX.Text, out myNet.myWidth);
int.TryParse(tbNetworkY.Text, out myNet.myHeight); int.TryParse(tbNetworkY.Text, out myNet.myHeight);