Hide various things based on whether we can do Replays, and if we have anything to replay

This commit is contained in:
Tim Young 2018-05-09 16:24:37 -05:00
parent 0ac9fea3bb
commit de5a3c353e
3 changed files with 30 additions and 8 deletions

View File

@ -14,6 +14,7 @@ namespace EduNetworkBuilder
NetworkAction CurrentNetAction = null; NetworkAction CurrentNetAction = null;
public Network GetNet { get { return StartingState; } } public Network GetNet { get { return StartingState; } }
public int GetActionCount { get { if (CurrentNetAction == null) return 0; return CurrentNetAction.Actions.Count; } }
public void RegisterNet(Network starting) public void RegisterNet(Network starting)
{ {

View File

@ -36,6 +36,7 @@
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
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.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();
@ -78,7 +79,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.replayToolStripMenuItem = 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();
@ -113,6 +113,7 @@
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24); this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24);
this.fileToolStripMenuItem.Text = "File"; this.fileToolStripMenuItem.Text = "File";
this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpening);
// //
// newToolStripMenuItem // newToolStripMenuItem
// //
@ -156,6 +157,13 @@
this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); 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 // editToolStripMenuItem
// //
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -535,13 +543,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;
// //
// 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 // BuilderWindow
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);

View File

@ -2804,6 +2804,8 @@ namespace EduNetworkBuilder
// Go through each step and do the actions again in order // Go through each step and do the actions again in order
NBSettings ourSettings = NB.GetSettings(); NBSettings ourSettings = NB.GetSettings();
if (OurSettings == null) return; //nothing to do 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(); ActionCollection actions = OurSettings.GetUserActionCollection();
if (actions == null) return; //nothing to do if (actions == null) return; //nothing to do
@ -2823,5 +2825,23 @@ namespace EduNetworkBuilder
myNetwork.NextReplayIndex = 0; myNetwork.NextReplayIndex = 0;
myNetwork.NextReplayAction = DateTime.UtcNow.AddMilliseconds(NB.MillisecondsBetweenReplays); 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;
}
}
} }
} }