Add drop-down menu item that shows up when we are in replay mode for the regression testing window

This commit is contained in:
Tim Young 2018-09-21 09:58:22 -05:00
parent 64b9f558c4
commit fcde8a1c5b
3 changed files with 182 additions and 150 deletions

View File

@ -111,6 +111,7 @@ namespace EduNetworkBuilder
} }
if(mode == LBContents.regressiontest) if(mode == LBContents.regressiontest)
{ {
MyMode = LBContents.regressiontest;
//Regression testing. Similar to listing all the puzzles. //Regression testing. Similar to listing all the puzzles.
Text = NB.Translate("LBW_Regression_Testing"); //Regression Testing Text = NB.Translate("LBW_Regression_Testing"); //Regression Testing
// //

View File

@ -37,6 +37,8 @@
this.logoutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.logoutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.replayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.replayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.storeReplayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveReplayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -65,6 +67,7 @@
this.solvedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.solvedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toSolveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toSolveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.randomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.randomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.regressionTestingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panelChoices = new System.Windows.Forms.Panel(); this.panelChoices = new System.Windows.Forms.Panel();
this.lbMessages = new System.Windows.Forms.ListBox(); this.lbMessages = new System.Windows.Forms.ListBox();
this.lblStatus = new System.Windows.Forms.Label(); this.lblStatus = new System.Windows.Forms.Label();
@ -79,8 +82,6 @@
this.myProgressBar = new System.Windows.Forms.ProgressBar(); this.myProgressBar = new System.Windows.Forms.ProgressBar();
this.cbLineColor = new System.Windows.Forms.ComboBox(); this.cbLineColor = new System.Windows.Forms.ComboBox();
this.cbFillColor = new System.Windows.Forms.ComboBox(); this.cbFillColor = new System.Windows.Forms.ComboBox();
this.storeReplayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveReplayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.msMainMenuStrip.SuspendLayout(); this.msMainMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit();
this.HelpPanel.SuspendLayout(); this.HelpPanel.SuspendLayout();
@ -168,6 +169,20 @@
this.replayToolStripMenuItem.Text = "Replay"; this.replayToolStripMenuItem.Text = "Replay";
this.replayToolStripMenuItem.Click += new System.EventHandler(this.replayToolStripMenuItem_Click); this.replayToolStripMenuItem.Click += new System.EventHandler(this.replayToolStripMenuItem_Click);
// //
// storeReplayToolStripMenuItem
//
this.storeReplayToolStripMenuItem.Name = "storeReplayToolStripMenuItem";
this.storeReplayToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
this.storeReplayToolStripMenuItem.Text = "Store Replay";
this.storeReplayToolStripMenuItem.Click += new System.EventHandler(this.storeReplayToolStripMenuItem_Click);
//
// saveReplayToolStripMenuItem
//
this.saveReplayToolStripMenuItem.Name = "saveReplayToolStripMenuItem";
this.saveReplayToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
this.saveReplayToolStripMenuItem.Text = "Save Replay";
this.saveReplayToolStripMenuItem.Click += new System.EventHandler(this.saveReplayToolStripMenuItem_Click);
//
// editToolStripMenuItem // editToolStripMenuItem
// //
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -350,37 +365,46 @@
this.puzzlesToolStripMenuItem, this.puzzlesToolStripMenuItem,
this.solvedToolStripMenuItem, this.solvedToolStripMenuItem,
this.toSolveToolStripMenuItem, this.toSolveToolStripMenuItem,
this.randomToolStripMenuItem}); this.randomToolStripMenuItem,
this.regressionTestingToolStripMenuItem});
this.samplesToolStripMenuItem.Name = "samplesToolStripMenuItem"; this.samplesToolStripMenuItem.Name = "samplesToolStripMenuItem";
this.samplesToolStripMenuItem.Size = new System.Drawing.Size(77, 24); this.samplesToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
this.samplesToolStripMenuItem.Text = "Samples"; this.samplesToolStripMenuItem.Text = "Samples";
this.samplesToolStripMenuItem.DropDownOpening += new System.EventHandler(this.samplesToolStripMenuItem_DropDownOpening);
// //
// puzzlesToolStripMenuItem // puzzlesToolStripMenuItem
// //
this.puzzlesToolStripMenuItem.Name = "puzzlesToolStripMenuItem"; this.puzzlesToolStripMenuItem.Name = "puzzlesToolStripMenuItem";
this.puzzlesToolStripMenuItem.Size = new System.Drawing.Size(140, 26); this.puzzlesToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.puzzlesToolStripMenuItem.Text = "Puzzles"; this.puzzlesToolStripMenuItem.Text = "Puzzles";
this.puzzlesToolStripMenuItem.Click += new System.EventHandler(this.puzzlesToolStripMenuItem_Click); this.puzzlesToolStripMenuItem.Click += new System.EventHandler(this.puzzlesToolStripMenuItem_Click);
// //
// solvedToolStripMenuItem // solvedToolStripMenuItem
// //
this.solvedToolStripMenuItem.Name = "solvedToolStripMenuItem"; this.solvedToolStripMenuItem.Name = "solvedToolStripMenuItem";
this.solvedToolStripMenuItem.Size = new System.Drawing.Size(140, 26); this.solvedToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.solvedToolStripMenuItem.Text = "Solved"; this.solvedToolStripMenuItem.Text = "Solved";
// //
// toSolveToolStripMenuItem // toSolveToolStripMenuItem
// //
this.toSolveToolStripMenuItem.Name = "toSolveToolStripMenuItem"; this.toSolveToolStripMenuItem.Name = "toSolveToolStripMenuItem";
this.toSolveToolStripMenuItem.Size = new System.Drawing.Size(140, 26); this.toSolveToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.toSolveToolStripMenuItem.Text = "To Solve"; this.toSolveToolStripMenuItem.Text = "To Solve";
// //
// randomToolStripMenuItem // randomToolStripMenuItem
// //
this.randomToolStripMenuItem.Name = "randomToolStripMenuItem"; this.randomToolStripMenuItem.Name = "randomToolStripMenuItem";
this.randomToolStripMenuItem.Size = new System.Drawing.Size(140, 26); this.randomToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.randomToolStripMenuItem.Text = "Random"; this.randomToolStripMenuItem.Text = "Random";
this.randomToolStripMenuItem.Click += new System.EventHandler(this.randomToolStripMenuItem_Click); this.randomToolStripMenuItem.Click += new System.EventHandler(this.randomToolStripMenuItem_Click);
// //
// regressionTestingToolStripMenuItem
//
this.regressionTestingToolStripMenuItem.Name = "regressionTestingToolStripMenuItem";
this.regressionTestingToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.regressionTestingToolStripMenuItem.Text = "Regression Testing";
this.regressionTestingToolStripMenuItem.Click += new System.EventHandler(this.regressionTestingToolStripMenuItem_Click);
//
// panelChoices // panelChoices
// //
this.panelChoices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.panelChoices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -547,20 +571,6 @@
this.cbFillColor.Size = new System.Drawing.Size(80, 24); this.cbFillColor.Size = new System.Drawing.Size(80, 24);
this.cbFillColor.TabIndex = 13; this.cbFillColor.TabIndex = 13;
// //
// storeReplayToolStripMenuItem
//
this.storeReplayToolStripMenuItem.Name = "storeReplayToolStripMenuItem";
this.storeReplayToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
this.storeReplayToolStripMenuItem.Text = "Store Replay";
this.storeReplayToolStripMenuItem.Click += new System.EventHandler(this.storeReplayToolStripMenuItem_Click);
//
// saveReplayToolStripMenuItem
//
this.saveReplayToolStripMenuItem.Name = "saveReplayToolStripMenuItem";
this.saveReplayToolStripMenuItem.Size = new System.Drawing.Size(181, 26);
this.saveReplayToolStripMenuItem.Text = "Save Replay";
this.saveReplayToolStripMenuItem.Click += new System.EventHandler(this.saveReplayToolStripMenuItem_Click);
//
// BuilderWindow // BuilderWindow
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@ -651,6 +661,7 @@
private System.Windows.Forms.ToolStripMenuItem replayToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem replayToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem storeReplayToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem storeReplayToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveReplayToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveReplayToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem regressionTestingToolStripMenuItem;
} }
} }

View File

@ -21,9 +21,9 @@ namespace EduNetworkBuilder
public Random GameRandomGen = new Random(); public Random GameRandomGen = new Random();
public NBSettings OurSettings = new NBSettings(NB.IsRunningOnMono()); //This will auto-load the settings public NBSettings OurSettings = new NBSettings(NB.IsRunningOnMono()); //This will auto-load the settings
private int LastPacketID=1; private int LastPacketID = 1;
public DebugPausePoint DebugSetting = DebugPausePoint.none; public DebugPausePoint DebugSetting = DebugPausePoint.none;
// public DebugPausePoint DebugSetting = DebugPausePoint.all | DebugPausePoint.dump; // public DebugPausePoint DebugSetting = DebugPausePoint.all | DebugPausePoint.dump;
public Network myNetwork = new Network(""); public Network myNetwork = new Network("");
private Network InvisibleNetwork = null; private Network InvisibleNetwork = null;
private List<Control> Buttons = new List<Control>(); private List<Control> Buttons = new List<Control>();
@ -64,7 +64,7 @@ namespace EduNetworkBuilder
private List<Network> storedNetworkStates = new List<Network>(); //for ctrl-z going back in time to past state private List<Network> storedNetworkStates = new List<Network>(); //for ctrl-z going back in time to past state
private List<Network> ForwardstoredNetworkStates = new List<Network>(); //for ctrl-y going forward to a ctrl-y state private List<Network> ForwardstoredNetworkStates = new List<Network>(); //for ctrl-y going forward to a ctrl-y state
public BuilderWindow(string FirstArg="") public BuilderWindow(string FirstArg = "")
{ {
InitializeComponent(); InitializeComponent();
@ -74,7 +74,7 @@ namespace EduNetworkBuilder
HelpURLs = NB.LoadObjectFromXmlFile<List<HelpURL>>("URLs"); HelpURLs = NB.LoadObjectFromXmlFile<List<HelpURL>>("URLs");
if(!OurSettings.LanguageHasBeenChosen) if (!OurSettings.LanguageHasBeenChosen)
NB.ChangeLanguage(OurSettings); NB.ChangeLanguage(OurSettings);
LanguagifyComponents(); LanguagifyComponents();
//I never implimented cut/copy/paste/undo. So we will remove them since they do nothing anyway //I never implimented cut/copy/paste/undo. So we will remove them since they do nothing anyway
@ -107,7 +107,7 @@ namespace EduNetworkBuilder
ColorNames.Sort(); ColorNames.Sort();
cbFillColor.Items.Clear(); cbFillColor.Items.Clear();
cbLineColor.Items.Clear(); cbLineColor.Items.Clear();
foreach(string ColorName in ColorNames) foreach (string ColorName in ColorNames)
{ {
cbFillColor.Items.Add(ColorName); cbFillColor.Items.Add(ColorName);
cbLineColor.Items.Add(ColorName); cbLineColor.Items.Add(ColorName);
@ -129,7 +129,7 @@ namespace EduNetworkBuilder
KeyPreview = true; KeyPreview = true;
CreateSolvedUnsolvedToolstripItems(); CreateSolvedUnsolvedToolstripItems();
LoadPuzzleInfo(); LoadPuzzleInfo();
} }
private void Tick(object sender, EventArgs e) private void Tick(object sender, EventArgs e)
@ -141,7 +141,7 @@ namespace EduNetworkBuilder
} }
myNetwork.Tick(false); myNetwork.Tick(false);
} }
private void LanguagifyComponents() private void LanguagifyComponents()
{ {
msMainMenuStrip.Text = NB.Translate("NB_msMainMenuStrip", OurSettings); msMainMenuStrip.Text = NB.Translate("NB_msMainMenuStrip", OurSettings);
@ -179,13 +179,13 @@ namespace EduNetworkBuilder
submitHomeworkToolStripMenuItem.Text = NB.Translate("NB_SubmitClasswork"); submitHomeworkToolStripMenuItem.Text = NB.Translate("NB_SubmitClasswork");
updateClassworkToolStripMenuItem.Text = NB.Translate("NB_UpdateClasswork"); updateClassworkToolStripMenuItem.Text = NB.Translate("NB_UpdateClasswork");
markAsGradedToolStripMenuItem.Text = NB.Translate("NB_MarkGraded"); markAsGradedToolStripMenuItem.Text = NB.Translate("NB_MarkGraded");
Text = NB.Translate("NB_Form", OurSettings); Text = NB.Translate("NB_Form", OurSettings);
} }
public ResourceManager GetResource() public ResourceManager GetResource()
{ {
if(LanguageResources == null) if (LanguageResources == null)
{ {
System.Reflection.Assembly MyAssembly; System.Reflection.Assembly MyAssembly;
MyAssembly = this.GetType().Assembly; MyAssembly = this.GetType().Assembly;
@ -196,7 +196,7 @@ namespace EduNetworkBuilder
public CultureInfo GetCulture() public CultureInfo GetCulture()
{ {
if(LanguageCulture == null) if (LanguageCulture == null)
{ {
string CL = OurSettings.ChosenLanguage; string CL = OurSettings.ChosenLanguage;
if (CL != ChosenLanguage) ChosenLanguage = CL; if (CL != ChosenLanguage) ChosenLanguage = CL;
@ -227,13 +227,13 @@ namespace EduNetworkBuilder
pbNetworkView_Delete_Click(sender, e); pbNetworkView_Delete_Click(sender, e);
ItemClickedOn = null; ItemClickedOn = null;
} }
if(e.KeyCode == Keys.S && e.Modifiers == Keys.Control) if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
{ {
doSave(true); doSave(true);
} }
if (e.KeyCode == Keys.Z && e.Modifiers == Keys.Control) if (e.KeyCode == Keys.Z && e.Modifiers == Keys.Control)
{ {
if(storedNetworkStates.Count > 0) if (storedNetworkStates.Count > 0)
{ {
ForwardstoredNetworkStates.Insert(0, myNetwork);//So we can ctrl-y to this state. Undo the undo ForwardstoredNetworkStates.Insert(0, myNetwork);//So we can ctrl-y to this state. Undo the undo
ChangeToPastState(storedNetworkStates[0]); ChangeToPastState(storedNetworkStates[0]);
@ -256,10 +256,10 @@ namespace EduNetworkBuilder
{ {
if (storedNetworkStates.Count > 0 && toStore.Equals(storedNetworkStates[0])) if (storedNetworkStates.Count > 0 && toStore.Equals(storedNetworkStates[0]))
return; //The states are identical. Do not store this state. return; //The states are identical. Do not store this state.
storedNetworkStates.Insert(0,Network.DeepClone(toStore)); storedNetworkStates.Insert(0, Network.DeepClone(toStore));
ForwardstoredNetworkStates.Clear(); ForwardstoredNetworkStates.Clear();
int maxCount = 30; int maxCount = 30;
if(storedNetworkStates.Count > maxCount) if (storedNetworkStates.Count > maxCount)
{ {
storedNetworkStates.RemoveRange(maxCount, storedNetworkStates.Count - maxCount); storedNetworkStates.RemoveRange(maxCount, storedNetworkStates.Count - maxCount);
} }
@ -302,7 +302,7 @@ namespace EduNetworkBuilder
/// <returns>The control, or null if no control is found</returns> /// <returns>The control, or null if no control is found</returns>
public Control GetControlNamed(string Name) public Control GetControlNamed(string Name)
{ {
Control[] tList = Controls.Find(Name, true); Control[] tList = Controls.Find(Name, true);
if (tList.Count() > 0) return tList[0]; //return the first one if (tList.Count() > 0) return tList[0]; //return the first one
return null; //return nothing return null; //return nothing
} }
@ -311,7 +311,7 @@ namespace EduNetworkBuilder
{ {
Button tButton; Button tButton;
this.SuspendLayout(); this.SuspendLayout();
foreach(Control tCont in HelpTopicButtons) foreach (Control tCont in HelpTopicButtons)
{ {
tCont.Click -= btnRead_Click; tCont.Click -= btnRead_Click;
Controls.Remove(tCont); //remove them all Controls.Remove(tCont); //remove them all
@ -321,7 +321,7 @@ namespace EduNetworkBuilder
HelpTopicButtons.Clear(); //They are all gone. HelpTopicButtons.Clear(); //They are all gone.
//Make a bunch of new buttons. //Make a bunch of new buttons.
int count=0; int count = 0;
int offset = btnHelp.Height + 3; int offset = btnHelp.Height + 3;
if (myNetwork.NetURL.GetText() != "") if (myNetwork.NetURL.GetText() != "")
{ {
@ -350,7 +350,7 @@ namespace EduNetworkBuilder
tButton.Height = btnHelp.Height; tButton.Height = btnHelp.Height;
tButton.Click += btnRead_Click; tButton.Click += btnRead_Click;
tButton.Name = HT.ToString(); tButton.Name = HT.ToString();
if(URL != "") if (URL != "")
{ {
//We have a URL for this. //We have a URL for this.
tButton.BackgroundImage = Properties.Resources.VidImage; tButton.BackgroundImage = Properties.Resources.VidImage;
@ -366,9 +366,9 @@ namespace EduNetworkBuilder
HelpTopicButtons.Add(tButton); HelpTopicButtons.Add(tButton);
count++; count++;
} }
foreach(NetTest nt in myNetwork.NetTests) foreach (NetTest nt in myNetwork.NetTests)
{ {
if(nt.TheTest == NetTestType.ReadContextHelp) if (nt.TheTest == NetTestType.ReadContextHelp)
{ {
nt.ColorItemsIfNeeded(true); nt.ColorItemsIfNeeded(true);
} }
@ -376,13 +376,13 @@ namespace EduNetworkBuilder
this.ResumeLayout(); this.ResumeLayout();
} }
string URLFromHelpTopic(HelpTopics what, string lang="") string URLFromHelpTopic(HelpTopics what, string lang = "")
{ {
string topic = what.ToString(); string topic = what.ToString();
if (lang == "") lang = ChosenLanguage; if (lang == "") lang = ChosenLanguage;
foreach(HelpURL one in HelpURLs) foreach (HelpURL one in HelpURLs)
{ {
if(one.HelpTopicString == topic && one.LangTag == lang) if (one.HelpTopicString == topic && one.LangTag == lang)
{ {
return one.URL; return one.URL;
} }
@ -433,7 +433,7 @@ namespace EduNetworkBuilder
} }
} }
private void myTooltip_Popup(Object sender, PopupEventArgs e) private void myTooltip_Popup(Object sender, PopupEventArgs e)
{ {
@ -502,7 +502,7 @@ namespace EduNetworkBuilder
int x, y; int x, y;
foreach (Button btn in Buttons) foreach (Button btn in Buttons)
{ {
if(what.Contains(btn.Name)) if (what.Contains(btn.Name))
{ {
x = (count % 2) * size; x = (count % 2) * size;
y = (count / 2) * size; y = (count / 2) * size;
@ -510,7 +510,7 @@ namespace EduNetworkBuilder
btn.Visible = true; btn.Visible = true;
count++; count++;
} }
} }
} }
@ -523,9 +523,9 @@ namespace EduNetworkBuilder
{ {
lbMessages.Items.Add(msg); lbMessages.Items.Add(msg);
} }
if(lbMessages.Items.Count > 0) if (lbMessages.Items.Count > 0)
lbMessages.SelectedIndex = lbMessages.Items.Count-1; lbMessages.SelectedIndex = lbMessages.Items.Count - 1;
} }
@ -562,7 +562,7 @@ namespace EduNetworkBuilder
updateClassworkToolStripMenuItem.Visible = false; updateClassworkToolStripMenuItem.Visible = false;
} }
markAsGradedToolStripMenuItem.Visible = false; markAsGradedToolStripMenuItem.Visible = false;
if(CurrentUser != null) if (CurrentUser != null)
{ {
if (CurrentUser.isAdmin) if (CurrentUser.isAdmin)
{ {
@ -593,7 +593,7 @@ namespace EduNetworkBuilder
List<string> tLoadList = new List<string>(); List<string> tLoadList = new List<string>();
loadToolStripMenuItem.DropDownItems.Clear(); loadToolStripMenuItem.DropDownItems.Clear();
if(OurSettings != null) if (OurSettings != null)
{ {
foreach (string one in OurSettings.GetRecentFiles()) foreach (string one in OurSettings.GetRecentFiles())
{ {
@ -670,7 +670,7 @@ namespace EduNetworkBuilder
rbHelp3.Visible = false; rbHelp3.Visible = false;
rbHelp4.Visible = false; rbHelp4.Visible = false;
} }
switch(myNetwork.HintsToDisplay) switch (myNetwork.HintsToDisplay)
{ {
case NetTestVerbosity.full: case NetTestVerbosity.full:
rbHelp4.Checked = true; rbHelp4.Checked = true;
@ -686,20 +686,20 @@ namespace EduNetworkBuilder
break; break;
} }
UpdateHelpTopicButtons(); UpdateHelpTopicButtons();
processing = false; processing = false;
} }
private void LayoutButtons() private void LayoutButtons()
{ {
List<string> what = new List<string>(); List<string> what = new List<string>();
foreach(Button btn in Buttons) foreach (Button btn in Buttons)
{ {
what.Add(btn.Name); what.Add(btn.Name);
} }
LayoutButtons(what); LayoutButtons(what);
} }
private void LoadPuzzleInfo() private void LoadPuzzleInfo()
{ {
XmlDocument xmlDoc = new XmlDocument(); XmlDocument xmlDoc = new XmlDocument();
@ -716,7 +716,7 @@ namespace EduNetworkBuilder
foreach (string str in Enum.GetNames(typeof(PuzzleNames))) foreach (string str in Enum.GetNames(typeof(PuzzleNames)))
{ {
byte[] item = (byte[])myManager.GetObject(str); byte[] item = (byte[])myManager.GetObject(str);
if(item == null) if (item == null)
{ {
MessageBox.Show(String.Format(NB.Translate("NB_LoadPuzInfo"), str)); MessageBox.Show(String.Format(NB.Translate("NB_LoadPuzInfo"), str));
continue; continue;
@ -729,22 +729,22 @@ namespace EduNetworkBuilder
PuzzleList.Add(newPuzzle); PuzzleList.Add(newPuzzle);
//Console.WriteLine("Puzzle: " + str + " " + newPuzzle.PuzzleTitle); //Console.WriteLine("Puzzle: " + str + " " + newPuzzle.PuzzleTitle);
} }
PuzzleList = PuzzleList.OrderBy( c=> c.Level).ThenBy(c => c.SortOrder).ThenBy(c=> c.PuzzleName).ToList(); PuzzleList = PuzzleList.OrderBy(c => c.Level).ThenBy(c => c.SortOrder).ThenBy(c => c.PuzzleName).ToList();
} }
public PuzzleInfo PuzzleInfoFromName(string PuzzleName) public PuzzleInfo PuzzleInfoFromName(string PuzzleName)
{ {
foreach(PuzzleInfo pi in PuzzleList) foreach (PuzzleInfo pi in PuzzleList)
{ {
if (pi.PuzzleName == PuzzleName) if (pi.PuzzleName == PuzzleName)
return pi; return pi;
} }
return null; return null;
} }
public bool PuzzleLevelHasUnsolved(string LevelName) public bool PuzzleLevelHasUnsolved(string LevelName)
{ {
foreach (PuzzleInfo pi in PuzzleList) foreach (PuzzleInfo pi in PuzzleList)
{ {
if ("Level_" + pi.Level.ToString() == LevelName) if ("Level_" + pi.Level.ToString() == LevelName)
@ -769,11 +769,11 @@ namespace EduNetworkBuilder
List<string> LevelTags = new List<string>(); List<string> LevelTags = new List<string>();
foreach (PuzzleInfo pi in PuzzleList) foreach (PuzzleInfo pi in PuzzleList)
{ {
foreach(string str in pi.PuzzleTags) foreach (string str in pi.PuzzleTags)
{ {
//string What = NB.Translate("NB_Level"); //string What = NB.Translate("NB_Level");
string What = "^Level"; string What = "^Level";
if (Regex.IsMatch(str,What)) if (Regex.IsMatch(str, What))
{ {
if (!LevelTags.Contains(str, StringComparer.OrdinalIgnoreCase)) if (!LevelTags.Contains(str, StringComparer.OrdinalIgnoreCase))
LevelTags.Add(str); LevelTags.Add(str);
@ -805,19 +805,20 @@ namespace EduNetworkBuilder
{ {
bool doupdate = false; bool doupdate = false;
if (selectedButton == "btnShapes") doupdate = true; if (selectedButton == "btnShapes") doupdate = true;
foreach(Control btn in Buttons) foreach (Control btn in Buttons)
{ {
if(btn == sender) if (btn == sender)
{ {
//This is the selected item //This is the selected item
btn.BackColor = Color.LightGreen; btn.BackColor = Color.LightGreen;
selectedButton = btn.Name; selectedButton = btn.Name;
lblStatus.Text = myTooltip.GetToolTip(btn); lblStatus.Text = myTooltip.GetToolTip(btn);
myNetwork.InShapeEditMode = true; myNetwork.InShapeEditMode = true;
if (selectedButton == "btnShapes") { if (selectedButton == "btnShapes")
{
myNetwork.InShapeEditMode = true; myNetwork.InShapeEditMode = true;
if (CurrentShape == NetShapeType.none) CurrentShape = NetShapeType.rectangle; if (CurrentShape == NetShapeType.none) CurrentShape = NetShapeType.rectangle;
if(doupdate) if (doupdate)
{ {
//The shape was already selected. Toggle it //The shape was already selected. Toggle it
if (CurrentShape == NetShapeType.rectangle) CurrentShape = NetShapeType.circle; if (CurrentShape == NetShapeType.rectangle) CurrentShape = NetShapeType.circle;
@ -838,7 +839,8 @@ namespace EduNetworkBuilder
btn.BackColor = Button.DefaultBackColor; btn.BackColor = Button.DefaultBackColor;
} }
} }
if (doupdate) { if (doupdate)
{
UpdateForm(); UpdateForm();
} }
} }
@ -851,8 +853,8 @@ namespace EduNetworkBuilder
selectedButton = ""; selectedButton = "";
CurrentShape = NetShapeType.none; CurrentShape = NetShapeType.none;
btn.BackColor = Button.DefaultBackColor; btn.BackColor = Button.DefaultBackColor;
if(btn.Name == "btnShapes") if (btn.Name == "btnShapes")
{ {
if (CurrentShape == NetShapeType.rectangle) btn.BackgroundImage = Properties.Resources.Square; if (CurrentShape == NetShapeType.rectangle) btn.BackgroundImage = Properties.Resources.Square;
if (CurrentShape == NetShapeType.circle) btn.BackgroundImage = Properties.Resources.Circle; if (CurrentShape == NetShapeType.circle) btn.BackgroundImage = Properties.Resources.Circle;
if (CurrentShape == NetShapeType.none) btn.BackgroundImage = Properties.Resources.Shapes; if (CurrentShape == NetShapeType.none) btn.BackgroundImage = Properties.Resources.Shapes;
@ -883,7 +885,7 @@ namespace EduNetworkBuilder
} }
private void pbNetworkView_RightMouseUp(NetworkDevice ReleasedOn, MouseEventArgs e) private void pbNetworkView_RightMouseUp(NetworkDevice ReleasedOn, MouseEventArgs e)
{ {
int index = 0; int index = 0;
bool LockedOut = false; bool LockedOut = false;
bool PoweredOff = false; bool PoweredOff = false;
@ -895,7 +897,7 @@ namespace EduNetworkBuilder
if (ReleasedOn != null) PoweredOff = ReleasedOn.PowerOff; if (ReleasedOn != null) PoweredOff = ReleasedOn.PowerOff;
pbNetworkView.ContextMenuStrip.Items.Clear(); pbNetworkView.ContextMenuStrip.Items.Clear();
if(myNetwork.InShapeEditMode && ShapeForEditing != null) if (myNetwork.InShapeEditMode && ShapeForEditing != null)
{ {
//context menu for shape //context menu for shape
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Delete")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Delete"));
@ -1016,23 +1018,23 @@ namespace EduNetworkBuilder
pbNetworkView.ContextMenuStrip.Items.Add(string.Format(NB.Translate("NB_NetViewRmLnkStr"), host)); pbNetworkView.ContextMenuStrip.Items.Add(string.Format(NB.Translate("NB_NetViewRmLnkStr"), host));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_RemoveLink_Click; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_RemoveLink_Click;
} }
if(ReleasedOn.PowerOff) if (ReleasedOn.PowerOff)
{ {
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOn")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOn"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_PowerOn_Click; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_PowerOn_Click;
} }
else if(ReleasedOn.ForwardsPackets() || ReleasedOn.RoutesPackets()) else if (ReleasedOn.ForwardsPackets() || ReleasedOn.RoutesPackets())
{ {
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOff")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOff"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_PowerOff_Click; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_PowerOff_Click;
} }
if (myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceBlowsUpWithPower) || if (myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceBlowsUpWithPower) ||
myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceNICSprays) || myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceNICSprays) ||
ReleasedOn.IsBurned) ReleasedOn.IsBurned)
{ {
bool toDo = false; bool toDo = false;
if (ReleasedOn.IsBurned) toDo = true; if (ReleasedOn.IsBurned) toDo = true;
if(myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceBlowsUpWithPower)) if (myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceBlowsUpWithPower))
toDo = !myNetwork.ItemTestIsComplete(ReleasedOn.hostname, NetTestType.DeviceBlowsUpWithPower); toDo = !myNetwork.ItemTestIsComplete(ReleasedOn.hostname, NetTestType.DeviceBlowsUpWithPower);
if (myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceNICSprays)) if (myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceNICSprays))
{ {
@ -1063,7 +1065,7 @@ namespace EduNetworkBuilder
pbNetworkView.ContextMenuStrip.Items.Add(string.Format(NB.Translate("NB_Reset"))); pbNetworkView.ContextMenuStrip.Items.Add(string.Format(NB.Translate("NB_Reset")));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Reset_Click; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Reset_Click;
} }
if (ReleasedOn != null && (Form.ModifierKeys & Keys.Control) == Keys.Control ) //We control-click on it if (ReleasedOn != null && (Form.ModifierKeys & Keys.Control) == Keys.Control) //We control-click on it
{ {
int MenuIndex = pbNetworkView.ContextMenuStrip.Items.Count; int MenuIndex = pbNetworkView.ContextMenuStrip.Items.Count;
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_Hide")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_Hide"));
@ -1073,14 +1075,14 @@ namespace EduNetworkBuilder
{ {
int MenuIndex = pbNetworkView.ContextMenuStrip.Items.Count; int MenuIndex = pbNetworkView.ContextMenuStrip.Items.Count;
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_ColorStr")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_ColorStr"));
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Blue"),null, pbNetworkView_Color_Click); (pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Blue"), null, pbNetworkView_Color_Click);
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Purple"), null, pbNetworkView_Color_Click); (pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Purple"), null, pbNetworkView_Color_Click);
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Yellow"), null, pbNetworkView_Color_Click); (pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Yellow"), null, pbNetworkView_Color_Click);
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Green"), null, pbNetworkView_Color_Click); (pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Green"), null, pbNetworkView_Color_Click);
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Orange"), null, pbNetworkView_Color_Click); (pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Orange"), null, pbNetworkView_Color_Click);
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Cyan"), null, pbNetworkView_Color_Click); (pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Cyan"), null, pbNetworkView_Color_Click);
} }
if ((!myNetwork.InShapeEditMode && ReleasedOn == null && ItemsSelected.Count == 0) || (myNetwork.InShapeEditMode && ShapeForEditing == null)) if ((!myNetwork.InShapeEditMode && ReleasedOn == null && ItemsSelected.Count == 0) || (myNetwork.InShapeEditMode && ShapeForEditing == null))
{ {
pbNetworkView.ContextMenuStrip.Visible = false; pbNetworkView.ContextMenuStrip.Visible = false;
} }
@ -1100,7 +1102,7 @@ namespace EduNetworkBuilder
} }
pbNetworkView.ContextMenuStrip.Items.Clear(); pbNetworkView.ContextMenuStrip.Items.Clear();
int index=0; int index = 0;
//We need to make sure the item is not critical before we delete it. //We need to make sure the item is not critical before we delete it.
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Delete")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Delete"));
@ -1145,15 +1147,15 @@ namespace EduNetworkBuilder
bool BlowUpOnce = myNetwork.ItemHasTest(ItemClickedOn.hostname, NetTestType.DeviceBlowsUpWithPower) && !myNetwork.ItemTestIsComplete(ItemClickedOn.hostname, NetTestType.DeviceBlowsUpWithPower); bool BlowUpOnce = myNetwork.ItemHasTest(ItemClickedOn.hostname, NetTestType.DeviceBlowsUpWithPower) && !myNetwork.ItemTestIsComplete(ItemClickedOn.hostname, NetTestType.DeviceBlowsUpWithPower);
bool BlowUpMultiple = myNetwork.ItemHasTest(ItemClickedOn.hostname, NetTestType.DeviceNeedsUPS) && !myNetwork.ItemTestIsComplete(ItemClickedOn.hostname, NetTestType.DeviceNeedsUPS); bool BlowUpMultiple = myNetwork.ItemHasTest(ItemClickedOn.hostname, NetTestType.DeviceNeedsUPS) && !myNetwork.ItemTestIsComplete(ItemClickedOn.hostname, NetTestType.DeviceNeedsUPS);
if (BlowUpOnce || BlowUpMultiple) if (BlowUpOnce || BlowUpMultiple)
{ {
Rectangle Where = new Rectangle(ItemClickedOn.myLocation().X, Rectangle Where = new Rectangle(ItemClickedOn.myLocation().X,
ItemClickedOn.myLocation().Y - ((ItemClickedOn.Size * 2) / 3), ItemClickedOn.Size, ItemClickedOn.Size); ItemClickedOn.myLocation().Y - ((ItemClickedOn.Size * 2) / 3), ItemClickedOn.Size, ItemClickedOn.Size);
if (ItemClickedOn.IsBurned) if (ItemClickedOn.IsBurned)
{ {
int which = GameRandomGen.Next(3); int which = GameRandomGen.Next(3);
if (which == 0) if (which == 0)
myNetwork.AddAnimation(AnimationName.Spark1, Where); myNetwork.AddAnimation(AnimationName.Spark1, Where);
else if(which == 1) else if (which == 1)
myNetwork.AddAnimation(AnimationName.Lightning1, Where); myNetwork.AddAnimation(AnimationName.Lightning1, Where);
else else
myNetwork.AddAnimation(AnimationName.Smoke1, Where); myNetwork.AddAnimation(AnimationName.Smoke1, Where);
@ -1248,9 +1250,9 @@ namespace EduNetworkBuilder
private void pbNetworkView_Color_Click(object sender, EventArgs e) private void pbNetworkView_Color_Click(object sender, EventArgs e)
{ {
ToolStripMenuItem TSMI = (ToolStripMenuItem)sender; ToolStripMenuItem TSMI = (ToolStripMenuItem)sender;
if(ItemsSelected.Count > 0) if (ItemsSelected.Count > 0)
{ {
foreach(NetworkDevice nd in ItemsSelected) foreach (NetworkDevice nd in ItemsSelected)
{ {
ColorizeDevice(nd, TSMI.Text); ColorizeDevice(nd, TSMI.Text);
} }
@ -1390,7 +1392,7 @@ namespace EduNetworkBuilder
private void pbNetworkView_DeleteShape_Click(object sender, EventArgs e) private void pbNetworkView_DeleteShape_Click(object sender, EventArgs e)
{ {
if(ShapeForEditing != null) if (ShapeForEditing != null)
{ {
myNetwork.RemoveShape(ShapeForEditing); myNetwork.RemoveShape(ShapeForEditing);
ShapeForEditing = null; ShapeForEditing = null;
@ -1424,7 +1426,7 @@ namespace EduNetworkBuilder
} }
} }
pbNetworkView.Image = null; pbNetworkView.Image = null;
ItemsSelected.Clear(); ItemsSelected.Clear();
UpdateLinks(); UpdateLinks();
myNetwork.TestForCompletion(true); myNetwork.TestForCompletion(true);
UpdateVisuals(); UpdateVisuals();
@ -1435,8 +1437,8 @@ namespace EduNetworkBuilder
bool todo = true; bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to ping from if (ItemClickedOn == null) return; //we do not have something chosen to ping from
NB_IPAddress destination = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only); NB_IPAddress destination = new NB_IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Ping"),true); todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Ping"), true);
if(todo) if (todo)
{ {
//ItemClickedOn.PingFromHere(destination); //ItemClickedOn.PingFromHere(destination);
NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination); NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination);
@ -1469,7 +1471,7 @@ namespace EduNetworkBuilder
string dest = (string)Pressed.Tag; string dest = (string)Pressed.Tag;
NB_IPAddress destination; NB_IPAddress destination;
destination = myNetwork.DNSLookup(ItemClickedOn, dest); destination = myNetwork.DNSLookup(ItemClickedOn, dest);
if(destination == null || destination.GetIPString == NB.ZeroIPString) if (destination == null || destination.GetIPString == NB.ZeroIPString)
destination = new NB_IPAddress(dest); destination = new NB_IPAddress(dest);
//ItemClickedOn.PingFromHere(destination); //ItemClickedOn.PingFromHere(destination);
NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination); NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination);
@ -1539,9 +1541,9 @@ namespace EduNetworkBuilder
Point ClickLocation = myNetwork.clickedPos(e.Location); Point ClickLocation = myNetwork.clickedPos(e.Location);
NetworkDevice ReleasedOn = myNetwork.ItemAtPosition(ClickLocation); NetworkDevice ReleasedOn = myNetwork.ItemAtPosition(ClickLocation);
NetworkLink ReleasedOnLink = null; NetworkLink ReleasedOnLink = null;
if(ReleasedOn == null && !myNetwork.InShapeEditMode) if (ReleasedOn == null && !myNetwork.InShapeEditMode)
ReleasedOnLink = myNetwork.LinkAtPosition(ClickLocation); ReleasedOnLink = myNetwork.LinkAtPosition(ClickLocation);
LastBackgroundImage = null; LastBackgroundImage = null;
pbNetworkView.Image = null; //erase old highlight area pbNetworkView.Image = null; //erase old highlight area
LastMouseMovePos = new Point(-1, -1); LastMouseMovePos = new Point(-1, -1);
@ -1550,7 +1552,7 @@ namespace EduNetworkBuilder
TimeSpan duration; TimeSpan duration;
duration = DateTime.Now - LastClick; duration = DateTime.Now - LastClick;
if(ReleasedOnLink != null && e.Button == MouseButtons.Right) if (ReleasedOnLink != null && e.Button == MouseButtons.Right)
{ {
//Right-click on a line. Make a special context menu for that. //Right-click on a line. Make a special context menu for that.
// delete // delete
@ -1616,12 +1618,12 @@ namespace EduNetworkBuilder
UpdateVisuals(); UpdateVisuals();
return; return;
} }
if (MouseIsDown && ItemClickedOn == null && (swidth > 4 || sheight>4)) if (MouseIsDown && ItemClickedOn == null && (swidth > 4 || sheight > 4))
{ {
//We just finished dragging a select box //We just finished dragging a select box
//Put them all into the drag box. //Put them all into the drag box.
ItemsSelected.Clear(); ItemsSelected.Clear();
//Now we have a rectangle, but need to exchange numbers for numbers on the image //Now we have a rectangle, but need to exchange numbers for numbers on the image
Point topCorner = myNetwork.clickedPos(new Point(sx, sy)); Point topCorner = myNetwork.clickedPos(new Point(sx, sy));
Point botCorner = myNetwork.clickedPos(new Point(sx + swidth, sy + sheight)); Point botCorner = myNetwork.clickedPos(new Point(sx + swidth, sy + sheight));
@ -1651,11 +1653,11 @@ namespace EduNetworkBuilder
if (LineColor.Name != "Empty" || FillColor.Name != "Empty") if (LineColor.Name != "Empty" || FillColor.Name != "Empty")
{ {
if (ShapeForEditing == null) if (ShapeForEditing == null)
{ {
NetShape NS = new NetShape(CurrentShape, selectbox, FillColor, LineColor); NetShape NS = new NetShape(CurrentShape, selectbox, FillColor, LineColor);
myNetwork.AddShape(NS); myNetwork.AddShape(NS);
UpdateForm(); UpdateForm();
} }
else else
{ {
@ -1819,7 +1821,7 @@ namespace EduNetworkBuilder
{ {
ItemClickedOn = null; ItemClickedOn = null;
ShapeForEditing = myNetwork.ShapeAtPoint(location); ShapeForEditing = myNetwork.ShapeAtPoint(location);
if(ShapeForEditing != null && e.Button == MouseButtons.Left) if (ShapeForEditing != null && e.Button == MouseButtons.Left)
{ {
//we set the drag-point for the opposite corner //we set the drag-point for the opposite corner
ClickedLocation = ShapeForEditing.OppositePoint(location); ClickedLocation = ShapeForEditing.OppositePoint(location);
@ -1829,12 +1831,12 @@ namespace EduNetworkBuilder
cbLineColor.Text = ShapeForEditing.LineColor.Name; cbLineColor.Text = ShapeForEditing.LineColor.Name;
btnUpdateShape(); //Change the shape to what we are editing btnUpdateShape(); //Change the shape to what we are editing
} }
else if(ShapeForEditing != null && e.Button == MouseButtons.Right) else if (ShapeForEditing != null && e.Button == MouseButtons.Right)
{ {
//Right-clicking the shape. Context menu to come at button release! //Right-clicking the shape. Context menu to come at button release!
} }
} }
if(e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
MouseIsDown = true; MouseIsDown = true;
LastMouseDown = DateTime.UtcNow; LastMouseDown = DateTime.UtcNow;
//Make a duplicate of the old background image. //Make a duplicate of the old background image.
@ -1851,7 +1853,7 @@ namespace EduNetworkBuilder
Point oldpoint = toMove.myLocation(); Point oldpoint = toMove.myLocation();
Rectangle oldrec = new Rectangle(oldpoint.X, oldpoint.Y, toMove.Size, toMove.Size); Rectangle oldrec = new Rectangle(oldpoint.X, oldpoint.Y, toMove.Size, toMove.Size);
Graphics.FromImage(pbNetworkView.BackgroundImage).DrawImage(LastBackgroundImage, oldrec, oldrec,GraphicsUnit.Pixel); Graphics.FromImage(pbNetworkView.BackgroundImage).DrawImage(LastBackgroundImage, oldrec, oldrec, GraphicsUnit.Pixel);
myNetwork.Invalidate(oldrec); myNetwork.Invalidate(oldrec);
//set it to the new pos //set it to the new pos
@ -1894,15 +1896,15 @@ namespace EduNetworkBuilder
else if (MouseIsDown && LastBackgroundImage != null && ItemClickedOn != null && ItemsSelected.Count == 0) //We are trying to drag something else if (MouseIsDown && LastBackgroundImage != null && ItemClickedOn != null && ItemsSelected.Count == 0) //We are trying to drag something
{ {
//find where we are //find where we are
TimeSpan HowLong = DateTime.UtcNow - LastMouseDown; TimeSpan HowLong = DateTime.UtcNow - LastMouseDown;
if(HowLong.TotalMilliseconds > 100 && !ItemClickedOn.IsLockedInLocation()) if (HowLong.TotalMilliseconds > 100 && !ItemClickedOn.IsLockedInLocation())
DragItemToNewLocation(ItemClickedOn, CenteredLocation); DragItemToNewLocation(ItemClickedOn, CenteredLocation);
} }
else if (MouseIsDown && ItemsSelected.Count >0) //dragging multiple items around else if (MouseIsDown && ItemsSelected.Count > 0) //dragging multiple items around
{ {
//Track the difference between the last redraw and this re-draw //Track the difference between the last redraw and this re-draw
//Move every item by that amount. //Move every item by that amount.
int xdif = CenteredLocation.X - OrigClickPoint.X ; int xdif = CenteredLocation.X - OrigClickPoint.X;
int ydif = CenteredLocation.Y - OrigClickPoint.Y; int ydif = CenteredLocation.Y - OrigClickPoint.Y;
if (xdif != 0 || ydif != 0) if (xdif != 0 || ydif != 0)
{ {
@ -1926,7 +1928,7 @@ namespace EduNetworkBuilder
int sy; int sy;
int swidth; int swidth;
int sheight; int sheight;
if(ClickedLocation.X > MouseLocation.X ) if (ClickedLocation.X > MouseLocation.X)
{ {
sx = MouseLocation.X; sx = MouseLocation.X;
swidth = ClickedLocation.X - sx; swidth = ClickedLocation.X - sx;
@ -1946,10 +1948,10 @@ namespace EduNetworkBuilder
sy = ClickedLocation.Y; sy = ClickedLocation.Y;
sheight = MouseLocation.Y - sy; sheight = MouseLocation.Y - sy;
} }
Rectangle selectbox = new Rectangle(sx,sy,swidth,sheight); Rectangle selectbox = new Rectangle(sx, sy, swidth, sheight);
Color tColor = Color.LightGreen; Color tColor = Color.LightGreen;
SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(128,tColor.R,tColor.G,tColor.B)); SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(128, tColor.R, tColor.G, tColor.B));
tGraphics.FillRectangle(semiTransBrush, selectbox); tGraphics.FillRectangle(semiTransBrush, selectbox);
pbNetworkView.Image = tImage; pbNetworkView.Image = tImage;
pbNetworkView.Invalidate(); pbNetworkView.Invalidate();
@ -1967,7 +1969,7 @@ namespace EduNetworkBuilder
else else
newtooltip = NB.Translate("NB_LockedOut"); newtooltip = NB.Translate("NB_LockedOut");
} }
if(oldtooltip != newtooltip) if (oldtooltip != newtooltip)
{ {
myTooltip.SetToolTip(pbNetworkView, newtooltip); myTooltip.SetToolTip(pbNetworkView, newtooltip);
} }
@ -1981,7 +1983,7 @@ namespace EduNetworkBuilder
myNetwork.RegisterDisplayArea(pbNetworkView); myNetwork.RegisterDisplayArea(pbNetworkView);
GC.Collect(); GC.Collect();
RTFWindow myWin = (RTFWindow)Application.OpenForms["RTFWindow"]; RTFWindow myWin = (RTFWindow)Application.OpenForms["RTFWindow"];
if (myWin != null) if (myWin != null)
{ {
myWin.Close(); myWin.Close();
} }
@ -2000,7 +2002,7 @@ namespace EduNetworkBuilder
mydialog.AddExtension = true; mydialog.AddExtension = true;
//If we have a user loaded, we can open homework files //If we have a user loaded, we can open homework files
string filter = "EduNet File (*.enbx, *enbu)|*.enbx; *.enbu"; string filter = "EduNet File (*.enbx, *enbu)|*.enbx; *.enbu";
if(NB.GetUser() != null) if (NB.GetUser() != null)
filter = "EduNet File (*.enbx, *enbu, *enbh)|*.enbx; *.enbu; *.enbh"; filter = "EduNet File (*.enbx, *enbu, *enbh)|*.enbx; *.enbu; *.enbh";
mydialog.Filter = filter; mydialog.Filter = filter;
mydialog.Multiselect = false; mydialog.Multiselect = false;
@ -2009,7 +2011,7 @@ namespace EduNetworkBuilder
DialogResult result = mydialog.ShowDialog(); DialogResult result = mydialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel) return; if (result == System.Windows.Forms.DialogResult.Cancel) return;
string extension = Path.GetExtension(mydialog.FileName).ToString(); string extension = Path.GetExtension(mydialog.FileName).ToString();
if(extension != ".enbx" && extension != ".enbu" && extension != ".enbh") if (extension != ".enbx" && extension != ".enbu" && extension != ".enbh")
{ {
MessageBox.Show(NB.Translate("_LoadErr")); MessageBox.Show(NB.Translate("_LoadErr"));
return; return;
@ -2110,10 +2112,10 @@ namespace EduNetworkBuilder
private void lbMessages_DoubleClick(object sender, EventArgs e) private void lbMessages_DoubleClick(object sender, EventArgs e)
{ {
if(lbMessages.SelectedIndex < 0) return; //nothing to do if (lbMessages.SelectedIndex < 0) return; //nothing to do
if(lbMessages.SelectedIndex > myNetwork.CountMessages()) return; //invalid. Do nothing if (lbMessages.SelectedIndex > myNetwork.CountMessages()) return; //invalid. Do nothing
PacketMessage newMessage = myNetwork.GetMessageAtIndex(lbMessages.SelectedIndex); PacketMessage newMessage = myNetwork.GetMessageAtIndex(lbMessages.SelectedIndex);
if(newMessage == null) return; //Not sure how we could get to this, but break out just in case if (newMessage == null) return; //Not sure how we could get to this, but break out just in case
ListBoxWindow newwindow = new ListBoxWindow(newMessage); ListBoxWindow newwindow = new ListBoxWindow(newMessage);
newwindow.ShowDialog(); newwindow.ShowDialog();
} }
@ -2185,7 +2187,7 @@ namespace EduNetworkBuilder
//myString = System.Text.Encoding.Default.GetString(item); //myString = System.Text.Encoding.Default.GetString(item);
xmlDoc.LoadXml(myString); xmlDoc.LoadXml(myString);
PrepForLoad(); PrepForLoad();
myNetwork.Load(xmlDoc,resource, true);//Load it from resource. Set the bool saying it was from resource myNetwork.Load(xmlDoc, resource, true);//Load it from resource. Set the bool saying it was from resource
UpdateMenu(); UpdateMenu();
UpdateForm(); UpdateForm();
} }
@ -2228,10 +2230,10 @@ namespace EduNetworkBuilder
private void CreateSolvedUnsolvedToolstripItems() private void CreateSolvedUnsolvedToolstripItems()
{ {
foreach(SolvedNetworkNames one in Enum.GetValues(typeof(SolvedNetworkNames))) foreach (SolvedNetworkNames one in Enum.GetValues(typeof(SolvedNetworkNames)))
{ {
//add a solved one //add a solved one
ToolStripMenuItem tsmi = new ToolStripMenuItem(NB.Translate("NB_"+one.ToString())); ToolStripMenuItem tsmi = new ToolStripMenuItem(NB.Translate("NB_" + one.ToString()));
tsmi.Name = one.ToString(); tsmi.Name = one.ToString();
tsmi.Click += MenuItemLoadSolved; tsmi.Click += MenuItemLoadSolved;
solvedToolStripMenuItem.DropDownItems.Add(tsmi); solvedToolStripMenuItem.DropDownItems.Add(tsmi);
@ -2266,7 +2268,7 @@ namespace EduNetworkBuilder
OptionsWindow tWindow = new OptionsWindow(myNetwork); OptionsWindow tWindow = new OptionsWindow(myNetwork);
tWindow.ShowDialog(); tWindow.ShowDialog();
myNetwork.UpdateDeviceSizes(); myNetwork.UpdateDeviceSizes();
UpdateForm(); UpdateForm();
} }
@ -2280,7 +2282,7 @@ namespace EduNetworkBuilder
} }
if (!File.Exists(filename)) if (!File.Exists(filename))
{ {
MessageBox.Show(string.Format(NB.Translate("NB_NoSuchFile"),filename)); MessageBox.Show(string.Format(NB.Translate("NB_NoSuchFile"), filename));
//Close(); //Close();
return; return;
} }
@ -2298,7 +2300,7 @@ namespace EduNetworkBuilder
} }
else if (extension == ".enbu") else if (extension == ".enbu")
{ {
if(CurrentUser != null && !CurrentUser.isAdmin) if (CurrentUser != null && !CurrentUser.isAdmin)
{ {
MessageBox.Show(NB.Translate("NB_LogOutFirst")); MessageBox.Show(NB.Translate("NB_LogOutFirst"));
return; return;
@ -2310,14 +2312,14 @@ namespace EduNetworkBuilder
while (counter < 4) while (counter < 4)
{ {
string tPass = ""; string tPass = "";
if(counter > 0) //First try an empty password if (counter > 0) //First try an empty password
tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true); tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true);
string tUserName = Path.GetFileNameWithoutExtension(filename); string tUserName = Path.GetFileNameWithoutExtension(filename);
string PasToUse = tUserName + tPass; string PasToUse = tUserName + tPass;
tUser = PersonClass.TryLoad(filename, PasToUse); tUser = PersonClass.TryLoad(filename, PasToUse);
if (tUser != null) break; if (tUser != null) break;
counter++; counter++;
} }
if (tUser == null) if (tUser == null)
{ {
//failed to load. //failed to load.
@ -2336,17 +2338,17 @@ namespace EduNetworkBuilder
CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu. CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
UpdateMenu(); UpdateMenu();
} }
else if(CurrentUser != null && CurrentUser.isAdmin) else if (CurrentUser != null && CurrentUser.isAdmin)
{ {
//We want to import the student information for this one student //We want to import the student information for this one student
string user = Path.GetFileNameWithoutExtension(filename); string user = Path.GetFileNameWithoutExtension(filename);
//Dig up the corresponding user. //Dig up the corresponding user.
PersonClass CurrentStudentUser = CurrentUser.StudentWithTheUserName(user); PersonClass CurrentStudentUser = CurrentUser.StudentWithTheUserName(user);
if(CurrentStudentUser == null) if (CurrentStudentUser == null)
{ {
//This means we do not have a user with that name in this class. //This means we do not have a user with that name in this class.
//More importantly, we do not have an alt-password set up so we can import them. //More importantly, we do not have an alt-password set up so we can import them.
MessageBox.Show(string.Format(NB.Translate("NB_TeacherUnableToLoadUserNoAcct"),user)); MessageBox.Show(string.Format(NB.Translate("NB_TeacherUnableToLoadUserNoAcct"), user));
return; return;
} }
//Use the alt password for that user to load the file //Use the alt password for that user to load the file
@ -2365,7 +2367,7 @@ namespace EduNetworkBuilder
} }
else if (extension == ".enbh") else if (extension == ".enbh")
{ {
if(NB.GetUser() == null || CurrentUser == null) if (NB.GetUser() == null || CurrentUser == null)
{ {
MessageBox.Show(NB.Translate("NB_LoadUserFirst")); MessageBox.Show(NB.Translate("NB_LoadUserFirst"));
return; return;
@ -2408,8 +2410,8 @@ namespace EduNetworkBuilder
} }
//If we started by clicking on a using a one_click installer, load that file //If we started by clicking on a using a one_click installer, load that file
if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null && if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null &&
AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &&
AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Any()) AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Any())
{ {
string[] activationData = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData; string[] activationData = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
@ -2424,7 +2426,7 @@ namespace EduNetworkBuilder
} }
} }
if (InitialFileLoad != "") //This is set when we are installed by msi and we click a file if (InitialFileLoad != "") //This is set when we are installed by msi and we click a file
{ {
if (File.Exists(InitialFileLoad)) if (File.Exists(InitialFileLoad))
{ {
LoadInitialFile(InitialFileLoad); LoadInitialFile(InitialFileLoad);
@ -2476,7 +2478,7 @@ namespace EduNetworkBuilder
UpdateForm(); UpdateForm();
} }
} }
private void rbHelp2_CheckedChanged(object sender, EventArgs e) private void rbHelp2_CheckedChanged(object sender, EventArgs e)
{ {
if (processing) return; if (processing) return;
@ -2532,24 +2534,24 @@ namespace EduNetworkBuilder
int max = (int)(total * 100); int max = (int)(total * 100);
myProgressBar.Maximum = max; myProgressBar.Maximum = max;
int distance = (int)(HowFar * 100); int distance = (int)(HowFar * 100);
if(distance > max) distance = max; if (distance > max) distance = max;
myProgressBar.Value = distance; myProgressBar.Value = distance;
} }
private void changeLanguageToolStripMenuItem_Click(object sender, EventArgs e) private void changeLanguageToolStripMenuItem_Click(object sender, EventArgs e)
{ {
DialogResult answer = MessageBox.Show(NB.Translate("NB_ChngLngClose"),NB.Translate("NB_ChngLngSure"),MessageBoxButtons.YesNoCancel); DialogResult answer = MessageBox.Show(NB.Translate("NB_ChngLngClose"), NB.Translate("NB_ChngLngSure"), MessageBoxButtons.YesNoCancel);
if (answer == System.Windows.Forms.DialogResult.Yes) if (answer == System.Windows.Forms.DialogResult.Yes)
{ {
OurSettings.LanguageHasBeenChosen = false; //So we choose the language on restart OurSettings.LanguageHasBeenChosen = false; //So we choose the language on restart
//System.Diagnostics.Process.Start(Application.ExecutablePath); // to start new instance of application //System.Diagnostics.Process.Start(Application.ExecutablePath); // to start new instance of application
this.Close(); //to turn off current app this.Close(); //to turn off current app
} }
} }
private void cbViewTitles_CheckedChanged(object sender, EventArgs e) private void cbViewTitles_CheckedChanged(object sender, EventArgs e)
{ {
if(!processing) if (!processing)
{ {
//myNetwork.ShowLabelsHere = cbViewTitles.Checked; //myNetwork.ShowLabelsHere = cbViewTitles.Checked;
bool didsomething = myNetwork.NoteActionDone(NetTestType.HelpRequest, "", "ViewButton"); bool didsomething = myNetwork.NoteActionDone(NetTestType.HelpRequest, "", "ViewButton");
@ -2682,7 +2684,7 @@ namespace EduNetworkBuilder
{ {
if (CurrentUser == null) return; //Nobody to logout if (CurrentUser == null) return; //Nobody to logout
DialogResult answer = MessageBox.Show(NB.Translate("NB_Logout"), NB.Translate("NB_Logout"),MessageBoxButtons.YesNoCancel); DialogResult answer = MessageBox.Show(NB.Translate("NB_Logout"), NB.Translate("NB_Logout"), MessageBoxButtons.YesNoCancel);
if (answer != DialogResult.Yes) return; if (answer != DialogResult.Yes) return;
//Save current user //Save current user
@ -2715,7 +2717,7 @@ namespace EduNetworkBuilder
} }
public bool ProcessingInvisibleNet() public bool ProcessingInvisibleNet()
{ {
if(InvisibleNetwork == null) return false; if (InvisibleNetwork == null) return false;
return true; return true;
} }
@ -2755,7 +2757,7 @@ namespace EduNetworkBuilder
} }
private void LoadSolvedRandomMap(string what, bool FromResource, int difficulty) private void LoadSolvedRandomMap(string what, bool FromResource, int difficulty)
{ {
if (FromResource) if (FromResource)
LoadSolvedResource(what); LoadSolvedResource(what);
else else
@ -2774,7 +2776,7 @@ namespace EduNetworkBuilder
while (Devices.Count > 2 && count < 5) while (Devices.Count > 2 && count < 5)
{ {
TraversalClass tc = myNetwork.NonVisualPingOneHost(Devices[0], Devices[1]); TraversalClass tc = myNetwork.NonVisualPingOneHost(Devices[0], Devices[1]);
if(tc != null) if (tc != null)
TraversalCollection.Add(tc); TraversalCollection.Add(tc);
Devices.RemoveAt(1); Devices.RemoveAt(1);
Devices.RemoveAt(0); Devices.RemoveAt(0);
@ -2794,7 +2796,7 @@ namespace EduNetworkBuilder
//loop through the traversalinfos //loop through the traversalinfos
//randomly choose a way to break it //randomly choose a way to break it
BreakList = NB.Randomize<HowToBreak>(BreakList); BreakList = NB.Randomize<HowToBreak>(BreakList);
HowHard += myNetwork.BreakNetworkPath(TraversalCollection[TraversalIndex],BreakList[0]); HowHard += myNetwork.BreakNetworkPath(TraversalCollection[TraversalIndex], BreakList[0]);
count++; count++;
TraversalIndex++; TraversalIndex++;
if (TraversalIndex >= TraversalCollection.Count) if (TraversalIndex >= TraversalCollection.Count)
@ -2886,7 +2888,7 @@ namespace EduNetworkBuilder
if (OurSettings != null && OurSettings.ReplayMode) if (OurSettings != null && OurSettings.ReplayMode)
{ {
ActionCollection AC = OurSettings.GetUserActionCollection(); ActionCollection AC = OurSettings.GetUserActionCollection();
if(AC.CurrentNeedsStoring) if (AC.CurrentNeedsStoring)
{ {
AC.PushActionToList(); AC.PushActionToList();
} }
@ -2916,5 +2918,23 @@ namespace EduNetworkBuilder
{ {
SaveReplayFile(); SaveReplayFile();
} }
private void regressionTestingToolStripMenuItem_Click(object sender, EventArgs e)
{
ListBoxWindow LBW = new ListBoxWindow(null, LBContents.regressiontest);
LBW.ShowDialog();
}
private void samplesToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
if (OurSettings != null && OurSettings.ReplayMode)
{
regressionTestingToolStripMenuItem.Visible = true;
}
else
{
regressionTestingToolStripMenuItem.Visible = false;
}
}
} }
} }