Colored packets, and some bugs that caused things to crash adding vlans

This commit is contained in:
Tim Young 2016-10-31 11:57:25 -05:00
parent b6eaf00d6d
commit a82db7ecb2
8 changed files with 186 additions and 15 deletions

View File

@ -27,6 +27,7 @@ namespace EduNetworkBuilder
public bool OptionShowLabels = false; public bool OptionShowLabels = false;
public bool ShowLabelsHere = false; public bool ShowLabelsHere = false;
public bool VLANsEnabled = false; public bool VLANsEnabled = false;
public bool VLANPacketColors = 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>();
@ -136,6 +137,11 @@ namespace EduNetworkBuilder
case "vlansenabled": case "vlansenabled":
bool.TryParse(Individual.InnerText, out VLANsEnabled); bool.TryParse(Individual.InnerText, out VLANsEnabled);
break; break;
case "vlanpacketcolors":
bool.TryParse(Individual.InnerText, out VLANPacketColors);
if (VLANPacketColors)
VLANsEnabled = true; //If we do colors, we need to do vlans
break;
case "itemsize": case "itemsize":
int.TryParse(Individual.InnerText, out itemsize); int.TryParse(Individual.InnerText, out itemsize);
break; break;
@ -282,6 +288,7 @@ 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("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++)
{ {
@ -1441,6 +1448,7 @@ namespace EduNetworkBuilder
public Color ColorFromPacketVLAN(int id) public Color ColorFromPacketVLAN(int id)
{ {
if (!VLANPacketColors) return Color.Blue; //If we are not set up to do vlan colors.
foreach(VLANName VN in VlanNames) foreach(VLANName VN in VlanNames)
{ {
if (VN.ID == id) if (VN.ID == id)

View File

@ -39,10 +39,10 @@ namespace EduNetworkBuilder
{ {
myNicType = theType; myNicType = theType;
_nic_name = myNicType.ToString() + index.ToString(); _nic_name = myNicType.ToString() + index.ToString();
myID = new HostNicID(HostID, UniqueIdentifier, hostname, _nic_name);
NetworkInterface nInterface = new NetworkInterface(NicName(), NB.ZeroIPString, NB.ZeroIPString, myID); NetworkInterface nInterface = new NetworkInterface(NicName(), NB.ZeroIPString, NB.ZeroIPString, myID);
if(theType == NicType.lo) if(theType == NicType.lo)
nInterface = new NetworkInterface(NicName(), "127.0.0.1", "255.0.0.0", myID); nInterface = new NetworkInterface(NicName(), "127.0.0.1", "255.0.0.0", myID);
myID = new HostNicID(HostID, UniqueIdentifier,hostname,nInterface.nic_name);
interfaces.Add(nInterface); interfaces.Add(nInterface);
ApplyNicRules(); ApplyNicRules();
SetIPForDHCP(); SetIPForDHCP();

View File

@ -50,6 +50,7 @@
this.cbStartingHelpLevel = new System.Windows.Forms.ComboBox(); this.cbStartingHelpLevel = new System.Windows.Forms.ComboBox();
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.SuspendLayout(); this.SuspendLayout();
// //
// btnDone // btnDone
@ -239,12 +240,23 @@
// cbVLANs // cbVLANs
// //
this.cbVLANs.AutoSize = true; this.cbVLANs.AutoSize = true;
this.cbVLANs.Location = new System.Drawing.Point(341, 44); this.cbVLANs.Location = new System.Drawing.Point(519, 247);
this.cbVLANs.Name = "cbVLANs"; this.cbVLANs.Name = "cbVLANs";
this.cbVLANs.Size = new System.Drawing.Size(129, 21); this.cbVLANs.Size = new System.Drawing.Size(129, 21);
this.cbVLANs.TabIndex = 21; this.cbVLANs.TabIndex = 21;
this.cbVLANs.Text = "VLANs Enabled"; this.cbVLANs.Text = "VLANs Enabled";
this.cbVLANs.UseVisualStyleBackColor = true; this.cbVLANs.UseVisualStyleBackColor = true;
this.cbVLANs.CheckedChanged += new System.EventHandler(this.cbVLANs_CheckedChanged);
//
// cb_ColoredPackets
//
this.cb_ColoredPackets.AutoSize = true;
this.cb_ColoredPackets.Location = new System.Drawing.Point(519, 274);
this.cb_ColoredPackets.Name = "cb_ColoredPackets";
this.cb_ColoredPackets.Size = new System.Drawing.Size(173, 21);
this.cb_ColoredPackets.TabIndex = 22;
this.cb_ColoredPackets.Text = "VLAN Colored Packets";
this.cb_ColoredPackets.UseVisualStyleBackColor = true;
// //
// OptionsWindow // OptionsWindow
// //
@ -252,6 +264,7 @@
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.cb_ColoredPackets);
this.Controls.Add(this.cbVLANs); this.Controls.Add(this.cbVLANs);
this.Controls.Add(this.lblStartingHelp); this.Controls.Add(this.lblStartingHelp);
this.Controls.Add(this.cbStartingHelpLevel); this.Controls.Add(this.cbStartingHelpLevel);
@ -305,5 +318,6 @@
private System.Windows.Forms.ComboBox cbStartingHelpLevel; private System.Windows.Forms.ComboBox cbStartingHelpLevel;
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;
} }
} }

View File

@ -46,6 +46,7 @@ namespace EduNetworkBuilder
myToolTip.SetToolTip(lblSortOrder, NB.Translate("OW_OWSort")); myToolTip.SetToolTip(lblSortOrder, NB.Translate("OW_OWSort"));
myToolTip.SetToolTip(tbSortOrder, NB.Translate("OW_OWSort")); myToolTip.SetToolTip(tbSortOrder, NB.Translate("OW_OWSort"));
myToolTip.SetToolTip(cbVLANs, NB.Translate("OW_OWVLANs")); myToolTip.SetToolTip(cbVLANs, NB.Translate("OW_OWVLANs"));
myToolTip.SetToolTip(cb_ColoredPackets, NB.Translate("OW_OWVLANColoredPacketsTT"));
LoadValuesFromNetwork(); LoadValuesFromNetwork();
} }
@ -63,6 +64,7 @@ namespace EduNetworkBuilder
lblSortOrder.Text = NB.Translate("OW_lblSortOrder"); lblSortOrder.Text = NB.Translate("OW_lblSortOrder");
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");
Text = NB.Translate("OW_Form"); Text = NB.Translate("OW_Form");
} }
@ -74,6 +76,7 @@ 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;
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();
tbLevel.Text = myNet.Level.ToString(); tbLevel.Text = myNet.Level.ToString();
@ -111,6 +114,7 @@ namespace EduNetworkBuilder
myNet.NetTitle.Add(tbNetworkTitle.Text); myNet.NetTitle.Add(tbNetworkTitle.Text);
myNet.OptionShowLabels = cbDisplayTitles.Checked; myNet.OptionShowLabels = cbDisplayTitles.Checked;
myNet.VLANsEnabled = cbVLANs.Checked; myNet.VLANsEnabled = cbVLANs.Checked;
myNet.VLANPacketColors = cb_ColoredPackets.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);
@ -375,5 +379,18 @@ namespace EduNetworkBuilder
int.TryParse(tbLevel.Text, out value); int.TryParse(tbLevel.Text, out value);
tbLevel.Text = value.ToString(); tbLevel.Text = value.ToString();
} }
private void cbVLANs_CheckedChanged(object sender, EventArgs e)
{
if(cbVLANs.Checked)
{
cb_ColoredPackets.Visible = true;
}
else
{
cb_ColoredPackets.Visible = false;
cb_ColoredPackets.Checked = false;
}
}
} }
} }

View File

@ -1601,4 +1601,12 @@
<value>The Interface needs an Untagged VLAN</value> <value>The Interface needs an Untagged VLAN</value>
<comment>NT_TstDiscriptNeedsUntaggedVLAN</comment> <comment>NT_TstDiscriptNeedsUntaggedVLAN</comment>
</data> </data>
<data name="OW_OWVLANColoredPackets" xml:space="preserve">
<value>VLAN Colored Packets</value>
<comment>OW_OWVLANColoredPackets = VLAN Colored Packets</comment>
</data>
<data name="OW_OWVLANColoredPacketsTT" xml:space="preserve">
<value>When packets are passing across a VLAN link, color the packets so we can visualize them better.</value>
<comment>OW_OWVLANColoredPacketsTT = When packets are passing across a VLAN link, color the packets so we can visualize them better.</comment>
</data>
</root> </root>

View File

@ -14,6 +14,7 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<uniqueidentifier>169</uniqueidentifier> <uniqueidentifier>169</uniqueidentifier>
<startinghelplevel>full</startinghelplevel> <startinghelplevel>full</startinghelplevel>
<vlansenabled>True</vlansenabled> <vlansenabled>True</vlansenabled>
<VLANPacketColors>True</VLANPacketColors>
<device> <device>
<hostname>firewall0</hostname> <hostname>firewall0</hostname>
<size>100</size> <size>100</size>
@ -40,6 +41,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>134</uniqueidentifier> <uniqueidentifier>134</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -64,6 +67,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>wan</nictype> <nictype>wan</nictype>
<uniqueidentifier>137</uniqueidentifier> <uniqueidentifier>137</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>wan0</nicname> <nicname>wan0</nicname>
<myip> <myip>
@ -88,6 +93,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>135</uniqueidentifier> <uniqueidentifier>135</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth0</nicname> <nicname>eth0</nicname>
<myip> <myip>
@ -138,6 +145,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>136</uniqueidentifier> <uniqueidentifier>136</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth1</nicname> <nicname>eth1</nicname>
<myip> <myip>
@ -207,6 +216,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>144</uniqueidentifier> <uniqueidentifier>144</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -231,6 +242,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>145</uniqueidentifier> <uniqueidentifier>145</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth0</nicname> <nicname>eth0</nicname>
<myip> <myip>
@ -260,10 +273,10 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<interface> <interface>
<nicname>wlan2</nicname> <nicname>wlan2</nicname>
<myip> <myip>
<ip>192.168.2.5</ip> <ip>0.0.0.0</ip>
<mask>255.255.255.0</mask> <mask>0.0.0.0</mask>
<gateway>192.168.2.1</gateway> <gateway>0.0.0.0</gateway>
<type>route</type> <type>ip</type>
</myip> </myip>
<VLAN <VLAN
ID="1">Untagged</VLAN> ID="1">Untagged</VLAN>
@ -296,6 +309,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>148</uniqueidentifier> <uniqueidentifier>148</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -320,6 +335,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>149</uniqueidentifier> <uniqueidentifier>149</uniqueidentifier>
<usesdhcp>True</usesdhcp> <usesdhcp>True</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth0</nicname> <nicname>eth0</nicname>
<myip> <myip>
@ -344,6 +361,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>wlan</nictype> <nictype>wlan</nictype>
<uniqueidentifier>150</uniqueidentifier> <uniqueidentifier>150</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>wlan2</nicname> <nicname>wlan2</nicname>
<myip> <myip>
@ -383,6 +402,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>101</uniqueidentifier> <uniqueidentifier>101</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -407,6 +428,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>management_interface</nictype> <nictype>management_interface</nictype>
<uniqueidentifier>102</uniqueidentifier> <uniqueidentifier>102</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>management_interface0</nicname> <nicname>management_interface0</nicname>
<myip> <myip>
@ -431,6 +454,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>103</uniqueidentifier> <uniqueidentifier>103</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port1</nicname> <nicname>port1</nicname>
<myip> <myip>
@ -459,6 +484,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>104</uniqueidentifier> <uniqueidentifier>104</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port2</nicname> <nicname>port2</nicname>
<myip> <myip>
@ -487,6 +514,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>105</uniqueidentifier> <uniqueidentifier>105</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port3</nicname> <nicname>port3</nicname>
<myip> <myip>
@ -515,6 +544,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>106</uniqueidentifier> <uniqueidentifier>106</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port4</nicname> <nicname>port4</nicname>
<myip> <myip>
@ -543,6 +574,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>107</uniqueidentifier> <uniqueidentifier>107</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port5</nicname> <nicname>port5</nicname>
<myip> <myip>
@ -571,6 +604,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>108</uniqueidentifier> <uniqueidentifier>108</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port6</nicname> <nicname>port6</nicname>
<myip> <myip>
@ -599,6 +634,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>109</uniqueidentifier> <uniqueidentifier>109</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port7</nicname> <nicname>port7</nicname>
<myip> <myip>
@ -642,6 +679,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>156</uniqueidentifier> <uniqueidentifier>156</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -666,6 +705,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>management_interface</nictype> <nictype>management_interface</nictype>
<uniqueidentifier>157</uniqueidentifier> <uniqueidentifier>157</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>management_interface0</nicname> <nicname>management_interface0</nicname>
<myip> <myip>
@ -690,6 +731,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>158</uniqueidentifier> <uniqueidentifier>158</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port1</nicname> <nicname>port1</nicname>
<myip> <myip>
@ -718,6 +761,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>159</uniqueidentifier> <uniqueidentifier>159</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port2</nicname> <nicname>port2</nicname>
<myip> <myip>
@ -746,6 +791,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>160</uniqueidentifier> <uniqueidentifier>160</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port3</nicname> <nicname>port3</nicname>
<myip> <myip>
@ -774,6 +821,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>161</uniqueidentifier> <uniqueidentifier>161</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port4</nicname> <nicname>port4</nicname>
<myip> <myip>
@ -802,6 +851,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>162</uniqueidentifier> <uniqueidentifier>162</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port5</nicname> <nicname>port5</nicname>
<myip> <myip>
@ -830,6 +881,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>163</uniqueidentifier> <uniqueidentifier>163</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port6</nicname> <nicname>port6</nicname>
<myip> <myip>
@ -858,6 +911,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>port</nictype> <nictype>port</nictype>
<uniqueidentifier>164</uniqueidentifier> <uniqueidentifier>164</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>port7</nicname> <nicname>port7</nicname>
<myip> <myip>
@ -902,6 +957,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>111</uniqueidentifier> <uniqueidentifier>111</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -926,6 +983,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>112</uniqueidentifier> <uniqueidentifier>112</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth0</nicname> <nicname>eth0</nicname>
<myip> <myip>
@ -966,6 +1025,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>114</uniqueidentifier> <uniqueidentifier>114</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -990,6 +1051,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>115</uniqueidentifier> <uniqueidentifier>115</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth0</nicname> <nicname>eth0</nicname>
<myip> <myip>
@ -1030,6 +1093,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>117</uniqueidentifier> <uniqueidentifier>117</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -1054,6 +1119,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>118</uniqueidentifier> <uniqueidentifier>118</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth0</nicname> <nicname>eth0</nicname>
<myip> <myip>
@ -1093,6 +1160,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>lo</nictype> <nictype>lo</nictype>
<uniqueidentifier>122</uniqueidentifier> <uniqueidentifier>122</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>lo0</nicname> <nicname>lo0</nicname>
<myip> <myip>
@ -1117,6 +1186,8 @@ For this map, the VLAN packets are displayed with the color of the PC on that VL
<nictype>eth</nictype> <nictype>eth</nictype>
<uniqueidentifier>123</uniqueidentifier> <uniqueidentifier>123</uniqueidentifier>
<usesdhcp>False</usesdhcp> <usesdhcp>False</usesdhcp>
<encryptionkey />
<ssid />
<interface> <interface>
<nicname>eth1</nicname> <nicname>eth1</nicname>
<myip> <myip>

View File

@ -49,9 +49,17 @@ namespace EduNetworkBuilder
} }
void NamesDataBindingComplete(object Sender, EventArgs e) void NamesDataBindingComplete(object Sender, EventArgs e)
{
Network theNet = NB.GetNetwork();
if (dgv_VLANNames.Columns.Count > 0)
{ {
dgv_VLANNames.Columns[0].ReadOnly = LockedNames; dgv_VLANNames.Columns[0].ReadOnly = LockedNames;
dgv_VLANNames.Columns[1].ReadOnly = LockedNames; dgv_VLANNames.Columns[1].ReadOnly = LockedNames;
if(theNet.VLANPacketColors && dgv_VLANNames.Columns.Count > 2)
{
dgv_VLANNames.Columns[2].ReadOnly = LockedNames;
}
}
} }
private void UpdateForm() private void UpdateForm()
@ -70,6 +78,7 @@ namespace EduNetworkBuilder
UpdateNamesFromForm(); //Read in any changes so far UpdateNamesFromForm(); //Read in any changes so far
processing = true; processing = true;
//********************
//Bind the vlan names //Bind the vlan names
Network theNet = NB.GetNetwork(); Network theNet = NB.GetNetwork();
int selectedrow = -1; int selectedrow = -1;
@ -84,8 +93,44 @@ namespace EduNetworkBuilder
List<VLANName> tList = theNet.VlanNames.OrderBy(x => x.ID).ToList(); List<VLANName> tList = theNet.VlanNames.OrderBy(x => x.ID).ToList();
StashedVLANNameList = new BindingList<VLANName>(tList); StashedVLANNameList = new BindingList<VLANName>(tList);
dgv_VLANNames.AutoGenerateColumns = false;
dgv_VLANNames.Columns.Clear();
dgv_VLANNames.DataSource = StashedVLANNameList; dgv_VLANNames.DataSource = StashedVLANNameList;
dgv_VLANNames.AllowUserToAddRows = true; dgv_VLANNames.AllowUserToAddRows = true;
//The VLAN ID
DataGridViewTextBoxColumn DGVTB = new DataGridViewTextBoxColumn();
DGVTB.ValueType = typeof(string);
DGVTB.DataPropertyName = "ID";
DGVTB.Name = "ID";
DGVTB.HeaderText = "ID";
dgv_VLANNames.Columns.Add(DGVTB);
//The VLAN name
DGVTB = new DataGridViewTextBoxColumn();
DGVTB.ValueType = typeof(string);
DGVTB.DataPropertyName = "Name";
DGVTB.Name = "Name";
DGVTB.HeaderText = "Name";
dgv_VLANNames.Columns.Add(DGVTB);
if (theNet.VLANPacketColors)
{
//The VLAN color. (optional)
DataGridViewComboBoxColumn DGVCBC = new DataGridViewComboBoxColumn();
DGVCBC.ValueType = typeof(string);
DGVCBC.DataPropertyName = "PacketColorString";
DGVCBC.Name = "Color";
DGVCBC.HeaderText = "Color";
DGVCBC.Items.Add("Blue");
DGVCBC.Items.Add("Purple");
DGVCBC.Items.Add("Yellow");
DGVCBC.Items.Add("Green");
DGVCBC.Items.Add("Orange");
DGVCBC.Items.Add("Cyan");
dgv_VLANNames.Columns.Add(DGVCBC);
}
if (TheDevice != null) if (TheDevice != null)
{ {
if (theNet.ItemIsLocked(hostname, "", NetTestType.LockVLANNames) || if (theNet.ItemIsLocked(hostname, "", NetTestType.LockVLANNames) ||
@ -94,6 +139,9 @@ namespace EduNetworkBuilder
else else
LockedNames = false; LockedNames = false;
} }
//**************************************
//Start building the VLAN/Interface list
VlanBindings.Columns.Clear(); VlanBindings.Columns.Clear();
VlanBindings.Columns.Add("IF", typeof(string)); VlanBindings.Columns.Add("IF", typeof(string));
foreach (VLANName vn in theNet.VlanNames) foreach (VLANName vn in theNet.VlanNames)
@ -234,7 +282,8 @@ namespace EduNetworkBuilder
{ {
if (!VLANNamesHasID(theNet.VlanNames, id)) if (!VLANNamesHasID(theNet.VlanNames, id))
{ {
Color tColor = oList[theNet.VlanNames.Count].PacketColor; Color tColor = Color.Blue;
if(theNet.VlanNames.Count < oList.Count ) tColor = oList[theNet.VlanNames.Count].PacketColor;
if (DR.Cells["Name"].Value == null) //When we are still adding if (DR.Cells["Name"].Value == null) //When we are still adding
theNet.VlanNames.Add(new VLANName(id, "----", tColor)); theNet.VlanNames.Add(new VLANName(id, "----", tColor));
else else
@ -283,8 +332,8 @@ namespace EduNetworkBuilder
private void dgv_VLANNames_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) private void dgv_VLANNames_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{ {
string headerText = //return;
dgv_VLANNames.Columns[e.ColumnIndex].HeaderText; string headerText = dgv_VLANNames.Columns[e.ColumnIndex].Name;
if (processing) return; if (processing) return;
dgv_VLANNames.Rows[e.RowIndex].ErrorText = ""; //clear the old one out dgv_VLANNames.Rows[e.RowIndex].ErrorText = ""; //clear the old one out
@ -325,9 +374,13 @@ namespace EduNetworkBuilder
} }
} }
//MessageBox.Show(e.RowIndex.ToString() + " out of " + StashedVLANNameList.Count); //MessageBox.Show(e.RowIndex.ToString() + " out of " + StashedVLANNameList.Count);
} }
} }
if (headerText.Equals("Color"))
{
//Checking the color
Console.WriteLine("Here "+ e.RowIndex);
}
} }
private void dgv_VLANNames_UserDeletedRow(object sender, DataGridViewRowEventArgs e) private void dgv_VLANNames_UserDeletedRow(object sender, DataGridViewRowEventArgs e)

View File

@ -11,16 +11,16 @@ namespace EduNetworkBuilder
[Serializable] [Serializable]
public class VLANName public class VLANName
{ {
public int _ID; public int _ID = 0;
[DisplayName("ID")] [DisplayName("ID")]
public int ID { get { return _ID; } set { _ID = value; } } public int ID { get { return _ID; } set { _ID = value; } }
public string _Name; public string _Name = "----";
[DisplayName("Name")] [DisplayName("Name")]
public string Name { get { return _Name; } set { _Name = value; } } public string Name { get { return _Name; } set { _Name = value; } }
Color _Color = Color.Empty; Color _Color = Color.Blue;
[DisplayName("ColorString")] [DisplayName("ColorString")]
public string PacketColorString { get { return _Color.Name; } set { _Color = Color.FromName(value); } } public string PacketColorString { get { return _Color.Name; } set { _Color = Color.FromName(value); } }
public Color PacketColor { get { return _Color; } set { _Color = value; } } public Color PacketColor { get { return _Color; } set { _Color = value; } }