Make options save different device captioning.

This commit is contained in:
Tim Young 2017-08-31 09:25:37 -05:00
parent 0f19ca49a8
commit 6079754714
4 changed files with 79 additions and 17 deletions

View File

@ -199,13 +199,15 @@ namespace EduNetworkBuilder
if(bool.TryParse(Individual.InnerText, out tf_answer)) if(bool.TryParse(Individual.InnerText, out tf_answer))
{ {
//compatibility with the old simple true/false //compatibility with the old simple true/false
if (tf_answer) ShowLabelsHere = CaptionType.full; if (tf_answer) { ShowLabelsHere = CaptionType.full; }
else ShowLabelsHere = CaptionType.none; else { ShowLabelsHere = CaptionType.none; }
} }
else else
{ {
ShowLabelsHere = NB.TryParseEnum<CaptionType>(Individual.InnerText, CaptionType.none); ShowLabelsHere = NB.TryParseEnum<CaptionType>(Individual.InnerText, CaptionType.none);
} }
OptionShowLabels = ShowLabelsHere;
break; break;
case "vlansenabled": case "vlansenabled":
bool.TryParse(Individual.InnerText, out VLANsEnabled); bool.TryParse(Individual.InnerText, out VLANsEnabled);

View File

@ -31,7 +31,6 @@
this.btnDone = new System.Windows.Forms.Button(); this.btnDone = new System.Windows.Forms.Button();
this.lblNetTitle = new System.Windows.Forms.Label(); this.lblNetTitle = new System.Windows.Forms.Label();
this.tbNetworkTitle = new System.Windows.Forms.TextBox(); this.tbNetworkTitle = new System.Windows.Forms.TextBox();
this.cbDisplayTitles = new System.Windows.Forms.CheckBox();
this.lblNetSize = new System.Windows.Forms.Label(); this.lblNetSize = new System.Windows.Forms.Label();
this.tbNetworkX = new System.Windows.Forms.TextBox(); this.tbNetworkX = new System.Windows.Forms.TextBox();
this.tbNetworkY = new System.Windows.Forms.TextBox(); this.tbNetworkY = new System.Windows.Forms.TextBox();
@ -51,6 +50,8 @@
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.cbCaptions = new System.Windows.Forms.ComboBox();
this.lblCaptions = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnDone // btnDone
@ -80,16 +81,6 @@
this.tbNetworkTitle.Size = new System.Drawing.Size(306, 22); this.tbNetworkTitle.Size = new System.Drawing.Size(306, 22);
this.tbNetworkTitle.TabIndex = 2; this.tbNetworkTitle.TabIndex = 2;
// //
// cbDisplayTitles
//
this.cbDisplayTitles.AutoSize = true;
this.cbDisplayTitles.Location = new System.Drawing.Point(184, 44);
this.cbDisplayTitles.Name = "cbDisplayTitles";
this.cbDisplayTitles.Size = new System.Drawing.Size(114, 21);
this.cbDisplayTitles.TabIndex = 3;
this.cbDisplayTitles.Text = "Display Titles";
this.cbDisplayTitles.UseVisualStyleBackColor = true;
//
// lblNetSize // lblNetSize
// //
this.lblNetSize.AutoSize = true; this.lblNetSize.AutoSize = true;
@ -258,12 +249,31 @@
this.cb_ColoredPackets.Text = "VLAN Colored Packets"; this.cb_ColoredPackets.Text = "VLAN Colored Packets";
this.cb_ColoredPackets.UseVisualStyleBackColor = true; this.cb_ColoredPackets.UseVisualStyleBackColor = true;
// //
// cbCaptions
//
this.cbCaptions.FormattingEnabled = true;
this.cbCaptions.Location = new System.Drawing.Point(185, 42);
this.cbCaptions.Name = "cbCaptions";
this.cbCaptions.Size = new System.Drawing.Size(150, 24);
this.cbCaptions.TabIndex = 23;
//
// lblCaptions
//
this.lblCaptions.AutoSize = true;
this.lblCaptions.Location = new System.Drawing.Point(23, 45);
this.lblCaptions.Name = "lblCaptions";
this.lblCaptions.Size = new System.Drawing.Size(92, 17);
this.lblCaptions.TabIndex = 24;
this.lblCaptions.Text = "Display Titles";
//
// 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.lblCaptions);
this.Controls.Add(this.cbCaptions);
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);
@ -283,7 +293,6 @@
this.Controls.Add(this.tbNetworkY); this.Controls.Add(this.tbNetworkY);
this.Controls.Add(this.tbNetworkX); this.Controls.Add(this.tbNetworkX);
this.Controls.Add(this.lblNetSize); this.Controls.Add(this.lblNetSize);
this.Controls.Add(this.cbDisplayTitles);
this.Controls.Add(this.tbNetworkTitle); this.Controls.Add(this.tbNetworkTitle);
this.Controls.Add(this.lblNetTitle); this.Controls.Add(this.lblNetTitle);
this.Controls.Add(this.btnDone); this.Controls.Add(this.btnDone);
@ -300,7 +309,6 @@
private System.Windows.Forms.Button btnDone; private System.Windows.Forms.Button btnDone;
private System.Windows.Forms.Label lblNetTitle; private System.Windows.Forms.Label lblNetTitle;
private System.Windows.Forms.TextBox tbNetworkTitle; private System.Windows.Forms.TextBox tbNetworkTitle;
private System.Windows.Forms.CheckBox cbDisplayTitles;
private System.Windows.Forms.Label lblNetSize; private System.Windows.Forms.Label lblNetSize;
private System.Windows.Forms.TextBox tbNetworkX; private System.Windows.Forms.TextBox tbNetworkX;
private System.Windows.Forms.TextBox tbNetworkY; private System.Windows.Forms.TextBox tbNetworkY;
@ -320,5 +328,7 @@
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.ComboBox cbCaptions;
private System.Windows.Forms.Label lblCaptions;
} }
} }

View File

@ -28,6 +28,7 @@ namespace EduNetworkBuilder
{ {
myNet = theNet; myNet = theNet;
InitializeComponent(); InitializeComponent();
LocalSetup();
myToolTip.SetToolTip(tbItemSize, NB.Translate("OW_OWSize")); myToolTip.SetToolTip(tbItemSize, NB.Translate("OW_OWSize"));
myToolTip.SetToolTip(lblItemSize, NB.Translate("OW_OWSize")); myToolTip.SetToolTip(lblItemSize, NB.Translate("OW_OWSize"));
myToolTip.SetToolTip(tbMessage, NB.Translate("OW_OWLoad")); myToolTip.SetToolTip(tbMessage, NB.Translate("OW_OWLoad"));
@ -51,11 +52,21 @@ namespace EduNetworkBuilder
Icon = Properties.Resources.NBIco; Icon = Properties.Resources.NBIco;
} }
private void LocalSetup()
{
cbCaptions.Items.Clear();
foreach(string one in CaptionOptionList())
{
string ToTranslate = "Options_Caption_" + one;
cbCaptions.Items.Add(NB.Translate(ToTranslate));
}
}
private void LanguagifyComponents() private void LanguagifyComponents()
{ {
Text = NB.Translate("_Done"); Text = NB.Translate("_Done");
lblNetTitle.Text = NB.Translate("OW_lblNetTitle"); lblNetTitle.Text = NB.Translate("OW_lblNetTitle");
cbDisplayTitles.Text = NB.Translate("OW_cbDisplayTitles"); lblCaptions.Text = NB.Translate("OW_cbDisplayTitles");
lblNetSize.Text = NB.Translate("OW_lblNetSize"); lblNetSize.Text = NB.Translate("OW_lblNetSize");
lblNetSize.Text = NB.Translate("OW_lblItemSize"); lblNetSize.Text = NB.Translate("OW_lblItemSize");
lblNetMessage.Text = NB.Translate("OW_lblNetMessage"); lblNetMessage.Text = NB.Translate("OW_lblNetMessage");
@ -69,13 +80,26 @@ namespace EduNetworkBuilder
Text = NB.Translate("OW_Form"); Text = NB.Translate("OW_Form");
} }
List<string> CaptionOptionList()
{
List<string> theList = new List<string>();
foreach (string one in Enum.GetNames(typeof(CaptionType)))
theList.Add(one);
return theList;
}
private void LoadValuesFromNetwork() private void LoadValuesFromNetwork()
{ {
tbItemSize.Text = myNet.itemsize.ToString(); tbItemSize.Text = myNet.itemsize.ToString();
tbMessage.Text = myNet.NetMessage.GetText(); tbMessage.Text = myNet.NetMessage.GetText();
tbNetworkTitle.Text = myNet.NetTitle.GetText(); tbNetworkTitle.Text = myNet.NetTitle.GetText();
//cbDisplayTitles.Checked = myNet.OptionShowLabels;
//select the Caption Level item we have defined.
List<string> CaptionItemList = CaptionOptionList();
int index = CaptionItemList.IndexOf(myNet.OptionShowLabels.ToString());
if (index < 0) index = 0;
if (index >= 0) cbCaptions.SelectedIndex = index;
cbVLANs.Checked = myNet.VLANsEnabled; cbVLANs.Checked = myNet.VLANsEnabled;
cb_ColoredPackets.Checked = myNet.VLANPacketColors; cb_ColoredPackets.Checked = myNet.VLANPacketColors;
tbNetworkX.Text = myNet.myWidth.ToString(); tbNetworkX.Text = myNet.myWidth.ToString();
@ -113,6 +137,12 @@ namespace EduNetworkBuilder
int.TryParse(tbItemSize.Text, out myNet.itemsize); int.TryParse(tbItemSize.Text, out myNet.itemsize);
myNet.NetMessage.Add( tbMessage.Text); myNet.NetMessage.Add( tbMessage.Text);
myNet.NetTitle.Add(tbNetworkTitle.Text); myNet.NetTitle.Add(tbNetworkTitle.Text);
List<string> CaptionItemList = CaptionOptionList();
int index = cbCaptions.SelectedIndex;
if (index > 0)
myNet.OptionShowLabels = NB.TryParseEnum<CaptionType>(CaptionItemList[index], CaptionType.none);
//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;

View File

@ -1929,4 +1929,24 @@
<value>Internet</value> <value>Internet</value>
<comment>NB_InternetHomeAndOffice = Internet</comment> <comment>NB_InternetHomeAndOffice = Internet</comment>
</data> </data>
<data name="Options_Caption_full" xml:space="preserve">
<value>Full</value>
<comment>Options_Caption_full = Full</comment>
</data>
<data name="Options_Caption_host" xml:space="preserve">
<value>Host</value>
<comment>Options_Caption_host = Host</comment>
</data>
<data name="Options_Caption_host_ip" xml:space="preserve">
<value>Host +IP</value>
<comment>Options_Caption_host_ip = Host +IP</comment>
</data>
<data name="Options_Caption_ip" xml:space="preserve">
<value>IP</value>
<comment>Options_Caption_ip = IP</comment>
</data>
<data name="Options_Caption_none" xml:space="preserve">
<value>None</value>
<comment>Options_Caption_none = None</comment>
</data>
</root> </root>