From 6079754714b3cd6bf72e5c9e7bd27410bb8effdf Mon Sep 17 00:00:00 2001 From: Tim Young Date: Thu, 31 Aug 2017 09:25:37 -0500 Subject: [PATCH] Make options save different device captioning. --- EduNetworkBuilder/Network.cs | 6 ++-- EduNetworkBuilder/OptionsWindow.Designer.cs | 36 ++++++++++++------- EduNetworkBuilder/OptionsWindow.cs | 34 ++++++++++++++++-- .../Resources/languages/edustrings.resx | 20 +++++++++++ 4 files changed, 79 insertions(+), 17 deletions(-) diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 1b7618c..d8dca87 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -199,13 +199,15 @@ namespace EduNetworkBuilder if(bool.TryParse(Individual.InnerText, out tf_answer)) { //compatibility with the old simple true/false - if (tf_answer) ShowLabelsHere = CaptionType.full; - else ShowLabelsHere = CaptionType.none; + if (tf_answer) { ShowLabelsHere = CaptionType.full; } + else { ShowLabelsHere = CaptionType.none; } } else { ShowLabelsHere = NB.TryParseEnum(Individual.InnerText, CaptionType.none); + } + OptionShowLabels = ShowLabelsHere; break; case "vlansenabled": bool.TryParse(Individual.InnerText, out VLANsEnabled); diff --git a/EduNetworkBuilder/OptionsWindow.Designer.cs b/EduNetworkBuilder/OptionsWindow.Designer.cs index d293429..df2ddc1 100644 --- a/EduNetworkBuilder/OptionsWindow.Designer.cs +++ b/EduNetworkBuilder/OptionsWindow.Designer.cs @@ -31,7 +31,6 @@ this.btnDone = new System.Windows.Forms.Button(); this.lblNetTitle = new System.Windows.Forms.Label(); this.tbNetworkTitle = new System.Windows.Forms.TextBox(); - this.cbDisplayTitles = new System.Windows.Forms.CheckBox(); this.lblNetSize = new System.Windows.Forms.Label(); this.tbNetworkX = new System.Windows.Forms.TextBox(); this.tbNetworkY = new System.Windows.Forms.TextBox(); @@ -51,6 +50,8 @@ this.lblStartingHelp = new System.Windows.Forms.Label(); this.cbVLANs = 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(); // // btnDone @@ -80,16 +81,6 @@ this.tbNetworkTitle.Size = new System.Drawing.Size(306, 22); 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 // this.lblNetSize.AutoSize = true; @@ -258,12 +249,31 @@ this.cb_ColoredPackets.Text = "VLAN Colored Packets"; 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 // 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.lblCaptions); + this.Controls.Add(this.cbCaptions); this.Controls.Add(this.cb_ColoredPackets); this.Controls.Add(this.cbVLANs); this.Controls.Add(this.lblStartingHelp); @@ -283,7 +293,6 @@ this.Controls.Add(this.tbNetworkY); this.Controls.Add(this.tbNetworkX); this.Controls.Add(this.lblNetSize); - this.Controls.Add(this.cbDisplayTitles); this.Controls.Add(this.tbNetworkTitle); this.Controls.Add(this.lblNetTitle); this.Controls.Add(this.btnDone); @@ -300,7 +309,6 @@ private System.Windows.Forms.Button btnDone; private System.Windows.Forms.Label lblNetTitle; private System.Windows.Forms.TextBox tbNetworkTitle; - private System.Windows.Forms.CheckBox cbDisplayTitles; private System.Windows.Forms.Label lblNetSize; private System.Windows.Forms.TextBox tbNetworkX; private System.Windows.Forms.TextBox tbNetworkY; @@ -320,5 +328,7 @@ private System.Windows.Forms.Label lblStartingHelp; private System.Windows.Forms.CheckBox cbVLANs; private System.Windows.Forms.CheckBox cb_ColoredPackets; + private System.Windows.Forms.ComboBox cbCaptions; + private System.Windows.Forms.Label lblCaptions; } } \ No newline at end of file diff --git a/EduNetworkBuilder/OptionsWindow.cs b/EduNetworkBuilder/OptionsWindow.cs index 880a2cb..e09c458 100644 --- a/EduNetworkBuilder/OptionsWindow.cs +++ b/EduNetworkBuilder/OptionsWindow.cs @@ -28,6 +28,7 @@ namespace EduNetworkBuilder { myNet = theNet; InitializeComponent(); + LocalSetup(); myToolTip.SetToolTip(tbItemSize, NB.Translate("OW_OWSize")); myToolTip.SetToolTip(lblItemSize, NB.Translate("OW_OWSize")); myToolTip.SetToolTip(tbMessage, NB.Translate("OW_OWLoad")); @@ -51,11 +52,21 @@ namespace EduNetworkBuilder 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() { Text = NB.Translate("_Done"); 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_lblItemSize"); lblNetMessage.Text = NB.Translate("OW_lblNetMessage"); @@ -69,13 +80,26 @@ namespace EduNetworkBuilder Text = NB.Translate("OW_Form"); } + List CaptionOptionList() + { + List theList = new List(); + foreach (string one in Enum.GetNames(typeof(CaptionType))) + theList.Add(one); + return theList; + } private void LoadValuesFromNetwork() { tbItemSize.Text = myNet.itemsize.ToString(); tbMessage.Text = myNet.NetMessage.GetText(); tbNetworkTitle.Text = myNet.NetTitle.GetText(); - //cbDisplayTitles.Checked = myNet.OptionShowLabels; + + //select the Caption Level item we have defined. + List CaptionItemList = CaptionOptionList(); + int index = CaptionItemList.IndexOf(myNet.OptionShowLabels.ToString()); + if (index < 0) index = 0; + if (index >= 0) cbCaptions.SelectedIndex = index; + cbVLANs.Checked = myNet.VLANsEnabled; cb_ColoredPackets.Checked = myNet.VLANPacketColors; tbNetworkX.Text = myNet.myWidth.ToString(); @@ -113,6 +137,12 @@ namespace EduNetworkBuilder int.TryParse(tbItemSize.Text, out myNet.itemsize); myNet.NetMessage.Add( tbMessage.Text); myNet.NetTitle.Add(tbNetworkTitle.Text); + + List CaptionItemList = CaptionOptionList(); + int index = cbCaptions.SelectedIndex; + if (index > 0) + myNet.OptionShowLabels = NB.TryParseEnum(CaptionItemList[index], CaptionType.none); + //myNet.OptionShowLabels = cbDisplayTitles.Checked; myNet.VLANsEnabled = cbVLANs.Checked; myNet.VLANPacketColors = cb_ColoredPackets.Checked; diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index d9e656a..cb334c8 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1929,4 +1929,24 @@ Internet NB_InternetHomeAndOffice = Internet + + Full + Options_Caption_full = Full + + + Host + Options_Caption_host = Host + + + Host +IP + Options_Caption_host_ip = Host +IP + + + IP + Options_Caption_ip = IP + + + None + Options_Caption_none = None + \ No newline at end of file