aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/WinformsDesktop.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.WinForms/WinformsDesktop.cs')
-rw-r--r--ShiftOS.WinForms/WinformsDesktop.cs190
1 files changed, 123 insertions, 67 deletions
diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs
index 85eab55..855e66d 100644
--- a/ShiftOS.WinForms/WinformsDesktop.cs
+++ b/ShiftOS.WinForms/WinformsDesktop.cs
@@ -49,22 +49,108 @@ namespace ShiftOS.WinForms
/// </summary>
public partial class WinformsDesktop : Form, IDesktop
{
+ public MainMenu.MainMenu ParentMenu = null;
+
+ [Command("pushnote")]
+ [RequiresArgument("target")]
+ [RequiresArgument("title")]
+ [RequiresArgument("body")]
+ public static bool PushNote(Dictionary<string, object> 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<IDesktopWidget> Widgets = new List<IDesktopWidget>();
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.
+
+ //We can use this attribute's ID in the skin engine to get an icon.
+ var img = GetIcon(itype.Name);
+ //Make it transparent.
+ (img as Bitmap).MakeTransparent(Color.White);
+ //Assign it to the control
+ ic.Image = img;
+ //Set the sizing mode
+ ic.SizeMode = PictureBoxSizeMode.StretchImage;
+ 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();
+
+ if(itype.BaseType == typeof(UserControl))
+ {
+ UserControl ctrl = (UserControl)Activator.CreateInstance(itype);
+ (ctrl as IStatusIcon).Setup();
+ currentSettingsPane = ctrl;
+ 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;
+ }
+ else
+ {
+ ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height;
+ }
+ ctrl.Show();
+ }
+
+
+ };
+ }
+ }
+
public void PushNotification(string app, string title, string msg)
{
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)
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,17 +161,24 @@ 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) =>
{
pnlnotificationbox.Hide();
+ pnlnotificationbox.AutoSize = true;
};
Engine.AudioManager.PlayStream(Properties.Resources.infobox);
+
+
pnlnotificationbox.Show();
+ pnlnotificationbox.BringToFront();
notekiller.Start();
}
+ private UserControl currentSettingsPane = null;
+
/// <summary>
/// Initializes a new instance of the <see cref="ShiftOS.WinForms.WinformsDesktop"/> class.
/// </summary>
@@ -104,36 +197,14 @@ namespace ShiftOS.WinForms
SetupControl(desktoppanel);
Shiftorium.Installed += () =>
{
- foreach(var widget in Widgets)
+ foreach (var widget in Widgets)
{
widget.OnUpgrade();
}
- //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");
- }
- }
- }
+ LoadIcons();
+
- if (!Shiftorium.UpgradeInstalled("victortran_shiftnet"))
- {
- if (SaveSystem.CurrentSave.Codepoints >= 50000)
- {
- if (Shiftorium.IsCategoryEmptied("Applications"))
- {
- Story.Start("victortran_shiftnet");
- }
- }
- }
};
this.TopMost = false;
@@ -155,6 +226,7 @@ namespace ShiftOS.WinForms
SaveSystem.GameReady += () =>
{
+ this.Invoke(new Action(LoadIcons));
if (this.Visible == true)
this.Invoke(new Action(() => SetupDesktop()));
};
@@ -183,6 +255,7 @@ namespace ShiftOS.WinForms
};
SkinEngine.SkinLoaded += () =>
{
+ LoadIcons();
foreach (var widget in Widgets)
{
widget.OnSkinLoad();
@@ -192,37 +265,6 @@ namespace ShiftOS.WinForms
SetupDesktop();
};
- long lastcp = 0;
-
- var storythread = new Thread(() =>
- {
- do
- {
- if (SaveSystem.CurrentSave != null)
- {
- if (SaveSystem.CurrentSave.Codepoints != lastcp)
- lastcp = SaveSystem.CurrentSave.Codepoints;
- 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);
- });
- storythread.IsBackground = true;
- storythread.Start();
-
time.Tick += (o, a) =>
{
if (Shiftorium.IsInitiated == true)
@@ -748,7 +790,7 @@ namespace ShiftOS.WinForms
item.Text = Localization.Parse("{SHUTDOWN}");
item.Click += (o, a) =>
{
- TerminalBackend.InvokeCommand("sos.shutdown");
+ TerminalBackend.InvokeCommand("shutdown");
};
apps.DropDownItems.Add(item);
if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
@@ -777,7 +819,7 @@ namespace ShiftOS.WinForms
catbtn.Height = 24;
flcategories.Controls.Add(catbtn);
catbtn.Show();
- catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("sos.shutdown");
+ catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("shutdown");
}
}
}
@@ -846,7 +888,7 @@ namespace ShiftOS.WinForms
/// <param name="e">E.</param>
private void Desktop_Load(object sender, EventArgs e)
{
-
+ SaveSystem.IsSandbox = this.IsSandbox;
SaveSystem.Begin();
SetupDesktop();
@@ -889,6 +931,7 @@ namespace ShiftOS.WinForms
}
private IWindowBorder focused = null;
+ internal bool IsSandbox = false;
public string DesktopName
{
@@ -958,10 +1001,17 @@ namespace ShiftOS.WinForms
{
try
{
- this.Invoke(new Action(() =>
+ if (this.Visible == true)
{
- act?.Invoke();
- }));
+ this.Invoke(new Action(() =>
+ {
+ act?.Invoke();
+ }));
+ }
+ else
+ {
+ ParentMenu?.Invoke(act);
+ }
}
catch
{
@@ -1025,15 +1075,21 @@ namespace ShiftOS.WinForms
private void btnshutdown_Click(object sender, EventArgs e)
{
- TerminalBackend.InvokeCommand("sos.shutdown");
+ TerminalBackend.InvokeCommand("shutdown");
}
public void HideAppLauncher()
{
- this.Invoke(new Action(() =>
+ try
{
- pnladvancedal.Hide();
- }));
+ this.Invoke(new Action(() =>
+ {
+ currentSettingsPane?.Hide();
+ currentSettingsPane = null;
+ pnladvancedal.Hide();
+ }));
+ }
+ catch { }
}
}