aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlkaline Thunder <[email protected]>2018-12-28 00:46:11 -0500
committerAlkaline Thunder <[email protected]>2018-12-28 00:46:11 -0500
commit3db03e7a89d9e701f8aead85ef307fd5f3e4c9ec (patch)
treebc99645c392a8baeee98e8b2560633f64800efec
parent563c26e43bba94849426c92aa9f0756e8bdc9ed4 (diff)
downloadshiftos-challenge-3db03e7a89d9e701f8aead85ef307fd5f3e4c9ec.tar.gz
shiftos-challenge-3db03e7a89d9e701f8aead85ef307fd5f3e4c9ec.tar.bz2
shiftos-challenge-3db03e7a89d9e701f8aead85ef307fd5f3e4c9ec.zip
Allow the desktop to be skinned.
-rw-r--r--ShiftOS/ShiftOS/Desktop.cs22
-rw-r--r--ShiftOS/ShiftOS/ShiftOS.csproj2
-rw-r--r--ShiftOS/ShiftOS/Skin.cs19
-rw-r--r--ShiftOS/ShiftOS/SkinContext.cs23
-rw-r--r--ShiftOS/ShiftOS/SystemContext.cs18
5 files changed, 84 insertions, 0 deletions
diff --git a/ShiftOS/ShiftOS/Desktop.cs b/ShiftOS/ShiftOS/Desktop.cs
index a33461e..25d01f2 100644
--- a/ShiftOS/ShiftOS/Desktop.cs
+++ b/ShiftOS/ShiftOS/Desktop.cs
@@ -22,7 +22,29 @@ namespace ShiftOS
private void UpdateTimer_Tick(object sender, EventArgs e)
{
+ // Update current time of day.
this.CurrentTime.Text = CurrentSystem.GetTimeOfDay();
+
+ // We get our background colors from the skin.
+ this.BackColor = this.CurrentSystem.GetSkinContext().GetSkinData().DesktopBackgroundColor;
+ this.DesktopPanel.BackColor = this.CurrentSystem.GetSkinContext().GetSkinData().DesktopPanelBackgroundColor;
+
+ // Desktop panel must get its height from the skin.
+ this.DesktopPanel.Height = this.CurrentSystem.GetSkinContext().GetSkinData().DesktopPanelHeight;
+
+ // Set up the panel clock's position.
+ this.CurrentTime.Top = this.CurrentSystem.GetSkinContext().GetSkinData().PanelClockFromTop;
+ this.CurrentTime.Left = (DesktopPanel.Width - CurrentTime.Width) - this.CurrentSystem.GetSkinContext().GetSkinData().PanelClockFromSide;
+
+ // Determine the desktop panel dock
+ if(this.CurrentSystem.GetSkinContext().GetSkinData().IsDesktopPanelAtTop)
+ {
+ this.DesktopPanel.Dock = DockStyle.Top;
+ }
+ else
+ {
+ this.DesktopPanel.Dock = DockStyle.Bottom;
+ }
}
}
}
diff --git a/ShiftOS/ShiftOS/ShiftOS.csproj b/ShiftOS/ShiftOS/ShiftOS.csproj
index cc47277..d8e4c7b 100644
--- a/ShiftOS/ShiftOS/ShiftOS.csproj
+++ b/ShiftOS/ShiftOS/ShiftOS.csproj
@@ -54,6 +54,8 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Skin.cs" />
+ <Compile Include="SkinContext.cs" />
<Compile Include="SystemContext.cs" />
<EmbeddedResource Include="Desktop.resx">
<DependentUpon>Desktop.cs</DependentUpon>
diff --git a/ShiftOS/ShiftOS/Skin.cs b/ShiftOS/ShiftOS/Skin.cs
new file mode 100644
index 0000000..8aa3329
--- /dev/null
+++ b/ShiftOS/ShiftOS/Skin.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Drawing;
+using System.Threading.Tasks;
+
+namespace ShiftOS
+{
+ public class Skin
+ {
+ public int DesktopPanelHeight = 24;
+ public Color DesktopPanelBackgroundColor = Color.Gray;
+ public Color DesktopBackgroundColor = Color.Black;
+ public int PanelClockFromTop = 2;
+ public int PanelClockFromSide = 4;
+ public bool IsDesktopPanelAtTop = true;
+ }
+}
diff --git a/ShiftOS/ShiftOS/SkinContext.cs b/ShiftOS/ShiftOS/SkinContext.cs
new file mode 100644
index 0000000..dbab213
--- /dev/null
+++ b/ShiftOS/ShiftOS/SkinContext.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShiftOS
+{
+ public class SkinContext
+ {
+ private Skin _skin = null;
+
+ public SkinContext()
+ {
+ _skin = new Skin();
+ }
+
+ public Skin GetSkinData()
+ {
+ return _skin;
+ }
+ }
+}
diff --git a/ShiftOS/ShiftOS/SystemContext.cs b/ShiftOS/ShiftOS/SystemContext.cs
index 2dc70da..13c7561 100644
--- a/ShiftOS/ShiftOS/SystemContext.cs
+++ b/ShiftOS/ShiftOS/SystemContext.cs
@@ -10,8 +10,15 @@ namespace ShiftOS
public class SystemContext : IDisposable
{
private Desktop _desktop = null;
+ private SkinContext _skinContext = null;
private int _codepoints = 0;
+ private void LoadCurrentSkin()
+ {
+ // TODO: Load it from a filesystem of some sort.
+ _skinContext = new SkinContext();
+ }
+
public void Dispose()
{
_desktop = null;
@@ -22,16 +29,27 @@ namespace ShiftOS
return this._codepoints;
}
+ public SkinContext GetSkinContext()
+ {
+ return this._skinContext;
+ }
+
public void Initialize()
{
// We can't initialize the game twice.
if (_desktop != null)
throw new InvalidOperationException("ShiftOS is already initialized.");
+ Console.WriteLine("Bootstrapping WinForms...");
+
// Set up WinForms to run normally.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
+ Console.WriteLine("Loading current skin...");
+ this.LoadCurrentSkin();
+
+ Console.WriteLine("Loading desktop...");
using (_desktop = new Desktop(this))
{
// Run Windows Forms.