Context reader, context-reader-test, and color-coding

This commit is contained in:
Tim Young 2015-08-08 11:09:22 -06:00
parent b4630655b3
commit 4c82388485
9 changed files with 278 additions and 71 deletions

View File

@ -11,6 +11,7 @@ using System.Xml;
using System.Drawing;
using System.Media;
using System.Reflection;
using System.Text.RegularExpressions;
namespace EduNetworkBuilder
@ -39,7 +40,7 @@ namespace EduNetworkBuilder
public enum NBSoundType { none, success }
public enum RTFWindowContents { help, about, release_notes }
public enum NetTestType { NeedsLocalIPTo, NeedsDefaultGW, NeedsLinkToDevice, NeedsRouteToNet,
SuccessfullyPings, SuccessfullyArps, SuccessfullyDHCPs, HelpRequest, FailedPing,
SuccessfullyPings, SuccessfullyArps, SuccessfullyDHCPs, HelpRequest, ReadContextHelp, FailedPing,
LockAll, LockIP, LockRoute, LockNic, LockDHCP, LockGateway
}
public enum NetTestVerbosity { none, basic, hints, full }
@ -293,6 +294,12 @@ namespace EduNetworkBuilder
if (myWin.GameRandomGen == null) return null;
return myWin.myNetwork;
}
public static BuilderWindow GetBuilderWin()
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
if (myWin == null) return null;
return myWin;
}
/// <summary>
/// Return a translated string in the current chosen language
@ -306,13 +313,23 @@ namespace EduNetworkBuilder
{
ResourceManager RM = GetResource();
CultureInfo CI = GetCulture();
string answer;
string answer="";
answer = RM.GetString(key, CI);
if (answer == null) return "";
return answer;
}
return myWin.Translate(key);
}
public static string GetHelpTopicKey(HelpTopics What)
{
return "H_" + What.ToString() + "_Key";
}
public static string GetHelpTopicTitle(HelpTopics What)
{
return "H_" + What.ToString() + "_Title";
}
public static DebugPausePoint GetDebugPauseSetting()
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
@ -483,9 +500,30 @@ namespace EduNetworkBuilder
public static void ReadContextHelp(HelpTopics What)
{
RTFWindow tForm = null;
//make a new window if needed
foreach(Form myfrm in Application.OpenForms)
{
if(myfrm.Name == "Context")
{
//We have a context window
tForm = (RTFWindow)myfrm;
break;
}
}
if(tForm == null)
{
//We do not have one yet. Make a new one
tForm = new RTFWindow(RTFWindowContents.help);
tForm.Name = "Context";
}
//load help
tForm.Show();
//Jump to the correct location
if(tForm != null)
{
tForm.JumpToSelection(What);
}
}
public static string GenerateMACAddress()

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Xml;
using System.Windows.Forms;
namespace EduNetworkBuilder
{
@ -21,6 +22,7 @@ namespace EduNetworkBuilder
sHost = srcHost;
dHost = dstHost;
TheTest = tTest;
SetInitialDoneState();
}
public NetTest(NetTest FromWhat)
@ -28,6 +30,7 @@ namespace EduNetworkBuilder
sHost = FromWhat.sHost;
dHost = FromWhat.dHost;
TheTest = FromWhat.TheTest;
SetInitialDoneState();
}
public NetTest(XmlNode theNode)
@ -53,6 +56,22 @@ namespace EduNetworkBuilder
}
}
}
SetInitialDoneState();
}
public void SetInitialDoneState()
{
switch (TheTest)
{
case NetTestType.LockAll:
case NetTestType.LockDHCP:
case NetTestType.LockGateway:
case NetTestType.LockIP:
case NetTestType.LockNic:
case NetTestType.LockRoute:
TaskWasDone = true;
break;
}
}
public void Save(XmlWriter writer)
@ -96,7 +115,9 @@ namespace EduNetworkBuilder
switch(amount)
{
case NetTestVerbosity.basic:
toreturn = "Has a problem";
if(TheTest != NetTestType.ReadContextHelp)
toreturn = "Has a problem";
toreturn = NB.Translate("_ReadContext");
break;
case NetTestVerbosity.hints:
switch (TheTest)
@ -149,6 +170,10 @@ namespace EduNetworkBuilder
case NetTestType.LockGateway:
toreturn = "Has Locked Gateway";
break;
case NetTestType.ReadContextHelp:
toreturn = NB.Translate("_ReadContext");
break;
}
break;
case NetTestVerbosity.full:
@ -202,6 +227,9 @@ namespace EduNetworkBuilder
case NetTestType.LockGateway:
toreturn = "Has Locked Gateway:";
break;
case NetTestType.ReadContextHelp:
toreturn = NB.Translate("_ReadContext");
break;
}
break;
case NetTestVerbosity.none:
@ -214,6 +242,10 @@ namespace EduNetworkBuilder
public string GetDescription(NetTestVerbosity amount)
{
string toreturn = "";
if(TheTest == NetTestType.ReadContextHelp)
{
return TestDescription(amount) + " " + sHost;
}
switch(amount)
{
case NetTestVerbosity.basic:
@ -248,6 +280,17 @@ namespace EduNetworkBuilder
bool WasDone = TaskWasDone;
if(!TestComplete())
{
if(TheTest == NetTestType.ReadContextHelp && ChangeColor)
{
BuilderWindow myWin = NB.GetBuilderWin();
if(myWin != null)
{
Control ctl = myWin.GetControlNamed(sHost);
if (ctl == null) return false;
ctl.BackColor = WrongColor;
}
return false;
}
Network theNet = NB.GetNetwork();
NetworkDevice Source = theNet.GetDeviceFromName(sHost);
if(Source!= null)
@ -345,6 +388,7 @@ namespace EduNetworkBuilder
case NetTestType.SuccessfullyDHCPs:
case NetTestType.SuccessfullyPings:
case NetTestType.HelpRequest:
case NetTestType.ReadContextHelp:
case NetTestType.FailedPing:
return TaskWasDone; //This variable will tell us if these tests have been done.
case NetTestType.LockAll:

View File

@ -51,6 +51,8 @@ namespace EduNetworkBuilder
private void btnOK_Click(object sender, EventArgs e)
{
OrigTest.UpdateValuesFromAnother(ToEdit);
OrigTest.TaskWasDone = false; //We edited it. Set it to false
OrigTest.SetInitialDoneState(); //Set some of them to true (locked. etc)
Close();
}
@ -94,12 +96,21 @@ namespace EduNetworkBuilder
}
else if (ToEdit.TheTest == NetTestType.HelpRequest)
{
foreach (string subnet in Enum.GetNames(typeof(NetTestVerbosity)))
foreach (string HelpLevel in Enum.GetNames(typeof(NetTestVerbosity)))
{
cbDest.Items.Add(subnet);
cbDest.Items.Add(HelpLevel);
}
cbDest.Items.Add("?Button");
}
else if (ToEdit.TheTest == NetTestType.ReadContextHelp)
{
cbSource.Items.Clear();
foreach (string ContextHelp in Enum.GetNames(typeof(HelpTopics)))
{
cbSource.Items.Add(ContextHelp);
}
cbDest.Items.Add("Read");
}
else if (ToEdit.TheTest == NetTestType.LockAll || ToEdit.TheTest == NetTestType.LockGateway)
{
cbDest.Items.Add("All");
@ -199,6 +210,7 @@ namespace EduNetworkBuilder
if (processing) return true; //If we are processing, we are all OK.
Network theNet = NB.GetNetwork();
NetTestType ntt = NB.ParseEnum<NetTestType>(cbTest.SelectedItem.ToString());
if (ntt == NetTestType.ReadContextHelp) return true;
if (cbSource.SelectedItem.ToString() == cbDest.SelectedItem.ToString() && ntt != NetTestType.HelpRequest)
return false; //Source cannot equal dest
if (theNet.GetDeviceFromName(cbSource.SelectedItem.ToString()) == null)

View File

@ -711,7 +711,7 @@ namespace EduNetworkBuilder
sourceIPstring = ReverseDNSLookup(null, sourceIP); //this will either be an ip address or the host name
destIP = new IPAddress(dHost);
destIPstring = ReverseDNSLookup(null, destIP); //this will either be an ip address or the host name
if ((nt.TheTest == NetTestType.HelpRequest || nt.TheTest == NetTestType.FailedPing) &&
if ((nt.TheTest == NetTestType.HelpRequest || nt.TheTest == NetTestType.FailedPing || nt.TheTest == NetTestType.ReadContextHelp) &&
(sHost == nt.sHost || sourceIPstring == nt.sHost) &&
(dHost == nt.dHost || destIPstring == nt.dHost))
{

View File

@ -41,6 +41,7 @@
this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.allToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dHCPRequestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearArpTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -76,7 +77,6 @@
this.rbHelp1 = new System.Windows.Forms.RadioButton();
this.HelpPanel = new System.Windows.Forms.Panel();
this.myProgressBar = new System.Windows.Forms.ProgressBar();
this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.msMainMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit();
this.HelpPanel.SuspendLayout();
@ -94,7 +94,7 @@
this.msMainMenuStrip.Location = new System.Drawing.Point(0, 0);
this.msMainMenuStrip.Name = "msMainMenuStrip";
this.msMainMenuStrip.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2);
this.msMainMenuStrip.Size = new System.Drawing.Size(463, 24);
this.msMainMenuStrip.Size = new System.Drawing.Size(463, 28);
this.msMainMenuStrip.TabIndex = 0;
this.msMainMenuStrip.Text = "msMainMenuStrip";
//
@ -107,41 +107,41 @@
this.saveToolStripMenuItem,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24);
this.fileToolStripMenuItem.Text = "File";
//
// newToolStripMenuItem
//
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
this.newToolStripMenuItem.Size = new System.Drawing.Size(125, 24);
this.newToolStripMenuItem.Text = "New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// loadToolStripMenuItem
//
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
this.loadToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
this.loadToolStripMenuItem.Size = new System.Drawing.Size(125, 24);
this.loadToolStripMenuItem.Text = "Load";
this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click);
//
// reloadToolStripMenuItem
//
this.reloadToolStripMenuItem.Name = "reloadToolStripMenuItem";
this.reloadToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
this.reloadToolStripMenuItem.Size = new System.Drawing.Size(125, 24);
this.reloadToolStripMenuItem.Text = "Reload";
this.reloadToolStripMenuItem.Click += new System.EventHandler(this.reloadToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
this.saveToolStripMenuItem.Size = new System.Drawing.Size(125, 24);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
this.exitToolStripMenuItem.Size = new System.Drawing.Size(125, 24);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
@ -155,40 +155,47 @@
this.optionsToolStripMenuItem,
this.changeLanguageToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Size = new System.Drawing.Size(47, 24);
this.editToolStripMenuItem.Text = "Edit";
//
// cutToolStripMenuItem
//
this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
this.cutToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.cutToolStripMenuItem.Size = new System.Drawing.Size(197, 24);
this.cutToolStripMenuItem.Text = "Cut";
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.copyToolStripMenuItem.Size = new System.Drawing.Size(197, 24);
this.copyToolStripMenuItem.Text = "Copy";
//
// pasteToolStripMenuItem
//
this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(197, 24);
this.pasteToolStripMenuItem.Text = "Paste";
//
// undoToolStripMenuItem
//
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
this.undoToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.undoToolStripMenuItem.Size = new System.Drawing.Size(197, 24);
this.undoToolStripMenuItem.Text = "Undo";
//
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(197, 24);
this.optionsToolStripMenuItem.Text = "Options";
this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click);
//
// changeLanguageToolStripMenuItem
//
this.changeLanguageToolStripMenuItem.Name = "changeLanguageToolStripMenuItem";
this.changeLanguageToolStripMenuItem.Size = new System.Drawing.Size(197, 24);
this.changeLanguageToolStripMenuItem.Text = "Change Language";
this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.changeLanguageToolStripMenuItem_Click);
//
// allToolStripMenuItem
//
this.allToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -197,34 +204,34 @@
this.clearIPsToolStripMenuItem,
this.pingToolStripMenuItem});
this.allToolStripMenuItem.Name = "allToolStripMenuItem";
this.allToolStripMenuItem.Size = new System.Drawing.Size(33, 20);
this.allToolStripMenuItem.Size = new System.Drawing.Size(39, 24);
this.allToolStripMenuItem.Text = "All";
//
// dHCPRequestToolStripMenuItem
//
this.dHCPRequestToolStripMenuItem.Name = "dHCPRequestToolStripMenuItem";
this.dHCPRequestToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
this.dHCPRequestToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.dHCPRequestToolStripMenuItem.Text = "DHCP Request";
this.dHCPRequestToolStripMenuItem.Click += new System.EventHandler(this.dHCPRequestToolStripMenuItem_Click);
//
// clearArpTableToolStripMenuItem
//
this.clearArpTableToolStripMenuItem.Name = "clearArpTableToolStripMenuItem";
this.clearArpTableToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
this.clearArpTableToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.clearArpTableToolStripMenuItem.Text = "Clear Arp Table";
this.clearArpTableToolStripMenuItem.Click += new System.EventHandler(this.clearArpTableToolStripMenuItem_Click);
//
// clearIPsToolStripMenuItem
//
this.clearIPsToolStripMenuItem.Name = "clearIPsToolStripMenuItem";
this.clearIPsToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
this.clearIPsToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.clearIPsToolStripMenuItem.Text = "Clear IPs";
this.clearIPsToolStripMenuItem.Click += new System.EventHandler(this.clearIPsToolStripMenuItem_Click);
//
// pingToolStripMenuItem
//
this.pingToolStripMenuItem.Name = "pingToolStripMenuItem";
this.pingToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
this.pingToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.pingToolStripMenuItem.Text = "Ping";
this.pingToolStripMenuItem.Click += new System.EventHandler(this.pingToolStripMenuItem_Click);
//
@ -236,34 +243,34 @@
this.releaseNotesToolStripMenuItem,
this.checkForUpdatesToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.helpToolStripMenuItem.Size = new System.Drawing.Size(53, 24);
this.helpToolStripMenuItem.Text = "Help";
//
// helpToolStripMenuItem1
//
this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1";
this.helpToolStripMenuItem1.Size = new System.Drawing.Size(173, 22);
this.helpToolStripMenuItem1.Size = new System.Drawing.Size(201, 24);
this.helpToolStripMenuItem1.Text = "Help";
this.helpToolStripMenuItem1.Click += new System.EventHandler(this.helpToolStripMenuItem1_Click);
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(201, 24);
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// releaseNotesToolStripMenuItem
//
this.releaseNotesToolStripMenuItem.Name = "releaseNotesToolStripMenuItem";
this.releaseNotesToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.releaseNotesToolStripMenuItem.Size = new System.Drawing.Size(201, 24);
this.releaseNotesToolStripMenuItem.Text = "Release Notes";
this.releaseNotesToolStripMenuItem.Click += new System.EventHandler(this.releaseNotesToolStripMenuItem_Click);
//
// checkForUpdatesToolStripMenuItem
//
this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";
this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(201, 24);
this.checkForUpdatesToolStripMenuItem.Text = "Check For Updates";
//
// samplesToolStripMenuItem
@ -273,13 +280,13 @@
this.solvedToolStripMenuItem,
this.toSolveToolStripMenuItem});
this.samplesToolStripMenuItem.Name = "samplesToolStripMenuItem";
this.samplesToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
this.samplesToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.samplesToolStripMenuItem.Text = "Samples";
//
// puzzlesToolStripMenuItem
//
this.puzzlesToolStripMenuItem.Name = "puzzlesToolStripMenuItem";
this.puzzlesToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
this.puzzlesToolStripMenuItem.Size = new System.Drawing.Size(135, 24);
this.puzzlesToolStripMenuItem.Text = "Puzzles";
this.puzzlesToolStripMenuItem.Click += new System.EventHandler(this.puzzlesToolStripMenuItem_Click);
//
@ -292,41 +299,41 @@
this.threeNetworksToolStripMenuItem,
this.firewallsToolStripMenuItem});
this.solvedToolStripMenuItem.Name = "solvedToolStripMenuItem";
this.solvedToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
this.solvedToolStripMenuItem.Size = new System.Drawing.Size(135, 24);
this.solvedToolStripMenuItem.Text = "Solved";
//
// dHCPToolStripMenuItem
//
this.dHCPToolStripMenuItem.Name = "dHCPToolStripMenuItem";
this.dHCPToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.dHCPToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.dHCPToolStripMenuItem.Text = "DHCP";
this.dHCPToolStripMenuItem.Click += new System.EventHandler(this.dHCPToolStripMenuItem_Click);
//
// oneNetworkToolStripMenuItem
//
this.oneNetworkToolStripMenuItem.Name = "oneNetworkToolStripMenuItem";
this.oneNetworkToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.oneNetworkToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.oneNetworkToolStripMenuItem.Text = "One Network";
this.oneNetworkToolStripMenuItem.Click += new System.EventHandler(this.oneNetworkToolStripMenuItem_Click);
//
// twoNetworksToolStripMenuItem
//
this.twoNetworksToolStripMenuItem.Name = "twoNetworksToolStripMenuItem";
this.twoNetworksToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.twoNetworksToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.twoNetworksToolStripMenuItem.Text = "Two Networks";
this.twoNetworksToolStripMenuItem.Click += new System.EventHandler(this.twoNetworksToolStripMenuItem_Click);
//
// threeNetworksToolStripMenuItem
//
this.threeNetworksToolStripMenuItem.Name = "threeNetworksToolStripMenuItem";
this.threeNetworksToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.threeNetworksToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.threeNetworksToolStripMenuItem.Text = "Three Networks";
this.threeNetworksToolStripMenuItem.Click += new System.EventHandler(this.threeNetworksToolStripMenuItem_Click);
//
// firewallsToolStripMenuItem
//
this.firewallsToolStripMenuItem.Name = "firewallsToolStripMenuItem";
this.firewallsToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.firewallsToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.firewallsToolStripMenuItem.Text = "Firewalls";
this.firewallsToolStripMenuItem.Click += new System.EventHandler(this.firewallsToolStripMenuItem_Click);
//
@ -339,41 +346,41 @@
this.SolvedThreeNetworksToolStripMenuItem,
this.firewallsToolStripMenuItem1});
this.toSolveToolStripMenuItem.Name = "toSolveToolStripMenuItem";
this.toSolveToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
this.toSolveToolStripMenuItem.Size = new System.Drawing.Size(135, 24);
this.toSolveToolStripMenuItem.Text = "To Solve";
//
// solvedDHCPToolStripMenuItem
//
this.solvedDHCPToolStripMenuItem.Name = "solvedDHCPToolStripMenuItem";
this.solvedDHCPToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.solvedDHCPToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.solvedDHCPToolStripMenuItem.Text = "DHCP";
this.solvedDHCPToolStripMenuItem.Click += new System.EventHandler(this.solvedDHCPToolStripMenuItem_Click);
//
// solvedOneNetworkToolStripMenuItem
//
this.solvedOneNetworkToolStripMenuItem.Name = "solvedOneNetworkToolStripMenuItem";
this.solvedOneNetworkToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.solvedOneNetworkToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.solvedOneNetworkToolStripMenuItem.Text = "One Network";
this.solvedOneNetworkToolStripMenuItem.Click += new System.EventHandler(this.solvedOneNetworkToolStripMenuItem_Click);
//
// solvedTwoNetworksToolStripMenuItem
//
this.solvedTwoNetworksToolStripMenuItem.Name = "solvedTwoNetworksToolStripMenuItem";
this.solvedTwoNetworksToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.solvedTwoNetworksToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.solvedTwoNetworksToolStripMenuItem.Text = "Two Networks";
this.solvedTwoNetworksToolStripMenuItem.Click += new System.EventHandler(this.solvedTwoNetworksToolStripMenuItem_Click);
//
// SolvedThreeNetworksToolStripMenuItem
//
this.SolvedThreeNetworksToolStripMenuItem.Name = "SolvedThreeNetworksToolStripMenuItem";
this.SolvedThreeNetworksToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.SolvedThreeNetworksToolStripMenuItem.Size = new System.Drawing.Size(181, 24);
this.SolvedThreeNetworksToolStripMenuItem.Text = "Three Networks";
this.SolvedThreeNetworksToolStripMenuItem.Click += new System.EventHandler(this.SolvedThreeNetworksToolStripMenuItem_Click);
//
// firewallsToolStripMenuItem1
//
this.firewallsToolStripMenuItem1.Name = "firewallsToolStripMenuItem1";
this.firewallsToolStripMenuItem1.Size = new System.Drawing.Size(157, 22);
this.firewallsToolStripMenuItem1.Size = new System.Drawing.Size(181, 24);
this.firewallsToolStripMenuItem1.Text = "Firewalls";
this.firewallsToolStripMenuItem1.Click += new System.EventHandler(this.firewallsToolStripMenuItem1_Click);
//
@ -382,7 +389,7 @@
this.panelChoices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.panelChoices.Location = new System.Drawing.Point(10, 25);
this.panelChoices.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelChoices.Margin = new System.Windows.Forms.Padding(2);
this.panelChoices.Name = "panelChoices";
this.panelChoices.Size = new System.Drawing.Size(59, 300);
this.panelChoices.TabIndex = 2;
@ -393,7 +400,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.lbMessages.FormattingEnabled = true;
this.lbMessages.Location = new System.Drawing.Point(74, 331);
this.lbMessages.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.lbMessages.Margin = new System.Windows.Forms.Padding(2);
this.lbMessages.Name = "lbMessages";
this.lbMessages.Size = new System.Drawing.Size(366, 43);
this.lbMessages.TabIndex = 3;
@ -418,7 +425,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.pbNetworkView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pbNetworkView.Location = new System.Drawing.Point(74, 25);
this.pbNetworkView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.pbNetworkView.Margin = new System.Windows.Forms.Padding(2);
this.pbNetworkView.Name = "pbNetworkView";
this.pbNetworkView.Size = new System.Drawing.Size(366, 300);
this.pbNetworkView.TabIndex = 1;
@ -433,7 +440,7 @@
//
this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnHelp.Location = new System.Drawing.Point(2, 2);
this.btnHelp.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnHelp.Margin = new System.Windows.Forms.Padding(2);
this.btnHelp.Name = "btnHelp";
this.btnHelp.Size = new System.Drawing.Size(21, 20);
this.btnHelp.TabIndex = 5;
@ -445,10 +452,10 @@
//
this.rbHelp4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rbHelp4.AutoSize = true;
this.rbHelp4.Location = new System.Drawing.Point(8, 28);
this.rbHelp4.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.rbHelp4.Location = new System.Drawing.Point(5, 28);
this.rbHelp4.Margin = new System.Windows.Forms.Padding(2);
this.rbHelp4.Name = "rbHelp4";
this.rbHelp4.Size = new System.Drawing.Size(14, 13);
this.rbHelp4.Size = new System.Drawing.Size(17, 16);
this.rbHelp4.TabIndex = 6;
this.rbHelp4.UseVisualStyleBackColor = true;
this.rbHelp4.CheckedChanged += new System.EventHandler(this.rbHelp4_CheckedChanged);
@ -457,10 +464,10 @@
//
this.rbHelp3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rbHelp3.AutoSize = true;
this.rbHelp3.Location = new System.Drawing.Point(8, 44);
this.rbHelp3.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.rbHelp3.Location = new System.Drawing.Point(5, 44);
this.rbHelp3.Margin = new System.Windows.Forms.Padding(2);
this.rbHelp3.Name = "rbHelp3";
this.rbHelp3.Size = new System.Drawing.Size(14, 13);
this.rbHelp3.Size = new System.Drawing.Size(17, 16);
this.rbHelp3.TabIndex = 7;
this.rbHelp3.UseVisualStyleBackColor = true;
this.rbHelp3.CheckedChanged += new System.EventHandler(this.rbHelp3_CheckedChanged);
@ -469,10 +476,10 @@
//
this.rbHelp2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rbHelp2.AutoSize = true;
this.rbHelp2.Location = new System.Drawing.Point(8, 62);
this.rbHelp2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.rbHelp2.Location = new System.Drawing.Point(5, 62);
this.rbHelp2.Margin = new System.Windows.Forms.Padding(2);
this.rbHelp2.Name = "rbHelp2";
this.rbHelp2.Size = new System.Drawing.Size(14, 13);
this.rbHelp2.Size = new System.Drawing.Size(17, 16);
this.rbHelp2.TabIndex = 8;
this.rbHelp2.UseVisualStyleBackColor = true;
this.rbHelp2.CheckedChanged += new System.EventHandler(this.rbHelp2_CheckedChanged);
@ -482,10 +489,10 @@
this.rbHelp1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rbHelp1.AutoSize = true;
this.rbHelp1.Checked = true;
this.rbHelp1.Location = new System.Drawing.Point(8, 80);
this.rbHelp1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.rbHelp1.Location = new System.Drawing.Point(5, 80);
this.rbHelp1.Margin = new System.Windows.Forms.Padding(2);
this.rbHelp1.Name = "rbHelp1";
this.rbHelp1.Size = new System.Drawing.Size(14, 13);
this.rbHelp1.Size = new System.Drawing.Size(17, 16);
this.rbHelp1.TabIndex = 9;
this.rbHelp1.TabStop = true;
this.rbHelp1.UseVisualStyleBackColor = true;
@ -500,28 +507,21 @@
this.HelpPanel.Controls.Add(this.rbHelp3);
this.HelpPanel.Controls.Add(this.rbHelp2);
this.HelpPanel.Location = new System.Drawing.Point(438, 25);
this.HelpPanel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.HelpPanel.Margin = new System.Windows.Forms.Padding(2);
this.HelpPanel.Name = "HelpPanel";
this.HelpPanel.Size = new System.Drawing.Size(25, 98);
this.HelpPanel.Size = new System.Drawing.Size(25, 300);
this.HelpPanel.TabIndex = 10;
//
// myProgressBar
//
this.myProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.myProgressBar.Location = new System.Drawing.Point(10, 330);
this.myProgressBar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.myProgressBar.Margin = new System.Windows.Forms.Padding(2);
this.myProgressBar.Name = "myProgressBar";
this.myProgressBar.Size = new System.Drawing.Size(59, 19);
this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.myProgressBar.TabIndex = 11;
//
// changeLanguageToolStripMenuItem
//
this.changeLanguageToolStripMenuItem.Name = "changeLanguageToolStripMenuItem";
this.changeLanguageToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.changeLanguageToolStripMenuItem.Text = "Change Language";
this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.changeLanguageToolStripMenuItem_Click);
//
// BuilderWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -536,7 +536,7 @@
this.Controls.Add(this.HelpPanel);
this.Icon = global::EduNetworkBuilder.Properties.Resources.NBIco;
this.MainMenuStrip = this.msMainMenuStrip;
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "BuilderWindow";
this.Text = "Network Builder";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BuilderWindow_FormClosing);

View File

@ -35,6 +35,7 @@ namespace EduNetworkBuilder
private ResourceManager LanguageResources = null;
private CultureInfo LanguageCulture = null;
public string ChosenLanguage = "en"; //The language to try to load
private List<Control> HelpTopicButtons = new List<Control>();
public BuilderWindow()
{
@ -151,6 +152,7 @@ namespace EduNetworkBuilder
CultureInfo CI = GetCulture();
string answer;
answer = RM.GetString(Key, CI);
if (answer == null) return "";
return answer;
}
@ -164,6 +166,77 @@ namespace EduNetworkBuilder
//MessageBox.Show(e.KeyCode.ToString());
}
/// <summary>
/// Return the control with the given name. Used primarily to color help buttons
/// </summary>
/// <param name="Name">The name of the control to search for</param>
/// <returns>The control, or null if no control is found</returns>
public Control GetControlNamed(string Name)
{
Control[] tList = Controls.Find(Name, true);
if (tList.Count() > 0) return tList[0]; //return the first one
return null; //return nothing
}
private void UpdateHelpTopicButtons()
{
Button tButton;
this.SuspendLayout();
foreach(Control tCont in HelpTopicButtons)
{
tCont.Click -= btnRead_Click;
Controls.Remove(tCont); //remove them all
HelpPanel.Controls.Remove(tCont); //Remove from the panel
tCont.Dispose();
}
HelpTopicButtons.Clear(); //They are all gone.
//Make a bunch of new buttons.
int count=0;
int offset = btnHelp.Height + 3;
foreach (HelpTopics HT in myNetwork.SuggestedReadings)
{
tButton = new Button();
tButton.Location = new Point(btnHelp.Location.X, rbHelp1.Location.Y + rbHelp1.Height + 5 + (offset * count));
tButton.Text = (count + 1).ToString();
tButton.Width = btnHelp.Width;
tButton.Height = btnHelp.Height;
tButton.Click += btnRead_Click;
tButton.Name = HT.ToString();
HelpPanel.Controls.Add(tButton);
myTooltip.SetToolTip(tButton, NB.Translate("_ReadContext") + " " + NB.Translate(NB.GetHelpTopicTitle(HT)));
HelpTopicButtons.Add(tButton);
count++;
}
foreach(NetTest nt in myNetwork.NetTests)
{
if(nt.TheTest == NetTestType.ReadContextHelp)
{
nt.ColorItemsIfNeeded(true);
}
}
this.ResumeLayout();
}
/// <summary>
/// Called by the context_read clicks
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRead_Click(object sender, EventArgs e)
{
Button me = (Button)sender;
HelpTopics HT = NB.TryParseEnum<HelpTopics>(me.Name, HelpTopics.None);
if(HT != HelpTopics.None)
{
myNetwork.NoteActionDone(NetTestType.ReadContextHelp, me.Name, "Read");
NB.ReadContextHelp(HT);
}
UpdateHelpTopicButtons();
UpdateForm();
UpdateMenu();
}
private void myTooltip_Popup(Object sender, PopupEventArgs e)
{
//In case we have a puzzle we are trying to solve
@ -309,6 +382,7 @@ namespace EduNetworkBuilder
rbHelp1.Checked = true;
break;
}
UpdateHelpTopicButtons();
processing = false;
}

View File

@ -225,6 +225,11 @@ namespace EduNetworkBuilder
private void lbTags_Read_Click(object sender, EventArgs e)
{
//We need to add this.
HelpTopics HT = HelpTopics.None;
if (lbTags.SelectedIndex >= lbTags.Items.Count) return;
if (lbTags.SelectedIndex < 0) return;
HT = NB.TryParseEnum(lbTags.SelectedItem.ToString(), HelpTopics.None);
NB.ReadContextHelp(HT);
}
private void lbTags_Delete_Click(object sender, EventArgs e)

View File

@ -61,6 +61,22 @@ namespace EduNetworkBuilder
LanguagifyComponents();
string currentDir = Directory.GetCurrentDirectory();
string myRTF;
Form myWin = null;
myWin = Application.OpenForms["RTFWindow"];
if (myWin == null)
{
myWin = Application.OpenForms["BuilderWindow"];
}
if (myWin != null)
{
StartPosition = FormStartPosition.Manual;
Point newlocation = new Point(myWin.Location.X + myWin.Width + 5, myWin.Location.Y);
if (newlocation.X > (Screen.PrimaryScreen.Bounds.Width + 5))
{
newlocation = new Point(Screen.PrimaryScreen.Bounds.Width - 5, newlocation.Y);
}
Location = newlocation;
}
if (WhatToShow == RTFWindowContents.help)
{
myRTF = Properties.Resources.Help;
@ -78,6 +94,20 @@ namespace EduNetworkBuilder
}
}
public void JumpToSelection(string WhatToFind)
{
int indexToText = rtbContent.Find(WhatToFind);
if (indexToText > 0)
{
rtbContent.SelectionStart = indexToText;
rtbContent.ScrollToCaret();
}
}
public void JumpToSelection(HelpTopics WhatToFind)
{
string toFind = NB.Translate(NB.GetHelpTopicKey(WhatToFind));
JumpToSelection(toFind);
}
private void LanguagifyComponents()
{
Text = NB.Translate("RTFW_rtbContent");

View File

@ -693,4 +693,8 @@
<value>When To Subnet</value>
<comment>Text used in the program on buttons and the like</comment>
</data>
<data name="_ReadContext" xml:space="preserve">
<value>Read Context Help for:</value>
<comment>Generic statement used many places</comment>
</data>
</root>