mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-01 16:33:43 -04:00
ready for testing
This commit is contained in:
@ -14,11 +14,15 @@ namespace Observatory.PluginManagement
|
||||
|
||||
private readonly NativeVoice NativeVoice;
|
||||
private readonly NativePopup NativePopup;
|
||||
|
||||
public PluginCore()
|
||||
private bool OverridePopup;
|
||||
private bool OverrideAudio;
|
||||
|
||||
public PluginCore(bool OverridePopup = false, bool OverrideAudio = false)
|
||||
{
|
||||
NativeVoice = new();
|
||||
NativePopup = new();
|
||||
this.OverridePopup = OverridePopup;
|
||||
this.OverrideAudio = OverrideAudio;
|
||||
}
|
||||
|
||||
public string Version => System.Reflection.Assembly.GetEntryAssembly()?.GetName().Version?.ToString() ?? "0";
|
||||
@ -31,11 +35,8 @@ namespace Observatory.PluginManagement
|
||||
};
|
||||
}
|
||||
|
||||
public Status GetStatus()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Status GetStatus() => LogMonitor.GetInstance.Status;
|
||||
|
||||
public Guid SendNotification(string title, string text)
|
||||
{
|
||||
return SendNotification(new NotificationArgs() { Title = title, Detail = text });
|
||||
@ -53,12 +54,12 @@ namespace Observatory.PluginManagement
|
||||
handler?.Invoke(this, notificationArgs);
|
||||
}
|
||||
|
||||
if (Properties.Core.Default.NativeNotify && notificationArgs.Rendering.HasFlag(NotificationRendering.NativeVisual))
|
||||
if (!OverridePopup && Properties.Core.Default.NativeNotify && notificationArgs.Rendering.HasFlag(NotificationRendering.NativeVisual))
|
||||
{
|
||||
guid = NativePopup.InvokeNativeNotification(notificationArgs);
|
||||
}
|
||||
|
||||
if (Properties.Core.Default.VoiceNotify && notificationArgs.Rendering.HasFlag(NotificationRendering.NativeVocal))
|
||||
if (!OverrideAudio && Properties.Core.Default.VoiceNotify && notificationArgs.Rendering.HasFlag(NotificationRendering.NativeVocal))
|
||||
{
|
||||
NativeVoice.EnqueueAndAnnounce(notificationArgs);
|
||||
}
|
||||
@ -69,14 +70,13 @@ namespace Observatory.PluginManagement
|
||||
|
||||
public void CancelNotification(Guid id)
|
||||
{
|
||||
NativePopup.CloseNotification(id);
|
||||
ExecuteOnUIThread(() => NativePopup.CloseNotification(id));
|
||||
}
|
||||
|
||||
public void UpdateNotification(Guid id, NotificationArgs notificationArgs)
|
||||
{
|
||||
if (!IsLogMonitorBatchReading)
|
||||
{
|
||||
|
||||
if (notificationArgs.Rendering.HasFlag(NotificationRendering.PluginNotifier))
|
||||
{
|
||||
var handler = Notification;
|
||||
@ -140,6 +140,8 @@ namespace Observatory.PluginManagement
|
||||
|
||||
public event EventHandler<NotificationArgs> Notification;
|
||||
|
||||
internal event EventHandler<PluginMessageArgs> PluginMessage;
|
||||
|
||||
public string PluginStorageFolder
|
||||
{
|
||||
get
|
||||
@ -161,25 +163,19 @@ namespace Observatory.PluginManagement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PlayAudioFile(string filePath)
|
||||
{
|
||||
await AudioHandler.PlayFile(filePath);
|
||||
}
|
||||
|
||||
public void SendPluginMessage(IObservatoryPlugin plugin, object message)
|
||||
{
|
||||
PluginMessage?.Invoke(this, new PluginMessageArgs(plugin.Name, plugin.Version, message));
|
||||
}
|
||||
|
||||
internal void Shutdown()
|
||||
{
|
||||
NativePopup.CloseAll();
|
||||
}
|
||||
|
||||
private static bool FirstRowIsAllNull(IObservatoryWorker worker)
|
||||
{
|
||||
bool allNull = true;
|
||||
Type itemType = worker.PluginUI.DataGrid[0].GetType();
|
||||
foreach (var property in itemType.GetProperties())
|
||||
{
|
||||
if (property.GetValue(worker.PluginUI.DataGrid[0], null) != null)
|
||||
{
|
||||
allNull = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return allNull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,14 @@ namespace Observatory.PluginManagement
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPluginMessageEvent(object _, PluginMessageArgs messageArgs)
|
||||
{
|
||||
foreach (var plugin in observatoryNotifiers.Cast<IObservatoryPlugin>().Concat(observatoryWorkers))
|
||||
{
|
||||
plugin.HandlePluginMessage(messageArgs.SourceName, messageArgs.SourceVersion, messageArgs.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetTimer()
|
||||
{
|
||||
timer.Stop();
|
||||
@ -146,4 +154,18 @@ namespace Observatory.PluginManagement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class PluginMessageArgs
|
||||
{
|
||||
internal string SourceName;
|
||||
internal string SourceVersion;
|
||||
internal object Message;
|
||||
|
||||
internal PluginMessageArgs(string sourceName, string sourceVersion, object message)
|
||||
{
|
||||
SourceName = sourceName;
|
||||
SourceVersion = sourceVersion;
|
||||
Message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,10 @@ namespace Observatory.PluginManagement
|
||||
logMonitor.StatusUpdate += pluginHandler.OnStatusUpdate;
|
||||
logMonitor.LogMonitorStateChanged += pluginHandler.OnLogMonitorStateChanged;
|
||||
|
||||
core = new PluginCore();
|
||||
var ovPopup = notifyPlugins.Any(n => n.plugin.OverridePopupNotifications);
|
||||
var ovAudio = notifyPlugins.Any(n => n.plugin.OverrideAudioNotifications);
|
||||
|
||||
core = new PluginCore(ovPopup, ovAudio);
|
||||
|
||||
List<IObservatoryPlugin> errorPlugins = new();
|
||||
|
||||
@ -97,6 +100,7 @@ namespace Observatory.PluginManagement
|
||||
notifyPlugins.RemoveAll(n => errorPlugins.Contains(n.plugin));
|
||||
|
||||
core.Notification += pluginHandler.OnNotificationEvent;
|
||||
core.PluginMessage += pluginHandler.OnPluginMessageEvent;
|
||||
|
||||
if (errorList.Any())
|
||||
ErrorReporter.ShowErrorPopup("Plugin Load Error" + (errorList.Count > 1 ? "s" : String.Empty), errorList);
|
||||
@ -114,7 +118,15 @@ namespace Observatory.PluginManagement
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(savedSettings))
|
||||
{
|
||||
pluginSettings = JsonSerializer.Deserialize<Dictionary<string, object>>(savedSettings);
|
||||
var settings = JsonSerializer.Deserialize<Dictionary<string, object>>(savedSettings);
|
||||
if (settings != null)
|
||||
{
|
||||
pluginSettings = settings;
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginSettings = new();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -138,7 +150,7 @@ namespace Observatory.PluginManagement
|
||||
var properties = settings.GetType().GetProperties();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var attrib = property.GetCustomAttribute<Framework.SettingDisplayName>();
|
||||
var attrib = property.GetCustomAttribute<SettingDisplayName>();
|
||||
if (attrib == null)
|
||||
{
|
||||
settingNames.Add(property, property.Name);
|
||||
@ -396,7 +408,7 @@ namespace Observatory.PluginManagement
|
||||
if (constructor != null)
|
||||
{
|
||||
object instance = constructor.Invoke(Array.Empty<object>());
|
||||
notifiers.Add(((instance as IObservatoryNotifier)!, PluginStatus.Signed));
|
||||
notifiers.Add(((instance as IObservatoryNotifier)!, pluginStatus));
|
||||
pluginCount++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user