diff --git a/EduNetworkBuilder/ActionClass.cs b/EduNetworkBuilder/ActionClass.cs index 207988c..437b8d8 100644 --- a/EduNetworkBuilder/ActionClass.cs +++ b/EduNetworkBuilder/ActionClass.cs @@ -14,6 +14,7 @@ namespace EduNetworkBuilder NetworkAction CurrentNetAction = null; public Network GetNet { get { return StartingState; } } + public int GetActionCount { get { if (CurrentNetAction == null) return 0; return CurrentNetAction.Actions.Count; } } public void RegisterNet(Network starting) { diff --git a/EduNetworkBuilder/NetworkBuilder.Designer.cs b/EduNetworkBuilder/NetworkBuilder.Designer.cs index 43e3c4f..1d3f48e 100644 --- a/EduNetworkBuilder/NetworkBuilder.Designer.cs +++ b/EduNetworkBuilder/NetworkBuilder.Designer.cs @@ -36,6 +36,7 @@ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.logoutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.replayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -78,7 +79,6 @@ this.myProgressBar = new System.Windows.Forms.ProgressBar(); this.cbLineColor = new System.Windows.Forms.ComboBox(); this.cbFillColor = new System.Windows.Forms.ComboBox(); - this.replayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.msMainMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit(); this.HelpPanel.SuspendLayout(); @@ -113,6 +113,7 @@ this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24); this.fileToolStripMenuItem.Text = "File"; + this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpening); // // newToolStripMenuItem // @@ -156,6 +157,13 @@ this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // + // replayToolStripMenuItem + // + this.replayToolStripMenuItem.Name = "replayToolStripMenuItem"; + this.replayToolStripMenuItem.Size = new System.Drawing.Size(181, 26); + this.replayToolStripMenuItem.Text = "Replay"; + this.replayToolStripMenuItem.Click += new System.EventHandler(this.replayToolStripMenuItem_Click); + // // editToolStripMenuItem // this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -535,13 +543,6 @@ this.cbFillColor.Size = new System.Drawing.Size(80, 24); this.cbFillColor.TabIndex = 13; // - // replayToolStripMenuItem - // - this.replayToolStripMenuItem.Name = "replayToolStripMenuItem"; - this.replayToolStripMenuItem.Size = new System.Drawing.Size(181, 26); - this.replayToolStripMenuItem.Text = "Replay"; - this.replayToolStripMenuItem.Click += new System.EventHandler(this.replayToolStripMenuItem_Click); - // // BuilderWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index f707f0b..2070d68 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -2804,6 +2804,8 @@ namespace EduNetworkBuilder // Go through each step and do the actions again in order NBSettings ourSettings = NB.GetSettings(); if (OurSettings == null) return; //nothing to do + if (OurSettings.ReplayMode == false) return; //We should never be here if we are false. + ActionCollection actions = OurSettings.GetUserActionCollection(); if (actions == null) return; //nothing to do @@ -2823,5 +2825,23 @@ namespace EduNetworkBuilder myNetwork.NextReplayIndex = 0; myNetwork.NextReplayAction = DateTime.UtcNow.AddMilliseconds(NB.MillisecondsBetweenReplays); } + + private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e) + { + NBSettings ourSettings = NB.GetSettings(); + replayToolStripMenuItem.Visible = false; + + if (OurSettings != null && OurSettings.ReplayMode) + { + ActionCollection AC = OurSettings.GetUserActionCollection(); + if(AC != null && AC.GetActionCount >0) + replayToolStripMenuItem.Visible = true; //Only visible if we have something to replay + } + else + { + replayToolStripMenuItem.Visible = false; + + } + } } } \ No newline at end of file