From b1cace7807f28deff51f06665d544a4246879a82 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 May 2017 15:51:19 -0400 Subject: [PATCH] Newer notification system (PANEL ICONS :D) --- .../Properties/Resources.Designer.cs | 10 ++ ShiftOS.WinForms/Properties/Resources.resx | 3 + .../Resources/notestate_connection_full.bmp | Bin 0 -> 3382 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/WinformsDesktop.Designer.cs | 126 ++++++++++++++---- ShiftOS.WinForms/WinformsDesktop.cs | 78 +++++++---- ShiftOS.WinForms/WinformsDesktop.resx | 3 + ShiftOS_TheReturn/AppearanceManager.cs | 5 +- ShiftOS_TheReturn/Desktop.cs | 17 ++- ShiftOS_TheReturn/ServerManager.cs | 1 + ShiftOS_TheReturn/Skinning.cs | 8 ++ 11 files changed, 198 insertions(+), 54 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/notestate_connection_full.bmp diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 0152be8..3e83c3f 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -1048,6 +1048,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap notestate_connection_full { + get { + object obj = ResourceManager.GetObject("notestate_connection_full", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index a90e69b..1db7a46 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34600,4 +34600,7 @@ ..\Resources\Ambient9.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\notestate_connection_full.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/notestate_connection_full.bmp b/ShiftOS.WinForms/Resources/notestate_connection_full.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a4e15b3090f4b1ae655a61c7b6474e7d9352933c GIT binary patch literal 3382 zcmZ?rHDh4_12Z700mK4O%*dbsWI@0YJ_ZI5hJpW706??;lZuh81?f#o>j7h8+35O_ z?I*@8Wc|o&a_pzJeq#KBY$q-@KEL47gDgH6^y3N(WOow7M)wObdXUu&2K~rkf$X+X c_Gk! + diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 71ef161..968a31c 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -53,15 +53,20 @@ namespace ShiftOS.WinForms private void InitializeComponent() { this.desktoppanel = new System.Windows.Forms.Panel(); - this.btnnotifications = new System.Windows.Forms.Button(); + this.pnlnotifications = new System.Windows.Forms.Panel(); + this.flnotifications = new System.Windows.Forms.FlowLayoutPanel(); this.lbtime = new System.Windows.Forms.Label(); this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); 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.pnlwidgetlayer = new System.Windows.Forms.Panel(); this.pnlssicon = new System.Windows.Forms.Panel(); + this.pnlwidgetlayer = new System.Windows.Forms.Panel(); + this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); + this.pnlnotificationbox = new System.Windows.Forms.Panel(); + this.lbnotemsg = new System.Windows.Forms.Label(); + this.lbnotetitle = new System.Windows.Forms.Label(); this.pnladvancedal = new System.Windows.Forms.Panel(); this.flapps = new System.Windows.Forms.FlowLayoutPanel(); this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); @@ -70,9 +75,13 @@ namespace ShiftOS.WinForms this.pnlstatus = new System.Windows.Forms.Panel(); this.lbalstatus = new System.Windows.Forms.Label(); this.desktoppanel.SuspendLayout(); + this.pnlnotifications.SuspendLayout(); + this.flnotifications.SuspendLayout(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.pnlscreensaver.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); + this.pnlnotificationbox.SuspendLayout(); this.pnladvancedal.SuspendLayout(); this.pnlalsystemactions.SuspendLayout(); this.pnlstatus.SuspendLayout(); @@ -81,8 +90,7 @@ namespace ShiftOS.WinForms // desktoppanel // this.desktoppanel.BackColor = System.Drawing.Color.Green; - this.desktoppanel.Controls.Add(this.btnnotifications); - this.desktoppanel.Controls.Add(this.lbtime); + this.desktoppanel.Controls.Add(this.pnlnotifications); this.desktoppanel.Controls.Add(this.panelbuttonholder); this.desktoppanel.Controls.Add(this.sysmenuholder); this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top; @@ -92,28 +100,34 @@ namespace ShiftOS.WinForms this.desktoppanel.TabIndex = 0; this.desktoppanel.Paint += new System.Windows.Forms.PaintEventHandler(this.desktoppanel_Paint); // - // btnnotifications + // pnlnotifications // - this.btnnotifications.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnnotifications.AutoSize = true; - this.btnnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnnotifications.BackColor = System.Drawing.Color.Transparent; - this.btnnotifications.FlatAppearance.BorderSize = 0; - this.btnnotifications.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnnotifications.Location = new System.Drawing.Point(1066, -2); - this.btnnotifications.Name = "btnnotifications"; - this.btnnotifications.Size = new System.Drawing.Size(136, 24); - this.btnnotifications.TabIndex = 3; - this.btnnotifications.Text = "Notifications (0)"; - this.btnnotifications.UseVisualStyleBackColor = false; - this.btnnotifications.Click += new System.EventHandler(this.btnnotifications_Click); + this.pnlnotifications.Controls.Add(this.flnotifications); + this.pnlnotifications.Controls.Add(this.lbtime); + this.pnlnotifications.Cursor = System.Windows.Forms.Cursors.Default; + this.pnlnotifications.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlnotifications.Location = new System.Drawing.Point(1096, 0); + this.pnlnotifications.Name = "pnlnotifications"; + this.pnlnotifications.Size = new System.Drawing.Size(200, 24); + this.pnlnotifications.TabIndex = 3; + // + // flnotifications + // + this.flnotifications.AutoSize = true; + this.flnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flnotifications.Controls.Add(this.ntconnectionstatus); + this.flnotifications.Dock = System.Windows.Forms.DockStyle.Left; + this.flnotifications.Location = new System.Drawing.Point(0, 0); + this.flnotifications.Name = "flnotifications"; + this.flnotifications.Size = new System.Drawing.Size(22, 24); + this.flnotifications.TabIndex = 1; // // lbtime // this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.lbtime.AutoSize = true; - this.lbtime.Location = new System.Drawing.Point(3, 0); + this.lbtime.Location = new System.Drawing.Point(139, 7); this.lbtime.Name = "lbtime"; this.lbtime.Size = new System.Drawing.Size(49, 14); this.lbtime.TabIndex = 0; @@ -170,6 +184,13 @@ namespace ShiftOS.WinForms 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; + // // pnlwidgetlayer // this.pnlwidgetlayer.BackColor = System.Drawing.Color.Transparent; @@ -179,12 +200,53 @@ namespace ShiftOS.WinForms this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); this.pnlwidgetlayer.TabIndex = 1; // - // pnlssicon + // ntconnectionstatus // - 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; + this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; + this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); + this.ntconnectionstatus.Name = "ntconnectionstatus"; + this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); + this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.ntconnectionstatus.TabIndex = 0; + this.ntconnectionstatus.TabStop = false; + this.ntconnectionstatus.Tag = "digitalsociety"; + // + // pnlnotificationbox + // + this.pnlnotificationbox.AutoSize = true; + this.pnlnotificationbox.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pnlnotificationbox.Controls.Add(this.lbnotemsg); + this.pnlnotificationbox.Controls.Add(this.lbnotetitle); + this.pnlnotificationbox.Location = new System.Drawing.Point(654, 111); + this.pnlnotificationbox.Name = "pnlnotificationbox"; + this.pnlnotificationbox.Size = new System.Drawing.Size(69, 68); + this.pnlnotificationbox.TabIndex = 0; + this.pnlnotificationbox.Visible = false; + // + // lbnotemsg + // + this.lbnotemsg.AutoSize = true; + this.lbnotemsg.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbnotemsg.Location = new System.Drawing.Point(0, 34); + this.lbnotemsg.MaximumSize = new System.Drawing.Size(350, 0); + this.lbnotemsg.Name = "lbnotemsg"; + this.lbnotemsg.Padding = new System.Windows.Forms.Padding(10); + this.lbnotemsg.Size = new System.Drawing.Size(69, 34); + this.lbnotemsg.TabIndex = 1; + this.lbnotemsg.Text = "label1"; + // + // lbnotetitle + // + this.lbnotetitle.AutoSize = true; + this.lbnotetitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbnotetitle.Location = new System.Drawing.Point(0, 0); + this.lbnotetitle.Margin = new System.Windows.Forms.Padding(10); + this.lbnotetitle.Name = "lbnotetitle"; + this.lbnotetitle.Padding = new System.Windows.Forms.Padding(10); + this.lbnotetitle.Size = new System.Drawing.Size(69, 34); + this.lbnotetitle.TabIndex = 0; + this.lbnotetitle.Tag = "header2"; + this.lbnotetitle.Text = "label1"; // // pnladvancedal // @@ -262,6 +324,7 @@ namespace ShiftOS.WinForms 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.pnlnotificationbox); this.Controls.Add(this.pnlwidgetlayer); this.Controls.Add(this.pnladvancedal); this.Controls.Add(this.pnlscreensaver); @@ -274,16 +337,24 @@ namespace ShiftOS.WinForms this.Load += new System.EventHandler(this.Desktop_Load); this.desktoppanel.ResumeLayout(false); this.desktoppanel.PerformLayout(); + this.pnlnotifications.ResumeLayout(false); + this.pnlnotifications.PerformLayout(); + this.flnotifications.ResumeLayout(false); + this.flnotifications.PerformLayout(); this.sysmenuholder.ResumeLayout(false); this.sysmenuholder.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.pnlscreensaver.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); + this.pnlnotificationbox.ResumeLayout(false); + this.pnlnotificationbox.PerformLayout(); this.pnladvancedal.ResumeLayout(false); this.pnlalsystemactions.ResumeLayout(false); this.pnlalsystemactions.PerformLayout(); this.pnlstatus.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } @@ -295,7 +366,6 @@ namespace ShiftOS.WinForms private System.Windows.Forms.MenuStrip menuStrip1; 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; private System.Windows.Forms.Panel pnladvancedal; @@ -306,6 +376,12 @@ namespace ShiftOS.WinForms private System.Windows.Forms.FlowLayoutPanel flapps; private System.Windows.Forms.FlowLayoutPanel flcategories; private System.Windows.Forms.Panel pnlwidgetlayer; + private System.Windows.Forms.Panel pnlnotifications; + private System.Windows.Forms.FlowLayoutPanel flnotifications; + private System.Windows.Forms.Panel pnlnotificationbox; + private System.Windows.Forms.Label lbnotemsg; + private System.Windows.Forms.Label lbnotetitle; + private System.Windows.Forms.PictureBox ntconnectionstatus; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 4efef1b..15ecb7a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -54,6 +54,38 @@ namespace ShiftOS.WinForms private int millisecondsUntilScreensaver = 300000; + public void PushNotification(string app, string title, string msg) + { + lbnotemsg.Text = msg; + lbnotetitle.Text = title; + + var ctl = flnotifications.Controls.ToList().FirstOrDefault(x => x.Tag.ToString() == app); + if (ctl == null) + pnlnotificationbox.Left = desktoppanel.Width - pnlnotificationbox.Width; + else + { + int left = ctl.PointToScreen(ctl.Location).X; + int realleft = left - pnlnotificationbox.Width; + realleft += ctl.Width; + pnlnotificationbox.Left = realleft; + } + + + if (LoadedSkin.DesktopPanelPosition == 0) + pnlnotificationbox.Top = desktoppanel.Height; + else + pnlnotificationbox.Top = this.Height - desktoppanel.Height - pnlnotificationbox.Height; + var notekiller = new System.Windows.Forms.Timer(); + notekiller.Interval = 10000; + notekiller.Tick += (o, a) => + { + pnlnotificationbox.Hide(); + }; + Engine.AudioManager.PlayStream(Properties.Resources.infobox); + pnlnotificationbox.Show(); + notekiller.Start(); + } + /// /// Initializes a new instance of the class. /// @@ -105,24 +137,6 @@ namespace ShiftOS.WinForms }; this.TopMost = false; - NotificationDaemon.NotificationMade += (note) => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - - NotificationDaemon.NotificationRead += () => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - this.LocationChanged += (o, a) => { if (this.Left != 0) @@ -143,10 +157,6 @@ namespace ShiftOS.WinForms { if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); }; Shiftorium.Installed += () => { @@ -187,8 +197,10 @@ namespace ShiftOS.WinForms if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) { lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; + lbtime.Left = pnlnotifications.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; + + pnlnotifications.Width = flnotifications.Width + lbtime.Width + LoadedSkin.DesktopPanelClockFromRight.X; } } @@ -215,8 +227,6 @@ namespace ShiftOS.WinForms catch { } - btnnotifications.Left = lbtime.Left - btnnotifications.Width - 2; - btnnotifications.Top = (desktoppanel.Height - btnnotifications.Height) / 2; }; time.Start(); @@ -372,10 +382,13 @@ namespace ShiftOS.WinForms desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); - btnnotifications.Visible = Shiftorium.UpgradeInstalled("panel_notifications"); + ControlManager.SetupControls(pnlnotificationbox); //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + lbtime.BackColor = Color.Transparent; + pnlnotifications.BackgroundImage = GetImage("panelclockbg"); + pnlnotifications.BackgroundImageLayout = GetImageLayout("panelclockbg"); + pnlnotifications.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; panelbuttonholder.Top = 0; panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; @@ -1060,4 +1073,15 @@ namespace ShiftOS.WinForms } } } + + public static class ControlCollectionExtensions + { + public static IList ToList(this Control.ControlCollection ctrls) + { + var lst = new List(); + foreach (var ctl in ctrls) + lst.Add(ctl as Control); + return lst; + } + } } \ No newline at end of file diff --git a/ShiftOS.WinForms/WinformsDesktop.resx b/ShiftOS.WinForms/WinformsDesktop.resx index d5494e3..b77504b 100644 --- a/ShiftOS.WinForms/WinformsDesktop.resx +++ b/ShiftOS.WinForms/WinformsDesktop.resx @@ -120,4 +120,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index d8004bc..a10f419 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -226,7 +226,10 @@ namespace ShiftOS.Engine OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); - Environment.Exit(0); + Desktop.InvokeOnWorkerThread(() => + { + Environment.Exit(0); + }); } /// diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index bc17a8e..a5e7f43 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -102,7 +102,14 @@ namespace ShiftOS.Engine /// Gets the name of the desktop. /// string DesktopName { get; } - + + /// + /// Show a notification on the desktop. + /// + /// An application ID (for determining what system icon to show the notification alongside) + /// The title of the notification. + /// Isn't this.... self explanatory? + void PushNotification(string app, string title, string message); /// /// Performs most of the skinning and layout handling for the desktop. @@ -266,6 +273,14 @@ namespace ShiftOS.Engine { _desktop.HideAppLauncher(); } + + public static void PushNotification(string app, string title, string msg) + { + InvokeOnWorkerThread(() => + { + _desktop.PushNotification(app, title, msg); + }); + } } // sorry i almost killed everything :P } diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 825064b..371d8e7 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -131,6 +131,7 @@ namespace ShiftOS.Engine { if (!UserDisconnect) { + Desktop.PushNotification("digital_society_connection", "Disconnected from Digital Society.", "The ShiftOS kernel has been disconnected from the Digital Society. We are attempting to re-connect you."); TerminalBackend.PrefixEnabled = true; ConsoleEx.ForegroundColor = ConsoleColor.Red; ConsoleEx.Bold = true; diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 548e80f..4340f1a 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -276,6 +276,14 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [Image("panelclockbg")] + [ShifterMeta("Desktop")] + [ShifterCategory("Panel Clock")] + [ShifterName("Panel Clock Background Image")] + [ShifterDescription("Set the background image of the panel clock.")] + [RequiresUpgrade("skinning;shift_panel_clock")] + public byte[] PanelClockBG = null; + [ShifterMeta("System")] [ShifterCategory("Login Screen")] [RequiresUpgrade("gui_based_login_screen")]