From c18c0fbc325b1c6a0864f88c6e2f4d2889d62e18 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 May 2017 20:32:28 -0400 Subject: dithering revamp --- ShiftOS.WinForms/WinformsDesktop.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6825f34..4efef1b 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -390,10 +390,7 @@ namespace ShiftOS.WinForms this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); //Not doing this will cause an ArgumentException. - DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => - { - this.BackgroundImage = img; - })); + this.BackgroundImage = SkinEngine.GetImage("desktopbackground"); this.BackgroundImageLayout = GetImageLayout("desktopbackground"); desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; -- cgit v1.2.3 From b1cace7807f28deff51f06665d544a4246879a82 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 May 2017 15:51:19 -0400 Subject: Newer notification system (PANEL ICONS :D) --- ShiftOS.WinForms/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 | 130 ++++++++++++++++----- 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, 200 insertions(+), 56 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/notestate_connection_full.bmp (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') 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 0000000..a4e15b3 Binary files /dev/null and b/ShiftOS.WinForms/Resources/notestate_connection_full.bmp differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1079203..89da4e1 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -771,6 +771,7 @@ + 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 - // - 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); + // pnlnotifications + // + 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 - // - 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; + // ntconnectionstatus + // + 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")] -- cgit v1.2.3 From e841b168e13e0bd699c0e0d19857167aa725f1ca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 27 May 2017 16:59:54 -0400 Subject: stuff --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Controls/TerminalBox.cs | 11 ++++--- ShiftOS.WinForms/Stories/LegionStory.cs | 9 +----- ShiftOS.WinForms/WinformsDesktop.cs | 49 ++++++++++++++++++-------------- ShiftOS_TheReturn/AppearanceManager.cs | 2 +- 5 files changed, 35 insertions(+), 37 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index e150b1a..f9e601f 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -186,6 +186,7 @@ namespace ShiftOS.WinForms.Applications SendMessage(ch, ch, "A little birdie tells me you know about the RTS exploits going around... Try using that on Aiden's server. You can find his systemname on Appscape under \"Contact Us.\" He has a mailserver on Appscape - and also has RTS on the same server."); Thread.Sleep(2500); SendMessage(ch, ch, "Good luck... My life depends on you!"); + complete = true; }); t.IsBackground = true; t.Start(); diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index a6dd610..7658c8c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -63,15 +63,12 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { - Thread.Sleep(5); - this.SuspendLayout(); this.HideSelection = true; this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; - this.ResumeLayout(); } private Font ConstructFont() @@ -89,8 +86,6 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { - Thread.Sleep(5); - this.SuspendLayout(); Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); @@ -99,11 +94,12 @@ namespace ShiftOS.WinForms.Controls this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; - this.ResumeLayout(); } bool quickCopying = false; + bool busy = false; + protected override void OnMouseDown(MouseEventArgs e) { //if right-clicking, then we initiate a quick-copy. @@ -255,8 +251,11 @@ namespace ShiftOS.WinForms.Controls } } + public string ThreadId = ""; + public TerminalBox() : base() { + ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); this.Tag = "keepbg keepfg keepfont"; } } diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 9b4966f..53d55fb 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -92,14 +92,7 @@ namespace ShiftOS.WinForms.Stories ConsoleEx.ForegroundColor = ConsoleColor.Gray; ConsoleEx.Bold = false; - foreach (var c in text) - { - Desktop.InvokeOnWorkerThread(() => - { - Console.Write(c); - }); - Thread.Sleep(75); - } + Console.WriteLine(text); Thread.Sleep(1000); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 15ecb7a..6ce8cc9 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -188,14 +188,40 @@ namespace ShiftOS.WinForms widget.OnSkinLoad(); } + SetupDesktop(); }; + + long lastcp = 0; + + var storythread = new Thread(() => + { + do + { + if (SaveSystem.CurrentSave != null) + { + if (SaveSystem.CurrentSave.Codepoints != lastcp) + lastcp = SaveSystem.CurrentSave.Codepoints; + if (lastcp >= 10000) + { + if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) + { + Story.Start("victortran_shiftnet"); + } + } + } + } while (!SaveSystem.ShuttingDown); + }); + storythread.IsBackground = true; + storythread.Start(); + time.Tick += (o, a) => { if (Shiftorium.IsInitiated == true) { - if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) + if (SaveSystem.CurrentSave != null) { + lbtime.Text = Applications.Terminal.GetTime(); lbtime.Left = pnlnotifications.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; @@ -230,27 +256,6 @@ 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(); - } - millisecondsUntilScreensaver--; - Thread.Sleep(1); - } - millisecondsUntilScreensaver = 300000; - HideScreensaver(); - } - }); - ssThread.IsBackground = true; - ssThread.Start(); - this.DoubleBuffered = true; } diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 81858d3..7cf06c9 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -190,7 +190,7 @@ namespace ShiftOS.Engine ServerManager.Disconnect(); Desktop.InvokeOnWorkerThread(() => { - Environment.Exit(0); //bye bye + Process.GetCurrentProcess().Kill(); //bye bye }); } -- cgit v1.2.3 From 03ebdf42d9f12b678d48f954736664f6f3eb1f84 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 12:40:06 -0400 Subject: Funny, disabling localization makes things easier... --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Applications/Terminal.cs | 6 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 5 +- ShiftOS.WinForms/Tools/ControlManager.cs | 139 +++++++++++------------------- ShiftOS.WinForms/WinformsDesktop.cs | 10 ++- ShiftOS_TheReturn/Localization.cs | 45 +--------- ShiftOS_TheReturn/TerminalTextWriter.cs | 1 + 7 files changed, 72 insertions(+), 135 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index f9e601f..7a2de81 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -41,6 +41,7 @@ namespace ShiftOS.WinForms.Applications [WinOpen("simplesrc")] [Launcher("SimpleSRC Client", false, null, "Networking")] [DefaultTitle("SimpleSRC Client")] + [AppscapeEntry("SimpleSRC", "A simple ShiftOS Relay Chat client that allows you to talk with other ShiftOS users from all over the world.", 300, 145, "file_skimmer", "Networking")] public partial class Chat : UserControl, IShiftOSWindow { public Chat() diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index bfc4425..3d17d35 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -504,11 +504,11 @@ namespace ShiftOS.WinForms.Applications Thread.Sleep(2000); Console.WriteLine("As you know, ShiftOS doesn't have very many features."); Thread.Sleep(2000); - Console.WriteLine("Using the applications you have, I need you to earn 50,000 Codepoints."); + Console.WriteLine("Using the applications you have, I need you to earn as many Codepoints as you can."); Thread.Sleep(2000); - Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn Codepoints."); + Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn even more Codepoints."); Thread.Sleep(2000); - Console.WriteLine("Start small, try to earn 500. Once you do, I'll contact you with more details."); + Console.WriteLine("Once you earn 1,000 Codepoints, I will check back with you and see how well you've done."); Thread.Sleep(2000); Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); Thread.Sleep(2000); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 41b50a7..0eac58e 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -283,7 +283,7 @@ Name: "AL Widget Manager", Cost: 125, Description: "Desktop Widgets are a huge advancement in ShiftOS technology, allowing access to system information, and quick control of your system, without even opening a window. However, we still need to be able to modify each widget. This upgrade adds an App Launcher entry for the Desktop Widget Manager.", - Description: "app_launcher;desktop_widgets", + Dependencies: "app_launcher;desktop_widgets", Category: "GUI" }, { @@ -704,7 +704,8 @@ Name: "Artpad", Cost: 7500, Category: "Applications", - Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!" + Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!", + Dependencies: "color_depth_8_bits" }, { Name: "AL Artpad", diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 1643b23..83ab7fe 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -1,3 +1,5 @@ +#define SLOW_LOCALIZATION + /* * MIT License * @@ -144,77 +146,66 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - - if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) + Desktop.InvokeOnWorkerThread(() => { - string tag = ""; - - try + if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { - if(ctrl.Tag != null) - tag = ctrl.Tag.ToString(); - } - catch { } + string tag = ""; - if (!tag.Contains("keepbg")) - { - if (ctrl.BackColor != Control.DefaultBackColor) + try { - Desktop.InvokeOnWorkerThread(() => + if (ctrl.Tag != null) + tag = ctrl.Tag.ToString(); + } + catch { } + + if (!tag.Contains("keepbg")) + { + if (ctrl.BackColor != Control.DefaultBackColor) { ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; - }); + } } - } - if (!tag.Contains("keepfont")) - { - Desktop.InvokeOnWorkerThread(() => + if (!tag.Contains("keepfont")) { ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; ctrl.Font = SkinEngine.LoadedSkin.MainFont; - }); - if (tag.Contains("header1")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header1")) { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - }); - } + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; + }); + } - if (tag.Contains("header2")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header2")) { ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - }); - } + } - if (tag.Contains("header3")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header3")) { ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - }); + } } - } - try - { - string ctrlText = Localization.Parse(ctrl.Text); - Desktop.InvokeOnWorkerThread(() => + try + { +#if !SLOW_LOCALIZATION + if (!string.IsNullOrWhiteSpace(ctrl.Text)) + { + string ctrlText = Localization.Parse(ctrl.Text); + ctrl.Text = ctrlText; + } +#endif + } + catch { - ctrl.Text = ctrlText; - }); - } - catch - { - } + } - if(ctrl is Button) - { - Desktop.InvokeOnWorkerThread(() => + if (ctrl is Button) { Button b = ctrl as Button; if (!b.Tag.ToString().ToLower().Contains("keepbg")) @@ -229,7 +220,7 @@ namespace ShiftOS.WinForms.Tools b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if(!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!b.Tag.ToString().ToLower().Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; @@ -260,15 +251,12 @@ namespace ShiftOS.WinForms.Tools b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed"); }; - }); + } } - if(ctrl is TextBox) + if (ctrl is TextBox) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; - }); + (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; } ctrl.KeyDown += (o, a) => @@ -286,27 +274,19 @@ namespace ShiftOS.WinForms.Tools }; if (ctrl is Button) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as Button).FlatStyle = FlatStyle.Flat; - }); + (ctrl as Button).FlatStyle = FlatStyle.Flat; } else if (ctrl is WindowBorder) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as WindowBorder).Setup(); - }); + (ctrl as WindowBorder).Setup(); } - } - Desktop.InvokeOnWorkerThread(() => - { - MakeDoubleBuffered(ctrl); + ControlSetup?.Invoke(ctrl); }); - ControlSetup?.Invoke(ctrl); } + + public static event Action ControlSetup; public static void MakeDoubleBuffered(Control c) @@ -330,27 +310,12 @@ namespace ShiftOS.WinForms.Tools { Desktop.HideAppLauncher(); }; - ThreadStart ts = () => - { - var ctrls = frm.Controls.ToList(); - for (int i = 0; i < ctrls.Count(); i++) - { - SetupControls(ctrls[i]); - } - SetupControl(frm); - - }; - - if (runInThread == true) - { - var t = new Thread(ts); - t.IsBackground = true; - t.Start(); - } - else + var ctrls = frm.Controls.ToList(); + for (int i = 0; i < ctrls.Count(); i++) { - ts?.Invoke(); + SetupControls(ctrls[i]); } + SetupControl(frm); } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6ce8cc9..85eab55 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -202,13 +202,21 @@ namespace ShiftOS.WinForms { if (SaveSystem.CurrentSave.Codepoints != lastcp) lastcp = SaveSystem.CurrentSave.Codepoints; - if (lastcp >= 10000) + if (lastcp >= 2500) { if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) { Story.Start("victortran_shiftnet"); } } + if(lastcp >= 5000) + { + if(Shiftorium.UpgradeInstalled("triwrite") && Shiftorium.UpgradeInstalled("simplesrc") && Shiftorium.UpgradeInstalled("victortran_shiftnet") && Shiftorium.UpgradeInstalled("story_hacker101_breakingthebonds")) + { + if (!Shiftorium.UpgradeInstalled("story_thefennfamily")) + Story.Start("story_thefennfamily"); + } + } } } while (!SaveSystem.ShuttingDown); }); diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 5d848b0..c542c2a 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -111,50 +111,11 @@ namespace ShiftOS.Engine localizationStrings = JsonConvert.DeserializeObject>(Utils.ReadAllText(Paths.GetPath("english.local"))); //if no provider fall back to english } - foreach (var kv in localizationStrings) + foreach (var kv in localizationStrings.Where(x=>original.Contains(x.Key))) { original = original.Replace(kv.Key, kv.Value); // goes through and replaces all the localization blocks } - List orphaned = new List(); - - - int start_index = 0; - int length = 0; - bool indexing = false; - - foreach (var c in original) - { - // start paying attenion when you see a "{" - if (c == '{') - { - start_index = original.IndexOf(c); - indexing = true; - } - - if (indexing == true) - { - // stop paying attention when you see a "}" after seeing a "{" - length++; - if (c == '}') - { - indexing = false; - string o = original.Substring(start_index, length); - if (!orphaned.Contains(o)) - { - orphaned.Add(o); - } - start_index = 0; - length = 0; - } - } - } - - if (orphaned.Count > 0) - { - Utils.WriteAllText("0:/dev_orphaned_lang.txt", JsonConvert.SerializeObject(orphaned, Formatting.Indented)); //format if from this txt file - } - //string original2 = Parse(original); string usernameReplace = ""; @@ -203,13 +164,13 @@ namespace ShiftOS.Engine }; // actually do the replacement - foreach (KeyValuePair replacement in replace) + foreach (KeyValuePair replacement in replace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, Parse(replacement.Value)); } // do the replacement but default - foreach (KeyValuePair replacement in defaultReplace) + foreach (KeyValuePair replacement in defaultReplace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, replacement.Value); } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 4c0c3a0..63e88eb 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -42,6 +42,7 @@ namespace ShiftOS.Engine { ConsoleEx.OnFlush = () => { + System.Diagnostics.Debug.WriteLine("[terminal] " + buffer); Desktop.InvokeOnWorkerThread(() => { UnderlyingControl?.Write(buffer); -- cgit v1.2.3 From 37ac4c684ce3904c5ec614362ed99bb9867ca0f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 May 2017 20:08:30 -0400 Subject: It's amazing what talking to Rylan can do to an integer datatype. --- ShiftOS.Objects/EngineShiftnetSubscription.cs | 2 +- ShiftOS.Objects/Save.cs | 4 ++-- ShiftOS.Objects/Shop.cs | 2 +- ShiftOS.Objects/UniteClient.cs | 12 ++++++------ ShiftOS.WinForms/Applications/Pong.cs | 20 ++++++++++---------- ShiftOS.WinForms/Applications/ShiftLetters.cs | 2 +- ShiftOS.WinForms/Applications/ShiftLotto.cs | 4 ++-- ShiftOS.WinForms/Applications/ShiftSweeper.cs | 8 ++++---- ShiftOS.WinForms/Applications/Shifter.cs | 2 +- ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs | 4 ++-- ShiftOS.WinForms/Applications/ShopItemCreator.cs | 4 ++-- ShiftOS.WinForms/HackerCommands.cs | 2 +- ShiftOS.WinForms/JobTasks.cs | 4 ++-- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 4 ++-- ShiftOS.WinForms/WinformsDesktop.cs | 2 +- ShiftOS_TheReturn/Commands.cs | 4 ++-- ShiftOS_TheReturn/SaveSystem.cs | 4 ++-- ShiftOS_TheReturn/Scripting.cs | 4 ++-- ShiftOS_TheReturn/ServerManager.cs | 2 +- ShiftOS_TheReturn/Shiftorium.cs | 10 +++++----- 20 files changed, 50 insertions(+), 50 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.Objects/EngineShiftnetSubscription.cs b/ShiftOS.Objects/EngineShiftnetSubscription.cs index 1296a98..c319f18 100644 --- a/ShiftOS.Objects/EngineShiftnetSubscription.cs +++ b/ShiftOS.Objects/EngineShiftnetSubscription.cs @@ -10,7 +10,7 @@ namespace ShiftOS.Objects { public string Name { get; set; } public string Description { get; set; } - public int CostPerMonth { get; set; } + public uint CostPerMonth { get; set; } public int DownloadSpeed { get; set; } public string Company { get; set; } } diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 8675a35..0fef7b3 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -41,9 +41,9 @@ namespace ShiftOS.Objects [Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")] public string Username { get; set; } - private long _cp = 0; + private ulong _cp = 0; - public long Codepoints + public ulong Codepoints { get { diff --git a/ShiftOS.Objects/Shop.cs b/ShiftOS.Objects/Shop.cs index 65f5746..c603523 100644 --- a/ShiftOS.Objects/Shop.cs +++ b/ShiftOS.Objects/Shop.cs @@ -42,7 +42,7 @@ namespace ShiftOS.Objects { public string Name { get; set; } public string Description { get; set; } - public int Cost { get; set; } + public ulong Cost { get; set; } public int FileType { get; set; } public byte[] MUDFile { get; set; } } diff --git a/ShiftOS.Objects/UniteClient.cs b/ShiftOS.Objects/UniteClient.cs index d8e34b7..ccd721b 100644 --- a/ShiftOS.Objects/UniteClient.cs +++ b/ShiftOS.Objects/UniteClient.cs @@ -83,9 +83,9 @@ namespace ShiftOS.Unite /// Get the Pong codepoint highscore for the current user. /// /// The amount of Codepoints returned by the server - public int GetPongCP() + public ulong GetPongCP() { - return Convert.ToInt32(MakeCall("/API/GetPongCP")); + return Convert.ToUInt64(MakeCall("/API/GetPongCP")); } /// @@ -110,7 +110,7 @@ namespace ShiftOS.Unite /// Set the pong Codepoints record for the user /// /// The amount of Codepoints to set the record to - public void SetPongCP(int value) + public void SetPongCP(ulong value) { MakeCall("/API/SetPongCP/" + value.ToString()); } @@ -182,16 +182,16 @@ namespace ShiftOS.Unite /// Get the user's codepoints. /// /// The amount of codepoints stored on the server for this user. - public long GetCodepoints() + public ulong GetCodepoints() { - return Convert.ToInt64(MakeCall("/API/GetCodepoints")); + return Convert.ToUInt64(MakeCall("/API/GetCodepoints")); } /// /// Set the user's codepoints. /// /// The amount of codepoints to set the user's codepoints value to. - public void SetCodepoints(long value) + public void SetCodepoints(ulong value) { MakeCall("/API/SetCodepoints/" + value.ToString()); } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 84177b7..6d81c64 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -58,10 +58,10 @@ namespace ShiftOS.WinForms.Applications double incrementy = 0.2; int levelxspeed = 3; int levelyspeed = 3; - int beatairewardtotal; - int beataireward = 1; - int[] levelrewards = new int[50]; - int totalreward; + ulong beatairewardtotal; + ulong beataireward = 1; + ulong[] levelrewards = new ulong[50]; + ulong totalreward; int countdown = 3; bool aiShouldIsbeEnabled = true; @@ -297,11 +297,11 @@ namespace ShiftOS.WinForms.Applications lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) { - totalreward = levelrewards[level - 1] + beatairewardtotal; + totalreward = (ulong)(levelrewards[level - 1] + beatairewardtotal); double onePercent = (totalreward / 100); lblbutyougained.Show(); lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100)); + SaveSystem.TransferCodepointsFrom("pong", (ulong)(totalreward / 100)); } else { @@ -715,10 +715,10 @@ namespace ShiftOS.WinForms.Applications { if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { - beataireward = level * 10; + beataireward = (ulong)(level * 10); } else { - beataireward = level * 5; + beataireward = (ulong)(level * 5); } } else @@ -726,11 +726,11 @@ namespace ShiftOS.WinForms.Applications if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; + beataireward = (ulong)Math.Round(br) * 10; } else { double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; + beataireward = (ulong)Math.Round(br) * 5; } } diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index 42e19f8..0e9f74a 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -217,7 +217,7 @@ namespace ShiftOS.WinForms.Applications if (!lblword.Text.Contains("_")) { int oldlives = lives; - int cp = (word.Length * oldlives) * 2; //drunky michael made this 5x... + ulong cp = (ulong)(word.Length * oldlives) * 2; //drunky michael made this 5x... SaveSystem.TransferCodepointsFrom("shiftletters", cp); StartGame(); } diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index 5ab8154..3f940c7 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -88,7 +88,7 @@ namespace ShiftOS.WinForms.Applications } else { - if (SaveSystem.CurrentSave.Codepoints - (codePoints * difficulty) <= 0) + if (SaveSystem.CurrentSave.Codepoints - (ulong)(codePoints * difficulty) <= 0) { Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to gamble this amount!"); } @@ -102,7 +102,7 @@ namespace ShiftOS.WinForms.Applications int winningNumber = rnd.Next(0, difficulty); // Multiply CodePoints * Difficulty - int jackpot = codePoints * difficulty; + ulong jackpot = (ulong)(codePoints * difficulty); // Test the random ints if (guessedNumber == winningNumber) diff --git a/ShiftOS.WinForms/Applications/ShiftSweeper.cs b/ShiftOS.WinForms/Applications/ShiftSweeper.cs index f23ed73..772ec26 100644 --- a/ShiftOS.WinForms/Applications/ShiftSweeper.cs +++ b/ShiftOS.WinForms/Applications/ShiftSweeper.cs @@ -300,12 +300,12 @@ namespace ShiftOS.WinForms.Applications { } public void winGame() { - int cp = 0; - int origminecount = gameBombCount * 10; + ulong cp = 0; + ulong origminecount = (ulong)(gameBombCount * 10); if (minetimer < 31) cp = (origminecount * 3); - else if (minetimer < 61) cp = (Int32)(origminecount * 2.5); + else if (minetimer < 61) cp = (ulong)(origminecount * 2.5); else if (minetimer < 91) cp = (origminecount * 2); - else if (minetimer < 121) cp = (Int32)(origminecount * 1.5); + else if (minetimer < 121) cp = (ulong)(origminecount * 1.5); else if (minetimer > 120) cp = (origminecount * 1); SaveSystem.TransferCodepointsFrom("shiftsweeper", cp); panelGameStatus.Image = Properties.Resources.SweeperWinFace; diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 1a59c80..3b3a4f1 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -391,7 +391,7 @@ namespace ShiftOS.WinForms.Applications } - public int CodepointValue = 0; + public uint CodepointValue = 0; public List settings = new List(); public Skin LoadedSkin = null; diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 08e6c8f..d6b014d 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -213,9 +213,9 @@ namespace ShiftOS.WinForms.Applications private void btnbuy_Click(object sender, EventArgs e) { - long cpCost = 0; + ulong cpCost = 0; backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); + Dictionary UpgradesToBuy = new Dictionary(); foreach (var itm in lbupgrades.SelectedItems) { cpCost += upgrades[itm.ToString()].Cost; diff --git a/ShiftOS.WinForms/Applications/ShopItemCreator.cs b/ShiftOS.WinForms/Applications/ShopItemCreator.cs index 61e7491..d2836ee 100644 --- a/ShiftOS.WinForms/Applications/ShopItemCreator.cs +++ b/ShiftOS.WinForms/Applications/ShopItemCreator.cs @@ -73,7 +73,7 @@ namespace ShiftOS.WinForms.Applications Infobox.Show("No file chosen.", "Please select a file to sell."); return; } - Item.Cost = Convert.ToInt32(txtcost.Text); + Item.Cost = Convert.ToUInt64(txtcost.Text); Item.Description = txtdescription.Text; Item.Name = txtitemname.Text; Callback?.Invoke(Item); @@ -101,7 +101,7 @@ namespace ShiftOS.WinForms.Applications { try { - Item.Cost = Convert.ToInt32(txtcost.Text); + Item.Cost = Convert.ToUInt64(txtcost.Text); } catch { diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 47b486d..f467eb2 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -504,7 +504,7 @@ namespace ShiftOS.WinForms string usr = args["user"].ToString(); string sys = args["sys"].ToString(); string pass = args["pass"].ToString(); - long amount = (long)args["amount"]; + ulong amount = (ulong)args["amount"]; if(amount < 0) { Console.WriteLine("--invalid codepoint amount - halting..."); diff --git a/ShiftOS.WinForms/JobTasks.cs b/ShiftOS.WinForms/JobTasks.cs index 622e287..d862961 100644 --- a/ShiftOS.WinForms/JobTasks.cs +++ b/ShiftOS.WinForms/JobTasks.cs @@ -35,12 +35,12 @@ namespace ShiftOS.WinForms { public class AcquireCodepointsJobTask : JobTask { - public AcquireCodepointsJobTask(int amount) + public AcquireCodepointsJobTask(uint amount) { CodepointsRequired = SaveSystem.CurrentSave.Codepoints + amount; } - public long CodepointsRequired { get; private set; } + public ulong CodepointsRequired { get; private set; } public override bool IsComplete { diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index fa575f4..c7830d0 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -372,7 +372,7 @@ namespace ShiftOS.WinForms /// public class AppscapeEntryAttribute : RequiresUpgradeAttribute { - public AppscapeEntryAttribute(string name, string description, int downloadSize, long cost, string dependencies = "", string category = "Misc") : base(name.ToLower().Replace(' ', '_')) + public AppscapeEntryAttribute(string name, string description, int downloadSize, ulong cost, string dependencies = "", string category = "Misc") : base(name.ToLower().Replace(' ', '_')) { Name = name; Description = description; @@ -385,7 +385,7 @@ namespace ShiftOS.WinForms public string Name { get; private set; } public string Description { get; private set; } public string Category { get; private set; } - public long Cost { get; private set; } + public ulong Cost { get; private set; } public string DependencyString { get; private set; } public int DownloadSize { get; private set; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 85eab55..95e7c1a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -192,7 +192,7 @@ namespace ShiftOS.WinForms SetupDesktop(); }; - long lastcp = 0; + ulong lastcp = 0; var storythread = new Thread(() => { diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index b97cd1d..ec89539 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -311,7 +311,7 @@ namespace ShiftOS.Engine if (args.ContainsKey("amount")) try { - long codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); + ulong codepointsToAdd = Convert.ToUInt64(args["amount"].ToString()); SaveSystem.CurrentSave.Codepoints += codepointsToAdd; return true; } @@ -639,7 +639,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); cat = args["cat"].ToString(); } - Dictionary upgrades = new Dictionary(); + Dictionary upgrades = new Dictionary(); int maxLength = 5; IEnumerable upglist = Shiftorium.GetAvailable(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index d1b92fd..395db85 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -480,7 +480,7 @@ namespace ShiftOS.Engine /// Deducts a set amount of Codepoints from the save file... and sends them to a place where they'll never be seen again. /// /// The amount of Codepoints to deduct. - public static void TransferCodepointsToVoid(long amount) + public static void TransferCodepointsToVoid(ulong amount) { if (amount < 0) throw new ArgumentOutOfRangeException("We see what you did there. Trying to pull Codepoints from the void? That won't work."); @@ -584,7 +584,7 @@ namespace ShiftOS.Engine /// /// The character name /// The amount of Codepoints. - public static void TransferCodepointsFrom(string who, long amount) + public static void TransferCodepointsFrom(string who, ulong amount) { if (amount < 0) throw new ArgumentOutOfRangeException("We see what you did there... You can't just give a fake character Codepoints like that. It's better if you transfer them to the void."); diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 61c6676..5021f50 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -444,7 +444,7 @@ end"); /// Retrieves the user's Codepoints from the save file. /// /// The user's Codepoints. - public long getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } + public ulong getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } /// /// Run a command in the Terminal. @@ -462,7 +462,7 @@ end"); /// Adds the specified amount of Codepoints to the save flie. /// /// The codepoints to add. - public void addCodepoints(int cp) + public void addCodepoints(uint cp) { if (cp > 100 || cp <= 0) { diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index abb674d..1439c0d 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -246,7 +246,7 @@ Ping: {ServerManager.DigitalSocietyPing} ms var args = JsonConvert.DeserializeObject>(msg.Contents); if(args["username"] as string == SaveSystem.CurrentUser.Username) { - SaveSystem.CurrentSave.Codepoints += (long)args["amount"]; + SaveSystem.CurrentSave.Codepoints += (ulong)args["amount"]; Desktop.InvokeOnWorkerThread(new Action(() => { Infobox.Show($"MUD Control Centre", $"Someone bought an item in your shop, and they have paid {args["amount"]}, and as such, you have been granted these Codepoints."); diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index bd7105f..975939f 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -112,7 +112,7 @@ namespace ShiftOS.Engine /// The upgrade ID to buy /// The amount of Codepoints to deduct /// True if the upgrade was installed successfully, false if the user didn't have enough Codepoints or the upgrade wasn' found. - public static bool Buy(string id, long cost) + public static bool Buy(string id, ulong cost) { if (SaveSystem.CurrentSave.Codepoints >= cost) { @@ -365,7 +365,7 @@ namespace ShiftOS.Engine /// /// The upgrade ID to search /// The codepoint value. - public static long GetCPValue(string id) + public static ulong GetCPValue(string id) { foreach (var upg in GetDefaults()) { @@ -520,7 +520,7 @@ namespace ShiftOS.Engine { public string Name { get; set; } public string Description { get; set; } - public long Cost { get; set; } + public ulong Cost { get; set; } public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } public string Id { get; set; } public string Category { get; set; } @@ -536,7 +536,7 @@ namespace ShiftOS.Engine public class ShiftoriumUpgradeAttribute : RequiresUpgradeAttribute { - public ShiftoriumUpgradeAttribute(string name, long cost, string desc, string dependencies, string category) : base(name.ToLower().Replace(" ", "_")) + public ShiftoriumUpgradeAttribute(string name, ulong cost, string desc, string dependencies, string category) : base(name.ToLower().Replace(" ", "_")) { Name = name; Description = desc; @@ -547,7 +547,7 @@ namespace ShiftOS.Engine public string Name { get; private set; } public string Description { get; private set; } - public long Cost { get; private set; } + public ulong Cost { get; private set; } public string Dependencies { get; private set; } public string Category { get; private set; } } -- cgit v1.2.3 From ecf5297dbb9fd551005963dc1d430ed348848390 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 May 2017 21:50:19 -0400 Subject: slightly fix balloon notes --- ShiftOS.WinForms/WinformsDesktop.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 95e7c1a..76c5050 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -47,8 +47,24 @@ namespace ShiftOS.WinForms /// /// Winforms desktop. /// + [Namespace("desktop")] public partial class WinformsDesktop : Form, IDesktop { + [Command("pushnote")] + [RequiresArgument("target")] + [RequiresArgument("title")] + [RequiresArgument("body")] + public static bool PushNote(Dictionary args) + { + string ta = args["target"].ToString(); + string ti = args["title"].ToString(); + string bo = args["body"].ToString(); + + Desktop.PushNotification(ta, ti, bo); + + return true; + } + public List Widgets = new List(); @@ -64,7 +80,7 @@ namespace ShiftOS.WinForms pnlnotificationbox.Left = desktoppanel.Width - pnlnotificationbox.Width; else { - int left = ctl.PointToScreen(ctl.Location).X; + int left = ctl.Parent.PointToScreen(ctl.Location).X; int realleft = left - pnlnotificationbox.Width; realleft += ctl.Width; pnlnotificationbox.Left = realleft; @@ -75,6 +91,7 @@ namespace ShiftOS.WinForms pnlnotificationbox.Top = desktoppanel.Height; else pnlnotificationbox.Top = this.Height - desktoppanel.Height - pnlnotificationbox.Height; + ControlManager.SetupControls(pnlnotificationbox); var notekiller = new System.Windows.Forms.Timer(); notekiller.Interval = 10000; notekiller.Tick += (o, a) => @@ -83,6 +100,7 @@ namespace ShiftOS.WinForms }; Engine.AudioManager.PlayStream(Properties.Resources.infobox); pnlnotificationbox.Show(); + pnlnotificationbox.BringToFront(); notekiller.Start(); } -- cgit v1.2.3 From 3dd402277bba874f24fab11865d257133c6f782c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 08:40:29 -0400 Subject: Fix sizing issue with notifications, and UP key in terminal --- ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/WinformsDesktop.cs | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 080e8bb..a4b77ae 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -338,6 +338,7 @@ namespace ShiftOS.WinForms.Applications var tostring3 = txt.Lines[txt.Lines.Length - 1]; if (tostring3 == $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") Console.Write(TerminalBackend.LastCommand); + ConsoleEx.OnFlush?.Invoke(); a.SuppressKeyPress = true; } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 76c5050..643c02a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -74,6 +74,10 @@ namespace ShiftOS.WinForms { lbnotemsg.Text = msg; lbnotetitle.Text = title; + int height = pnlnotificationbox.Height; + pnlnotificationbox.AutoSize = false; + pnlnotificationbox.Height = height; + pnlnotificationbox.Width = lbnotetitle.Width; var ctl = flnotifications.Controls.ToList().FirstOrDefault(x => x.Tag.ToString() == app); if (ctl == null) @@ -97,8 +101,11 @@ namespace ShiftOS.WinForms notekiller.Tick += (o, a) => { pnlnotificationbox.Hide(); + pnlnotificationbox.AutoSize = true; }; Engine.AudioManager.PlayStream(Properties.Resources.infobox); + + pnlnotificationbox.Show(); pnlnotificationbox.BringToFront(); notekiller.Start(); -- cgit v1.2.3 From c63117276194d18890f14c75b8864749fbd33a0e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 09:03:19 -0400 Subject: modular notifications --- ShiftOS.WinForms/WinformsDesktop.cs | 44 +++++++++++++++++++++++++++++++++ ShiftOS_TheReturn/IStatusIcon.cs | 14 +++++++++++ ShiftOS_TheReturn/NotificationDaemon.cs | 30 ++++++++++++++++++++++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + 4 files changed, 89 insertions(+) create mode 100644 ShiftOS_TheReturn/IStatusIcon.cs (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 643c02a..0cfd667 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -70,6 +70,46 @@ namespace ShiftOS.WinForms private int millisecondsUntilScreensaver = 300000; + public void LoadIcons() + { + //That shot me back to 0.0.x with that name. Whatever. + flnotifications.Controls.Clear(); //Clear the status tray + + foreach(var itype in NotificationDaemon.GetAllStatusIcons()) + { + //We have the types. No need for shiftorium calls or anything. + //First create the icon control... + + var ic = new PictureBox(); + //We can use the type name, in lowercase, for the icon tag. + ic.Tag = itype.Name.ToLower(); + //Next get the icon data if any. + + var iconattrib = itype.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultIconAttribute) as DefaultIconAttribute; + if(iconattrib != null) + { + //We can use this attribute's ID in the skin engine to get an icon. + var img = GetIcon(iconattrib.ID); + //Make it transparent. + (img as Bitmap).MakeTransparent(LoadedSkin.SystemKey); + //Assign it to the control + ic.Image = img; + //Set the sizing mode + ic.SizeMode = PictureBoxSizeMode.StretchImage; + } + else + { + ic.BackColor = Color.White; //TODO: Make it skinnable. + } + ic.Size = new Size(20, 20); //TODO: make it skinnable + //add to the notification tray + flnotifications.Controls.Add(ic); + ic.Show(); + + //TODO: Settings pane on click. + } + } + public void PushNotification(string app, string title, string msg) { lbnotemsg.Text = msg; @@ -134,6 +174,8 @@ namespace ShiftOS.WinForms widget.OnUpgrade(); } + LoadIcons(); + //Only if the DevX Legions story hasn't been experienced yet. if (!Shiftorium.UpgradeInstalled("devx_legions")) { @@ -180,6 +222,7 @@ namespace ShiftOS.WinForms SaveSystem.GameReady += () => { + this.Invoke(new Action(LoadIcons)); if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); }; @@ -208,6 +251,7 @@ namespace ShiftOS.WinForms }; SkinEngine.SkinLoaded += () => { + LoadIcons(); foreach (var widget in Widgets) { widget.OnSkinLoad(); diff --git a/ShiftOS_TheReturn/IStatusIcon.cs b/ShiftOS_TheReturn/IStatusIcon.cs new file mode 100644 index 0000000..f32d1c1 --- /dev/null +++ b/ShiftOS_TheReturn/IStatusIcon.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public interface IStatusIcon + { + void Setup(); + + } +} diff --git a/ShiftOS_TheReturn/NotificationDaemon.cs b/ShiftOS_TheReturn/NotificationDaemon.cs index a90510a..0725782 100644 --- a/ShiftOS_TheReturn/NotificationDaemon.cs +++ b/ShiftOS_TheReturn/NotificationDaemon.cs @@ -25,6 +25,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; @@ -34,6 +35,35 @@ namespace ShiftOS.Engine { public static class NotificationDaemon { + /// + /// Gets a list of all objects that meet their Shiftorium dependencies. + /// + /// An array of s containing the found objects. + public static Type[] GetAllStatusIcons() + { + List lst = new List(); + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IStatusIcon)))) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + lst.Add(type); + } + } + } + catch { } + } + } + return lst.ToArray(); + } + + //if the notifications file already exists then get them public static Notification[] GetAllFromFile() { diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 4cbce72..f70c41e 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -109,6 +109,7 @@ + -- cgit v1.2.3 From b0da30bbde2bb198850ea45dc0006762b23f99a3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 09:14:27 -0400 Subject: COMPLETELY WORKING notification system! --- ShiftOS.WinForms/WinformsDesktop.cs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 0cfd667..b9c4f37 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -106,7 +106,32 @@ namespace ShiftOS.WinForms flnotifications.Controls.Add(ic); ic.Show(); - //TODO: Settings pane on click. + ic.Click += (o, a) => + { + HideAppLauncher(); + + if(itype.BaseType == typeof(UserControl)) + { + UserControl ctrl = (UserControl)Activator.CreateInstance(itype); + (ctrl as IStatusIcon).Setup(); + currentSettingsPane = ctrl; + if(LoadedSkin.DesktopPanelPosition == 0) + { + ctrl.Top = desktoppanel.Height; + } + else + { + ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height; + } + int noteleft = flnotifications.PointToScreen(ic.Location).X; + int realleft = (this.Width - (noteleft + ic.Width)) - ctrl.Width; + ctrl.Left = realleft; + ControlManager.SetupControls(ctrl); + ctrl.Show(); + } + + + }; } } @@ -151,6 +176,8 @@ namespace ShiftOS.WinForms notekiller.Start(); } + private UserControl currentSettingsPane = null; + /// /// Initializes a new instance of the class. /// @@ -1101,6 +1128,8 @@ namespace ShiftOS.WinForms { this.Invoke(new Action(() => { + currentSettingsPane?.Hide(); + currentSettingsPane = null; pnladvancedal.Hide(); })); } -- cgit v1.2.3 From 324104eb0b8650969b2205404e3ad83401fb100e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 19:23:40 -0400 Subject: volume control slider and other goodies --- ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 88 ++++++++------- ShiftOS.WinForms/Properties/Resources.Designer.cs | 16 ++- ShiftOS.WinForms/Properties/Resources.resx | 3 + ShiftOS.WinForms/Resources/iconSpeaker.bmp | Bin 0 -> 3382 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 19 ++++ .../StatusIcons/ShiftnetStatus.Designer.cs | 90 ++++++++++++++++ ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs | 33 ++++++ ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/StatusIcons/Volume.Designer.cs | 59 ++++++++++ ShiftOS.WinForms/StatusIcons/Volume.cs | 67 ++++++++++++ ShiftOS.WinForms/StatusIcons/Volume.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/Tools/ControlManager.cs | 15 ++- ShiftOS.WinForms/WinformsDesktop.Designer.cs | 29 ++--- ShiftOS.WinForms/WinformsDesktop.cs | 32 +++--- ShiftOS.WinForms/WinformsDesktop.resx | 3 - 15 files changed, 617 insertions(+), 77 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/iconSpeaker.bmp create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.cs create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.resx (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index ceaff02..c5a6d05 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -140,51 +140,65 @@ namespace ShiftOS.WinForms.Controls protected override void OnPaint(PaintEventArgs pe) { - pe.Graphics.Clear(this.RealBackColor); - if(RealBackgroundImage != null) + try { - pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); - } - switch (Style) - { - case ProgressBarStyle.Continuous: - double width = linear(this.Value, 0, this.Maximum, 0, this.Width); - if (ProgressImage != null) - { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); - } - else - { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); - } - break; - case ProgressBarStyle.Blocks: - int block_count = this.Width / (this.BlockSize + 2); - int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); - for(int i = 0; i < blocks - 1; i++) - { - int position = i * (BlockSize + 2); + pe.Graphics.Clear(this.RealBackColor); + if (RealBackgroundImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); + } + switch (Style) + { + case ProgressBarStyle.Continuous: + double width = linear(this.Value, 0, this.Maximum, 0, this.Width); if (ProgressImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); + } + break; + case ProgressBarStyle.Blocks: + int block_count = this.Width / (this.BlockSize + 2); + int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); + for (int i = 0; i < blocks - 1; i++) + { + int position = i * (BlockSize + 2); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + } + } + break; + case ProgressBarStyle.Marquee: + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } else { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } - } - break; - case ProgressBarStyle.Marquee: - if (ProgressImage != null) - { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - } - else - { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - } - break; + break; + } + } + catch + { + pe.Graphics.Clear(Color.Black); + string text = "Preview mode. This control can't be drawn without an initiated ShiftOS engine."; + SizeF sz = pe.Graphics.MeasureString(text, this.Font); + PointF loc = new PointF( + (this.Width - sz.Width) / 2, + (this.Height - sz.Height) / 2 + ); + pe.Graphics.DrawString(text, Font, new SolidBrush(Color.White), loc); } } diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 3e83c3f..0386237 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -947,6 +947,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap iconSpeaker { + get { + object obj = ResourceManager.GetObject("iconSpeaker", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1103,9 +1113,9 @@ namespace ShiftOS.WinForms.Properties { /// Category: "Enhancements", /// }, /// { - /// Name: "GUI Based Login Screen", - /// Cost: 500, - /// Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, w [rest of string was truncated]";. + /// Name: "Shift Progress Bar", + /// Cost: 150, + /// Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground an [rest of string was truncated]";. /// internal static string Shiftorium { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 1db7a46..d1a3544 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34603,4 +34603,7 @@ ..\Resources\notestate_connection_full.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\iconSpeaker.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/iconSpeaker.bmp b/ShiftOS.WinForms/Resources/iconSpeaker.bmp new file mode 100644 index 0000000..ec2defb Binary files /dev/null and b/ShiftOS.WinForms/Resources/iconSpeaker.bmp differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 65a512e..fd875e9 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -403,6 +403,18 @@ + + UserControl + + + ShiftnetStatus.cs + + + UserControl + + + Volume.cs + @@ -601,6 +613,12 @@ ShiftSoft_Ping.cs + + ShiftnetStatus.cs + + + Volume.cs + UniteLoginDialog.cs @@ -827,6 +845,7 @@ + diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs new file mode 100644 index 0000000..65aed28 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs @@ -0,0 +1,90 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class ShiftnetStatus + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.lbserviceprovider = new System.Windows.Forms.Label(); + this.lbstatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(5); + this.label1.Size = new System.Drawing.Size(53, 23); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "Shiftnet"; + // + // lbserviceprovider + // + this.lbserviceprovider.AutoSize = true; + this.lbserviceprovider.Dock = System.Windows.Forms.DockStyle.Top; + this.lbserviceprovider.Location = new System.Drawing.Point(0, 23); + this.lbserviceprovider.Name = "lbserviceprovider"; + this.lbserviceprovider.Padding = new System.Windows.Forms.Padding(5); + this.lbserviceprovider.Size = new System.Drawing.Size(98, 23); + this.lbserviceprovider.TabIndex = 1; + this.lbserviceprovider.Tag = "header3"; + this.lbserviceprovider.Text = "Freebie Solutions"; + // + // lbstatus + // + this.lbstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbstatus.Location = new System.Drawing.Point(0, 46); + this.lbstatus.Name = "lbstatus"; + this.lbstatus.Padding = new System.Windows.Forms.Padding(5); + this.lbstatus.Size = new System.Drawing.Size(331, 144); + this.lbstatus.TabIndex = 2; + this.lbstatus.Text = "This will show the Shiftnet status."; + // + // ShiftnetStatus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbstatus); + this.Controls.Add(this.lbserviceprovider); + this.Controls.Add(this.label1); + this.Name = "ShiftnetStatus"; + this.Size = new System.Drawing.Size(331, 190); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lbserviceprovider; + private System.Windows.Forms.Label lbstatus; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs new file mode 100644 index 0000000..f1d31af --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs @@ -0,0 +1,33 @@ +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.StatusIcons +{ + [DefaultIcon("iconShiftnet")] + [RequiresUpgrade("victortran_shiftnet")] + public partial class ShiftnetStatus : UserControl, IStatusIcon + { + public ShiftnetStatus() + { + InitializeComponent(); + } + + public void Setup() + { + var subscription = Applications.DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription]; + float kilobytes = (float)subscription.DownloadSpeed / 1024F; + lbserviceprovider.Text = subscription.Name; + lbstatus.Text = $@"Company: {subscription.Company} +Download speed (KB/s): {kilobytes}"; + + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs b/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs new file mode 100644 index 0000000..aa8aa7a --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs @@ -0,0 +1,59 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class Volume + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lbvolume = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbvolume + // + this.lbvolume.AutoSize = true; + this.lbvolume.Location = new System.Drawing.Point(4, 4); + this.lbvolume.Name = "lbvolume"; + this.lbvolume.Size = new System.Drawing.Size(81, 13); + this.lbvolume.TabIndex = 0; + this.lbvolume.Text = "System volume:"; + // + // Volume + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbvolume); + this.Name = "Volume"; + this.Size = new System.Drawing.Size(444, 44); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbvolume; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/Volume.cs b/ShiftOS.WinForms/StatusIcons/Volume.cs new file mode 100644 index 0000000..329faf0 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.cs @@ -0,0 +1,67 @@ +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; +using ShiftOS.WinForms.Controls; + +namespace ShiftOS.WinForms.StatusIcons +{ + [DefaultIcon("iconSpeaker")] + public partial class Volume : UserControl, IStatusIcon + { + public Volume() + { + InitializeComponent(); + } + + public void Setup() + { + lbvolume.Top = (this.Height - lbvolume.Height) / 2; + bool moving = false; + var prg = new ShiftedProgressBar(); + prg.Tag = "ignoreal"; //Don't close AL or current widget when this control is clicked. + this.Controls.Add(prg); + prg.Height = this.Height / 3; + prg.Maximum = 100; + prg.Value = SaveSystem.CurrentSave.MusicVolume; + prg.Width = this.Width - lbvolume.Width - 50; + prg.Left = lbvolume.Left + lbvolume.Width + 15; + prg.Top = (this.Height - prg.Height) / 2; + prg.MouseDown += (o, a) => + { + moving = true; + }; + + prg.MouseMove += (o, a) => + { + if (moving) + { + int val = (int)linear(a.X, 0, prg.Width, 0, 100); + SaveSystem.CurrentSave.MusicVolume = val; + prg.Value = val; + } + }; + + prg.MouseUp += (o, a) => + { + moving = false; + }; + prg.Show(); + } + + static public double linear(double x, double x0, double x1, double y0, double y1) + { + if ((x1 - x0) == 0) + { + return (y0 + y1) / 2; + } + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/Volume.resx b/ShiftOS.WinForms/StatusIcons/Volume.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 92482fa..548a62a 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -158,6 +158,15 @@ namespace ShiftOS.WinForms.Tools } catch { } + if (!tag.Contains("ignoreal")) + { + ctrl.Click += (o, a) => + { + Desktop.HideAppLauncher(); + }; + + } + if (!tag.Contains("keepbg")) { if (ctrl.BackColor != Control.DefaultBackColor) @@ -279,6 +288,8 @@ namespace ShiftOS.WinForms.Tools { (ctrl as WindowBorder).Setup(); } + + MakeDoubleBuffered(ctrl); ControlSetup?.Invoke(ctrl); }); @@ -305,10 +316,6 @@ namespace ShiftOS.WinForms.Tools public static void SetupControls(Control frm, bool runInThread = true) { - frm.Click += (o, a) => - { - Desktop.HideAppLauncher(); - }; var ctrls = frm.Controls.ToList(); for (int i = 0; i < ctrls.Count(); i++) { diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 968a31c..d82bc0c 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -55,6 +55,7 @@ namespace ShiftOS.WinForms this.desktoppanel = new System.Windows.Forms.Panel(); this.pnlnotifications = new System.Windows.Forms.Panel(); this.flnotifications = new System.Windows.Forms.FlowLayoutPanel(); + this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); this.lbtime = new System.Windows.Forms.Label(); this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); this.sysmenuholder = new System.Windows.Forms.Panel(); @@ -63,7 +64,6 @@ namespace ShiftOS.WinForms this.pnlscreensaver = 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(); @@ -77,10 +77,10 @@ namespace ShiftOS.WinForms this.desktoppanel.SuspendLayout(); this.pnlnotifications.SuspendLayout(); this.flnotifications.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.pnlscreensaver.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); this.pnlnotificationbox.SuspendLayout(); this.pnladvancedal.SuspendLayout(); this.pnlalsystemactions.SuspendLayout(); @@ -121,6 +121,18 @@ namespace ShiftOS.WinForms this.flnotifications.Name = "flnotifications"; this.flnotifications.Size = new System.Drawing.Size(22, 24); this.flnotifications.TabIndex = 1; + this.flnotifications.WrapContents = false; + // + // ntconnectionstatus + // + 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"; // // lbtime // @@ -200,17 +212,6 @@ namespace ShiftOS.WinForms this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); this.pnlwidgetlayer.TabIndex = 1; // - // ntconnectionstatus - // - 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; @@ -341,12 +342,12 @@ namespace ShiftOS.WinForms this.pnlnotifications.PerformLayout(); this.flnotifications.ResumeLayout(false); this.flnotifications.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); 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); diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index b9c4f37..f1dbe48 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -85,27 +85,24 @@ namespace ShiftOS.WinForms ic.Tag = itype.Name.ToLower(); //Next get the icon data if any. - var iconattrib = itype.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultIconAttribute) as DefaultIconAttribute; - if(iconattrib != null) - { //We can use this attribute's ID in the skin engine to get an icon. - var img = GetIcon(iconattrib.ID); + var img = GetIcon(itype.Name); //Make it transparent. - (img as Bitmap).MakeTransparent(LoadedSkin.SystemKey); + (img as Bitmap).MakeTransparent(Color.White); //Assign it to the control ic.Image = img; //Set the sizing mode ic.SizeMode = PictureBoxSizeMode.StretchImage; - } - else - { - ic.BackColor = Color.White; //TODO: Make it skinnable. - } - ic.Size = new Size(20, 20); //TODO: make it skinnable + ic.Size = new Size(16, 16); //TODO: make it skinnable //add to the notification tray flnotifications.Controls.Add(ic); ic.Show(); + ic.BringToFront(); + + flnotifications.Show(); + + ic.Click += (o, a) => { HideAppLauncher(); @@ -115,7 +112,14 @@ namespace ShiftOS.WinForms UserControl ctrl = (UserControl)Activator.CreateInstance(itype); (ctrl as IStatusIcon).Setup(); currentSettingsPane = ctrl; - if(LoadedSkin.DesktopPanelPosition == 0) + ControlManager.SetupControls(ctrl); + this.Controls.Add(ctrl); + ctrl.BringToFront(); + int left = ic.Parent.PointToScreen(ic.Location).X; + int realleft = left - ctrl.Width; + realleft += ic.Width; + ctrl.Left = realleft; + if (LoadedSkin.DesktopPanelPosition == 0) { ctrl.Top = desktoppanel.Height; } @@ -123,10 +127,6 @@ namespace ShiftOS.WinForms { ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height; } - int noteleft = flnotifications.PointToScreen(ic.Location).X; - int realleft = (this.Width - (noteleft + ic.Width)) - ctrl.Width; - ctrl.Left = realleft; - ControlManager.SetupControls(ctrl); ctrl.Show(); } diff --git a/ShiftOS.WinForms/WinformsDesktop.resx b/ShiftOS.WinForms/WinformsDesktop.resx index b77504b..d5494e3 100644 --- a/ShiftOS.WinForms/WinformsDesktop.resx +++ b/ShiftOS.WinForms/WinformsDesktop.resx @@ -120,7 +120,4 @@ 17, 17 - - 17, 17 - \ No newline at end of file -- cgit v1.2.3 From 5246798b0ad07ac1a2dd9a1369da4ecad2383488 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Jun 2017 08:05:53 -0400 Subject: Make stories not happen until user is logged in. --- ShiftOS.WinForms/WinformsDesktop.cs | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'ShiftOS.WinForms/WinformsDesktop.cs') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index f1dbe48..4614842 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -196,38 +196,14 @@ namespace ShiftOS.WinForms SetupControl(desktoppanel); Shiftorium.Installed += () => { - foreach(var widget in Widgets) + foreach (var widget in Widgets) { widget.OnUpgrade(); } LoadIcons(); - //Only if the DevX Legions story hasn't been experienced yet. - if (!Shiftorium.UpgradeInstalled("devx_legions")) - { - //Check for shiftnet story experience - if (Shiftorium.UpgradeInstalled("shiftnet")) - { - //Check for saturation of the "GUI" upgrade set - if (Shiftorium.IsCategoryEmptied("GUI")) - { - //Start the MUD Control Centre story. - Story.Start("devx_legions"); - } - } - } - if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) - { - if (SaveSystem.CurrentSave.Codepoints >= 50000) - { - if (Shiftorium.IsCategoryEmptied("Applications")) - { - Story.Start("victortran_shiftnet"); - } - } - } }; this.TopMost = false; @@ -294,6 +270,9 @@ namespace ShiftOS.WinForms { do { + while (SaveSystem.CurrentUser == null) + Thread.Sleep(10); + if (SaveSystem.CurrentSave != null) { if (SaveSystem.CurrentSave.Codepoints != lastcp) -- cgit v1.2.3