From 44f8184edc6c78de1358ff2e64b9c0e087df0573 Mon Sep 17 00:00:00 2001 From: Alkaline Thunder Date: Fri, 28 Dec 2018 00:18:56 -0500 Subject: [PATCH] Time Of Day text --- ShiftOS/ShiftOS/Desktop.Designer.cs | 26 ++++++++++++++++++++++++++ ShiftOS/ShiftOS/Desktop.cs | 10 +++++++++- ShiftOS/ShiftOS/Desktop.resx | 3 +++ ShiftOS/ShiftOS/SystemContext.cs | 8 +++++++- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ShiftOS/ShiftOS/Desktop.Designer.cs b/ShiftOS/ShiftOS/Desktop.Designer.cs index 558300a..b1ead61 100644 --- a/ShiftOS/ShiftOS/Desktop.Designer.cs +++ b/ShiftOS/ShiftOS/Desktop.Designer.cs @@ -28,12 +28,17 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.DesktopPanel = new System.Windows.Forms.Panel(); + this.CurrentTime = new System.Windows.Forms.Label(); + this.UpdateTimer = new System.Windows.Forms.Timer(this.components); + this.DesktopPanel.SuspendLayout(); this.SuspendLayout(); // // DesktopPanel // this.DesktopPanel.BackColor = System.Drawing.Color.Gray; + this.DesktopPanel.Controls.Add(this.CurrentTime); this.DesktopPanel.Dock = System.Windows.Forms.DockStyle.Top; this.DesktopPanel.ForeColor = System.Drawing.Color.Black; this.DesktopPanel.Location = new System.Drawing.Point(0, 0); @@ -41,6 +46,23 @@ this.DesktopPanel.Size = new System.Drawing.Size(800, 24); this.DesktopPanel.TabIndex = 0; // + // CurrentTime + // + this.CurrentTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.CurrentTime.AutoSize = true; + this.CurrentTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold); + this.CurrentTime.Location = new System.Drawing.Point(698, 4); + this.CurrentTime.Name = "CurrentTime"; + this.CurrentTime.Size = new System.Drawing.Size(101, 18); + this.CurrentTime.TabIndex = 0; + this.CurrentTime.Text = "12:00:00 AM"; + // + // UpdateTimer + // + this.UpdateTimer.Enabled = true; + this.UpdateTimer.Interval = 50; + this.UpdateTimer.Tick += new System.EventHandler(this.UpdateTimer_Tick); + // // Desktop // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -55,6 +77,8 @@ this.Text = "Form1"; this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(0)))), ((int)(((byte)(1))))); this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.DesktopPanel.ResumeLayout(false); + this.DesktopPanel.PerformLayout(); this.ResumeLayout(false); } @@ -62,6 +86,8 @@ #endregion private System.Windows.Forms.Panel DesktopPanel; + private System.Windows.Forms.Label CurrentTime; + private System.Windows.Forms.Timer UpdateTimer; } } diff --git a/ShiftOS/ShiftOS/Desktop.cs b/ShiftOS/ShiftOS/Desktop.cs index 4aa8a1a..a33461e 100644 --- a/ShiftOS/ShiftOS/Desktop.cs +++ b/ShiftOS/ShiftOS/Desktop.cs @@ -12,9 +12,17 @@ namespace ShiftOS { public partial class Desktop : Form { - public Desktop() + private SystemContext CurrentSystem = null; + + public Desktop(SystemContext InSystem) { + this.CurrentSystem = InSystem; InitializeComponent(); } + + private void UpdateTimer_Tick(object sender, EventArgs e) + { + this.CurrentTime.Text = CurrentSystem.GetTimeOfDay(); + } } } diff --git a/ShiftOS/ShiftOS/Desktop.resx b/ShiftOS/ShiftOS/Desktop.resx index 1af7de1..05f1355 100644 --- a/ShiftOS/ShiftOS/Desktop.resx +++ b/ShiftOS/ShiftOS/Desktop.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS/ShiftOS/SystemContext.cs b/ShiftOS/ShiftOS/SystemContext.cs index 33a58c3..f6d4c83 100644 --- a/ShiftOS/ShiftOS/SystemContext.cs +++ b/ShiftOS/ShiftOS/SystemContext.cs @@ -26,11 +26,17 @@ namespace ShiftOS Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - using (_desktop = new Desktop()) + using (_desktop = new Desktop(this)) { // Run Windows Forms. Application.Run(_desktop); } } + + public string GetTimeOfDay() + { + // TODO: Shiftorium time upgrades. + return DateTime.Now.ToShortTimeString(); + } } }