mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
modular notifications
This commit is contained in:
parent
3dd402277b
commit
c631172761
4 changed files with 89 additions and 0 deletions
|
@ -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();
|
||||
|
|
14
ShiftOS_TheReturn/IStatusIcon.cs
Normal file
14
ShiftOS_TheReturn/IStatusIcon.cs
Normal file
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of all <see cref="IStatusIcon"/> objects that meet their Shiftorium dependencies.
|
||||
/// </summary>
|
||||
/// <returns>An array of <see cref="Type"/>s containing the found objects.</returns>
|
||||
public static Type[] GetAllStatusIcons()
|
||||
{
|
||||
List<Type> lst = new List<Type>();
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
<Compile Include="FileSkimmerBackend.cs" />
|
||||
<Compile Include="Infobox.cs" />
|
||||
<Compile Include="IShiftOSWindow.cs" />
|
||||
<Compile Include="IStatusIcon.cs" />
|
||||
<Compile Include="KernelWatchdog.cs" />
|
||||
<Compile Include="Localization.cs" />
|
||||
<Compile Include="LoginManager.cs" />
|
||||
|
|
Loading…
Reference in a new issue