diff options
| -rw-r--r-- | ShiftOS.WinForms/DesktopWidgetAttribute.cs | 21 | ||||
| -rw-r--r-- | ShiftOS.WinForms/DesktopWidgets/Clock.Designer.cs | 63 | ||||
| -rw-r--r-- | ShiftOS.WinForms/DesktopWidgets/Clock.cs | 45 | ||||
| -rw-r--r-- | ShiftOS.WinForms/DesktopWidgets/Clock.resx | 120 | ||||
| -rw-r--r-- | ShiftOS.WinForms/IDesktopWidget.cs | 51 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Resources/Shiftorium.txt | 11 | ||||
| -rw-r--r-- | ShiftOS.WinForms/ShiftOS.WinForms.csproj | 12 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WidgetManager.cs | 50 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WinformsDesktop.Designer.cs | 48 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WinformsDesktop.cs | 42 |
10 files changed, 445 insertions, 18 deletions
diff --git a/ShiftOS.WinForms/DesktopWidgetAttribute.cs b/ShiftOS.WinForms/DesktopWidgetAttribute.cs new file mode 100644 index 0000000..28d50ac --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgetAttribute.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.WinForms +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] + public class DesktopWidgetAttribute : Attribute + { + public string Name { get; set; } + public string Description { get; set; } + + public DesktopWidgetAttribute(string n, string desc) + { + Name = n; + Description = desc; + } + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/Clock.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/Clock.Designer.cs new file mode 100644 index 0000000..a36d386 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/Clock.Designer.cs @@ -0,0 +1,63 @@ +namespace ShiftOS.WinForms.DesktopWidgets +{ + partial class Clock + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.lbtime = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbtime + // + this.lbtime.BackColor = System.Drawing.Color.Transparent; + this.lbtime.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbtime.Location = new System.Drawing.Point(0, 0); + this.lbtime.Name = "lbtime"; + this.lbtime.Size = new System.Drawing.Size(210, 49); + this.lbtime.TabIndex = 0; + this.lbtime.Tag = "header2 keepbg"; + this.lbtime.Text = "label1"; + this.lbtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // Clock + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Transparent; + this.Controls.Add(this.lbtime); + this.Name = "Clock"; + this.Size = new System.Drawing.Size(210, 49); + this.Tag = "keepbg"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label lbtime; + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/Clock.cs b/ShiftOS.WinForms/DesktopWidgets/Clock.cs new file mode 100644 index 0000000..aa29e2e --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/Clock.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.DesktopWidgets +{ + [DesktopWidget("Clock", "Show a clock on the desktop.")] + [RequiresUpgrade("desktop_clock_widget")] + public partial class Clock : UserControl, IDesktopWidget + { + public Clock() + { + InitializeComponent(); + tmr = new Timer(); + tmr.Tick += (o, a) => + { + lbtime.Text = Applications.Terminal.GetTime(); + }; + tmr.Interval = 100; + } + + Timer tmr = new Timer(); + + public void OnSkinLoad() + { + Tools.ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + public void Setup() + { + tmr.Start(); + } + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/Clock.resx b/ShiftOS.WinForms/DesktopWidgets/Clock.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/Clock.resx @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/ShiftOS.WinForms/IDesktopWidget.cs b/ShiftOS.WinForms/IDesktopWidget.cs new file mode 100644 index 0000000..95c373c --- /dev/null +++ b/ShiftOS.WinForms/IDesktopWidget.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ + /// <summary> + /// Provides base functionality for a ShiftOS desktop widget. + /// </summary> + public interface IDesktopWidget + { + /// <summary> + /// Performs routine setup operations to keep the widget up to date. + /// </summary> + void Setup(); + + /// <summary> + /// Occurs when a skin is loaded. + /// </summary> + void OnSkinLoad(); + + /// <summary> + /// Occurs when a Shiftorium upgrade is installed. + /// </summary> + void OnUpgrade(); + + /// <summary> + /// Hides this desktop widget. + /// </summary> + void Hide(); + + /// <summary> + /// Shows this desktop widget. + /// </summary> + void Show(); + + /// <summary> + /// Gets or sets the location on the desktop that this widget resides. + /// </summary> + Point Location { get; set; } + + /// <summary> + /// Gets or sets this widget's size. + /// </summary> + Size Size { get; set; } + } +} diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 82ee613..c18f456 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -1,4 +1,15 @@ [ + //TEMPORARY + { + Name: "Desktop Widgets", + Cost: 0, + Description: "Temporary upgrade. Will be replaced by either a Shiftnet app or a story element.", + Dependencies: "advanced_app_launcher;wm_free_placement", + Category: "Work-in-progress" + }, + + + // SCREENSAVER { Name: "Screensavers", diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9675bb6..a223f47 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -257,6 +257,13 @@ <Compile Include="Controls\TerminalBox.cs"> <SubType>Component</SubType> </Compile> + <Compile Include="DesktopWidgetAttribute.cs" /> + <Compile Include="DesktopWidgets\Clock.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="DesktopWidgets\Clock.Designer.cs"> + <DependentUpon>Clock.cs</DependentUpon> + </Compile> <Compile Include="DownloadControl.cs"> <SubType>UserControl</SubType> </Compile> @@ -271,6 +278,7 @@ </Compile> <Compile Include="GUIFunctions.cs" /> <Compile Include="HackerCommands.cs" /> + <Compile Include="IDesktopWidget.cs" /> <Compile Include="JobTasks.cs" /> <Compile Include="Oobe.cs"> <SubType>Form</SubType> @@ -294,6 +302,7 @@ <Compile Include="TrailerCommands.cs" /> <Compile Include="VisualBasicStuff.cs" /> <Compile Include="WFLanguageProvider.cs" /> + <Compile Include="WidgetManager.cs" /> <Compile Include="Window.cs"> <SubType>UserControl</SubType> </Compile> @@ -399,6 +408,9 @@ <EmbeddedResource Include="Applications\UpdateManager.resx"> <DependentUpon>UpdateManager.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="DesktopWidgets\Clock.resx"> + <DependentUpon>Clock.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="DownloadControl.resx"> <DependentUpon>DownloadControl.cs</DependentUpon> </EmbeddedResource> diff --git a/ShiftOS.WinForms/WidgetManager.cs b/ShiftOS.WinForms/WidgetManager.cs new file mode 100644 index 0000000..125c804 --- /dev/null +++ b/ShiftOS.WinForms/WidgetManager.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ + public static class WidgetManager + { + public static Dictionary<DesktopWidgetAttribute, Type> GetAllWidgetTypes() + { + Dictionary<DesktopWidgetAttribute, Type> types = new Dictionary<WinForms.DesktopWidgetAttribute, Type>(); + foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach(var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IDesktopWidget))) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + foreach (var attrib in type.GetCustomAttributes(false)) + { + if (attrib is DesktopWidgetAttribute) + { + var dw = attrib as DesktopWidgetAttribute; + types.Add(dw, type); + } + } + } + } + } + } + catch { } + } + } + return types; + } + + + } +} diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 3d24c3d..71ef161 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -60,14 +60,15 @@ namespace ShiftOS.WinForms this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.apps = new System.Windows.Forms.ToolStripMenuItem(); this.pnlscreensaver = new System.Windows.Forms.Panel(); + this.pnlwidgetlayer = new System.Windows.Forms.Panel(); this.pnlssicon = new System.Windows.Forms.Panel(); this.pnladvancedal = new System.Windows.Forms.Panel(); + this.flapps = new System.Windows.Forms.FlowLayoutPanel(); + this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); this.pnlalsystemactions = new System.Windows.Forms.Panel(); this.btnshutdown = new System.Windows.Forms.Button(); this.pnlstatus = new System.Windows.Forms.Panel(); this.lbalstatus = new System.Windows.Forms.Label(); - this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); - this.flapps = new System.Windows.Forms.FlowLayoutPanel(); this.desktoppanel.SuspendLayout(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -169,6 +170,15 @@ namespace ShiftOS.WinForms this.pnlscreensaver.TabIndex = 1; this.pnlscreensaver.Visible = false; // + // pnlwidgetlayer + // + this.pnlwidgetlayer.BackColor = System.Drawing.Color.Transparent; + this.pnlwidgetlayer.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlwidgetlayer.Location = new System.Drawing.Point(0, 24); + this.pnlwidgetlayer.Name = "pnlwidgetlayer"; + this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); + this.pnlwidgetlayer.TabIndex = 1; + // // pnlssicon // this.pnlssicon.Location = new System.Drawing.Point(303, 495); @@ -188,6 +198,22 @@ namespace ShiftOS.WinForms this.pnladvancedal.TabIndex = 1; this.pnladvancedal.Visible = false; // + // flapps + // + this.flapps.Dock = System.Windows.Forms.DockStyle.Fill; + this.flapps.Location = new System.Drawing.Point(221, 58); + this.flapps.Name = "flapps"; + this.flapps.Size = new System.Drawing.Size(212, 328); + this.flapps.TabIndex = 3; + // + // flcategories + // + this.flcategories.Dock = System.Windows.Forms.DockStyle.Left; + this.flcategories.Location = new System.Drawing.Point(0, 58); + this.flcategories.Name = "flcategories"; + this.flcategories.Size = new System.Drawing.Size(221, 328); + this.flcategories.TabIndex = 2; + // // pnlalsystemactions // this.pnlalsystemactions.Controls.Add(this.btnshutdown); @@ -230,28 +256,13 @@ namespace ShiftOS.WinForms this.lbalstatus.Text = "michael@system\r\n0 Codepoints\r\n0 installed, 0 available"; this.lbalstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // flcategories - // - this.flcategories.Dock = System.Windows.Forms.DockStyle.Left; - this.flcategories.Location = new System.Drawing.Point(0, 58); - this.flcategories.Name = "flcategories"; - this.flcategories.Size = new System.Drawing.Size(221, 328); - this.flcategories.TabIndex = 2; - // - // flapps - // - this.flapps.Dock = System.Windows.Forms.DockStyle.Fill; - this.flapps.Location = new System.Drawing.Point(221, 58); - this.flapps.Name = "flapps"; - this.flapps.Size = new System.Drawing.Size(212, 328); - this.flapps.TabIndex = 3; - // // 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.pnlwidgetlayer); this.Controls.Add(this.pnladvancedal); this.Controls.Add(this.pnlscreensaver); this.Controls.Add(this.desktoppanel); @@ -294,6 +305,7 @@ namespace ShiftOS.WinForms private System.Windows.Forms.Label lbalstatus; private System.Windows.Forms.FlowLayoutPanel flapps; private System.Windows.Forms.FlowLayoutPanel flcategories; + private System.Windows.Forms.Panel pnlwidgetlayer; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index cd74a6b..3050cdf 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -49,6 +49,9 @@ namespace ShiftOS.WinForms /// </summary> public partial class WinformsDesktop : Form, IDesktop { + public List<IDesktopWidget> Widgets = new List<IDesktopWidget>(); + + private bool InScreensaver = false; private int millisecondsUntilScreensaver = 300000; @@ -65,6 +68,11 @@ namespace ShiftOS.WinForms SetupControl(desktoppanel); Shiftorium.Installed += () => { + foreach(var widget in Widgets) + { + widget.OnUpgrade(); + } + //Only if the DevX Legions story hasn't been experienced yet. if (!Shiftorium.UpgradeInstalled("devx_legions")) { @@ -161,6 +169,11 @@ namespace ShiftOS.WinForms }; SkinEngine.SkinLoaded += () => { + foreach (var widget in Widgets) + { + widget.OnSkinLoad(); + } + SetupDesktop(); }; time.Tick += (o, a) => @@ -429,6 +442,34 @@ namespace ShiftOS.WinForms desktoppanel.Dock = DockStyle.Top; } } + + pnlwidgetlayer.Show(); + pnlwidgetlayer.BringToFront(); + + if (Shiftorium.UpgradeInstalled("desktop_widgets")) + { + Widgets.Clear(); + foreach(var widget in WidgetManager.GetAllWidgetTypes()) + { + UserControl w = (UserControl)Activator.CreateInstance(widget.Value, null); + pnlwidgetlayer.Controls.Add(w); + Widgets.Add(w as IDesktopWidget); + } + } + + foreach (var widget in Widgets) + { + if (Shiftorium.UpgradeInstalled("desktop_widgets")) + { + widget.Setup(); + widget.Show(); + } + else + { + widget.Hide(); + } + } + } else { @@ -851,6 +892,7 @@ namespace ShiftOS.WinForms apps.DropDown.Hide(); pnladvancedal.Location = new Point(0, (LoadedSkin.DesktopPanelPosition == 0) ? desktoppanel.Height : this.Height - pnladvancedal.Height - desktoppanel.Height); pnladvancedal.Visible = !pnladvancedal.Visible; + pnladvancedal.BringToFront(); } } |
