diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt
index fde7f36..719ad59 100644
--- a/ShiftOS.WinForms/Resources/Shiftorium.txt
+++ b/ShiftOS.WinForms/Resources/Shiftorium.txt
@@ -1,4 +1,19 @@
[
+// SCREENSAVER
+ {
+ Name: "Screensavers",
+ Cost: 750,
+ Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it.",
+ Dependencies: "desktop"
+ },
+ {
+ Name: "Shift Screensavers",
+ Cost: 100,
+ Description: "This Shifter upgrade will allow you to customize the screensaver.",
+ Dependencies: "screensavers;shifter"
+ },
+
+
// CALCULATOR UPGRADES
{
Name: "Calculator",
diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs
index aef7296..2348320 100644
--- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs
+++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs
@@ -59,9 +59,12 @@ namespace ShiftOS.WinForms
this.sysmenuholder = new System.Windows.Forms.Panel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.apps = new System.Windows.Forms.ToolStripMenuItem();
+ this.pnlscreensaver = new System.Windows.Forms.Panel();
+ this.pnlssicon = new System.Windows.Forms.Panel();
this.desktoppanel.SuspendLayout();
this.sysmenuholder.SuspendLayout();
this.menuStrip1.SuspendLayout();
+ this.pnlscreensaver.SuspendLayout();
this.SuspendLayout();
//
// desktoppanel
@@ -144,12 +147,30 @@ namespace ShiftOS.WinForms
this.apps.Tag = "applauncherbutton";
this.apps.Text = "ShiftOS";
//
+ // pnlscreensaver
+ //
+ this.pnlscreensaver.Controls.Add(this.pnlssicon);
+ this.pnlscreensaver.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pnlscreensaver.Location = new System.Drawing.Point(0, 24);
+ this.pnlscreensaver.Name = "pnlscreensaver";
+ this.pnlscreensaver.Size = new System.Drawing.Size(1296, 714);
+ this.pnlscreensaver.TabIndex = 1;
+ this.pnlscreensaver.Visible = false;
+ //
+ // pnlssicon
+ //
+ this.pnlssicon.Location = new System.Drawing.Point(303, 495);
+ this.pnlssicon.Name = "pnlssicon";
+ this.pnlssicon.Size = new System.Drawing.Size(200, 100);
+ this.pnlssicon.TabIndex = 0;
+ //
// WinformsDesktop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(1296, 738);
+ this.Controls.Add(this.pnlscreensaver);
this.Controls.Add(this.desktoppanel);
this.Font = new System.Drawing.Font("Consolas", 9F);
this.ForeColor = System.Drawing.Color.LightGreen;
@@ -163,6 +184,7 @@ namespace ShiftOS.WinForms
this.sysmenuholder.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
+ this.pnlscreensaver.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -176,6 +198,8 @@ namespace ShiftOS.WinForms
private System.Windows.Forms.ToolStripMenuItem apps;
private System.Windows.Forms.FlowLayoutPanel panelbuttonholder;
private System.Windows.Forms.Button btnnotifications;
+ private System.Windows.Forms.Panel pnlscreensaver;
+ private System.Windows.Forms.Panel pnlssicon;
}
}
diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs
index 899eb0d..70910d8 100644
--- a/ShiftOS.WinForms/WinformsDesktop.cs
+++ b/ShiftOS.WinForms/WinformsDesktop.cs
@@ -37,6 +37,7 @@ using ShiftOS.WinForms.Tools;
using ShiftOS.WinForms.Applications;
using Newtonsoft.Json;
using ShiftOS.Engine.Scripting;
+using System.Threading;
///
/// Winforms desktop.
@@ -48,6 +49,9 @@ namespace ShiftOS.WinForms
///
public partial class WinformsDesktop : Form, IDesktop
{
+ private bool InScreensaver = false;
+ private int millisecondsUntilScreensaver = 300000;
+
///
/// Initializes a new instance of the class.
///
@@ -100,7 +104,7 @@ namespace ShiftOS.WinForms
if (this.Visible == true)
this.Invoke(new Action(() => SetupDesktop()));
};
- var time = new Timer();
+ var time = new System.Windows.Forms.Timer();
time.Interval = 100;
this.KeyDown += (o, a) =>
{
@@ -139,9 +143,86 @@ namespace ShiftOS.WinForms
};
time.Start();
+ var ssThread = new Thread(() =>
+ {
+ while(this.Visible == true)
+ {
+ var mousePos = Cursor.Position;
+ while(Cursor.Position == mousePos)
+ {
+ if(millisecondsUntilScreensaver <= 0)
+ {
+ ShowScreensaver();
+ InScreensaver = true;
+ }
+ millisecondsUntilScreensaver--;
+ Thread.Sleep(1);
+ }
+ millisecondsUntilScreensaver = 300000;
+ InScreensaver = false;
+ HideScreensaver();
+ }
+ });
+ ssThread.IsBackground = true;
+ ssThread.Start();
+
this.DoubleBuffered = true;
}
+ public void HideScreensaver()
+ {
+ this.Invoke(new Action(() =>
+ {
+ this.TopMost = false;
+ pnlscreensaver.Hide();
+ Cursor.Show();
+ SetupDesktop();
+ }));
+ }
+
+ private void ShowScreensaver()
+ {
+ if (Shiftorium.UpgradeInstalled("screensavers"))
+ {
+ this.Invoke(new Action(() =>
+ {
+ pnlscreensaver.Show();
+ this.TopMost = true;
+ pnlssicon.Show();
+ pnlssicon.BackColor = Color.Green;
+ pnlssicon.BackgroundImage = GetImage("screensaver");
+ pnlssicon.BackgroundImageLayout = GetImageLayout("screensaver");
+
+ if (pnlssicon.BackgroundImage != null)
+ {
+ pnlssicon.Size = pnlssicon.BackgroundImage.Size;
+ }
+
+ Cursor.Hide();
+
+ var t = new Thread(() =>
+ {
+ var rnd = new Random();
+ while (InScreensaver == true)
+ {
+ int x = rnd.Next(0, this.Width);
+ int y = rnd.Next(0, this.Height);
+
+ this.Invoke(new Action(() =>
+ {
+ pnlssicon.Location = new Point(x, y);
+ }));
+
+ Thread.Sleep(5000);
+ }
+ });
+ t.IsBackground = true;
+ t.Start();
+ }));
+ }
+ }
+
+
///
/// Populates the panel buttons.
///
diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs
index 4837dcd..43e0b5d 100644
--- a/ShiftOS_TheReturn/Skinning.cs
+++ b/ShiftOS_TheReturn/Skinning.cs
@@ -246,6 +246,21 @@ namespace ShiftOS.Engine {
[ShifterHidden]
public Dictionary AppIcons = new Dictionary();
+ [RequiresUpgrade("shift_screensaver")]
+ [ShifterMeta("System")]
+ [ShifterCategory("Screen saver")]
+ [ShifterName("Screen saver wait (milliseconds)")]
+ [ShifterDescription("How long do you have to stay idle before the screensaver activates?")]
+ public int ScreensaverWait = 300000;
+
+ [RequiresUpgrade("skinning;shift_screensaver")]
+ [ShifterMeta("System")]
+ [ShifterCategory("Screen saver")]
+ [ShifterName("Screen saver image")]
+ [ShifterDescription("What image should appear on the screen saver?")]
+ public byte[] ScreensaverImage = null;
+
+
[ShifterMeta("Windows")]
[ShifterCategory("Titlebar")]