aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS/ShiftOS/SystemContext.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS/ShiftOS/SystemContext.cs')
-rw-r--r--ShiftOS/ShiftOS/SystemContext.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/ShiftOS/ShiftOS/SystemContext.cs b/ShiftOS/ShiftOS/SystemContext.cs
new file mode 100644
index 0000000..33a58c3
--- /dev/null
+++ b/ShiftOS/ShiftOS/SystemContext.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Threading.Tasks;
+
+namespace ShiftOS
+{
+ public class SystemContext : IDisposable
+ {
+ private Desktop _desktop = null;
+
+ public void Dispose()
+ {
+ _desktop = null;
+ }
+
+ public void Initialize()
+ {
+ // We can't initialize the game twice.
+ if (_desktop != null)
+ throw new InvalidOperationException("ShiftOS is already initialized.");
+
+ // Set up WinForms to run normally.
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+
+ using (_desktop = new Desktop())
+ {
+ // Run Windows Forms.
+ Application.Run(_desktop);
+ }
+ }
+ }
+}