diff --git a/Chapter6/frmMain.Designer.cs b/Chapter6/frmMain.Designer.cs index 7cc8d7e..3cbb446 100644 --- a/Chapter6/frmMain.Designer.cs +++ b/Chapter6/frmMain.Designer.cs @@ -48,7 +48,11 @@ namespace Chapter6 this.mnuWindowCloseAll = new System.Windows.Forms.ToolStripMenuItem(); this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); this.mnuHelpAbout = new System.Windows.Forms.ToolStripMenuItem(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.lblUser = new System.Windows.Forms.ToolStripStatusLabel(); + this.lblDateTime = new System.Windows.Forms.ToolStripStatusLabel(); this.Menu.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // Menu @@ -86,7 +90,7 @@ namespace Chapter6 this.mnuEditCalculate.Name = "mnuEditCalculate"; this.mnuEditCalculate.Size = new System.Drawing.Size(153, 22); this.mnuEditCalculate.Text = "Calculate"; - this.mnuEditCalculate.Click += mnuEditCalculate_Click; + this.mnuEditCalculate.Click += new System.EventHandler(this.mnuEditCalculate_Click); // // mnuEditSummary // @@ -123,35 +127,36 @@ namespace Chapter6 // mnuWindowArrangeIcons // this.mnuWindowArrangeIcons.Name = "mnuWindowArrangeIcons"; - this.mnuWindowArrangeIcons.Size = new System.Drawing.Size(152, 22); + this.mnuWindowArrangeIcons.Size = new System.Drawing.Size(147, 22); this.mnuWindowArrangeIcons.Text = "Arrange Icons"; // // mnuWindowsCascade // this.mnuWindowsCascade.Name = "mnuWindowsCascade"; - this.mnuWindowsCascade.Size = new System.Drawing.Size(152, 22); + this.mnuWindowsCascade.Size = new System.Drawing.Size(147, 22); this.mnuWindowsCascade.Text = "Cascade"; this.mnuWindowsCascade.Click += new System.EventHandler(this.mnuWindowsCascade_Click); // // munWindowHorizontal // this.munWindowHorizontal.Name = "munWindowHorizontal"; - this.munWindowHorizontal.Size = new System.Drawing.Size(152, 22); + this.munWindowHorizontal.Size = new System.Drawing.Size(147, 22); this.munWindowHorizontal.Text = "Horizontal"; this.munWindowHorizontal.Click += new System.EventHandler(this.munWindowHorizontal_Click); // // mnuWindowVertical // this.mnuWindowVertical.Name = "mnuWindowVertical"; - this.mnuWindowVertical.Size = new System.Drawing.Size(152, 22); + this.mnuWindowVertical.Size = new System.Drawing.Size(147, 22); this.mnuWindowVertical.Text = "Vertical"; this.mnuWindowVertical.Click += new System.EventHandler(this.mnuWindowVertical_Click); // // mnuWindowCloseAll // this.mnuWindowCloseAll.Name = "mnuWindowCloseAll"; - this.mnuWindowCloseAll.Size = new System.Drawing.Size(152, 22); + this.mnuWindowCloseAll.Size = new System.Drawing.Size(147, 22); this.mnuWindowCloseAll.Text = "Close All"; + this.mnuWindowCloseAll.Click += new System.EventHandler(this.mnuWindowCloseAll_Click); // // mnuHelp // @@ -167,11 +172,34 @@ namespace Chapter6 this.mnuHelpAbout.Text = "About"; this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click); // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.lblUser, this.lblDateTime }); + this.statusStrip1.Location = new System.Drawing.Point(0, 428); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(800, 22); + this.statusStrip1.TabIndex = 3; + this.statusStrip1.Text = "statusStrip1"; + // + // lblUser + // + this.lblUser.Name = "lblUser"; + this.lblUser.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.lblUser.Size = new System.Drawing.Size(0, 17); + this.lblUser.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal; + // + // lblDateTime + // + this.lblDateTime.Margin = new System.Windows.Forms.Padding(470, 3, 0, 2); + this.lblDateTime.Name = "lblDateTime"; + this.lblDateTime.Size = new System.Drawing.Size(0, 17); + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.statusStrip1); this.Controls.Add(this.Menu); this.IsMdiContainer = true; this.MainMenuStrip = this.Menu; @@ -179,10 +207,18 @@ namespace Chapter6 this.Text = "MDI"; this.Menu.ResumeLayout(false); this.Menu.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } + private System.Windows.Forms.ToolStripStatusLabel lblDateTime; + + private System.Windows.Forms.ToolStripStatusLabel lblUser; + + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripMenuItem mnuEditCalculate; private System.Windows.Forms.ToolStripMenuItem mnuEditSummary; private System.Windows.Forms.ToolStripMenuItem mnuEditShowStudents; diff --git a/Chapter6/frmMain.cs b/Chapter6/frmMain.cs index babe473..92be0e0 100644 --- a/Chapter6/frmMain.cs +++ b/Chapter6/frmMain.cs @@ -1,13 +1,34 @@ using System; using System.Windows.Forms; +using System.Security.Principal; namespace Chapter6 { public partial class frmMain : Form { + + private Timer timer; public frmMain() { InitializeComponent(); + + lblUser.Text = WindowsIdentity.GetCurrent().Name.ToString(); + + timer = new Timer + { + Interval = 1000 + }; + + timer.Tick += Tick; + timer.Start(); + + } + + private void Tick(object sender, EventArgs e) + { + + lblDateTime.Text = DateTime.Now.ToString("f"); + } private void mnuFileExit_Click(object sender, EventArgs e) @@ -88,5 +109,20 @@ namespace Chapter6 { LayoutMdi(MdiLayout.Cascade); } + + private void mnuWindowCloseAll_Click(object sender, EventArgs e) + { + foreach (var childform in MdiChildren) + { + + childform.Close(); + + } + } + + private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + { + + } } } \ No newline at end of file diff --git a/Chapter6/frmMain.resx b/Chapter6/frmMain.resx index 5b57c07..2e28eba 100644 --- a/Chapter6/frmMain.resx +++ b/Chapter6/frmMain.resx @@ -120,4 +120,7 @@ 17, 17 + + 97, 17 + \ No newline at end of file