1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-28 16:50:11 +00:00
msfs-popout-panel-manager/Shared/StatusMessageWriter.cs

53 lines
2 KiB
C#
Raw Normal View History

2022-07-23 19:23:32 +00:00
using System;
2023-07-12 22:41:31 +00:00
using System.Collections.Generic;
2022-07-23 19:23:32 +00:00
namespace MSFSPopoutPanelManager.Shared
{
public class StatusMessageWriter
{
2023-07-12 22:41:31 +00:00
private static List<StatusMessage> _messages = new List<StatusMessage>();
2022-07-23 19:23:32 +00:00
public static event EventHandler<StatusMessageEventArg> OnStatusMessage;
2023-07-12 22:41:31 +00:00
public static void WriteMessage(string message, StatusMessageType statusMessageType, int duration = -1)
{
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = false });
if (IsEnabled)
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
}
public static void WriteMessageNewLine(string message, StatusMessageType statusMessageType, int duration = -1)
2022-07-23 19:23:32 +00:00
{
2023-07-12 22:41:31 +00:00
_messages.Add(new StatusMessage { Message = message, StatusMessageType = statusMessageType, NewLine = true });
if (IsEnabled)
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
2022-07-23 19:23:32 +00:00
}
2023-07-12 22:41:31 +00:00
public static void WriteOkStatusMessage(int duration = -1)
2022-07-23 19:23:32 +00:00
{
2023-07-12 22:41:31 +00:00
_messages.Add(new StatusMessage { Message = " (OK)", StatusMessageType = StatusMessageType.Success, NewLine = true });
if (IsEnabled)
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
2022-07-23 19:23:32 +00:00
}
2023-07-12 22:41:31 +00:00
public static void WriteFailureStatusMessage(int duration = -1)
{
_messages.Add(new StatusMessage { Message = " (FAILED)", StatusMessageType = StatusMessageType.Failure, NewLine = true });
if (IsEnabled)
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(_messages, duration));
}
public static void ClearMessage()
{
_messages.Clear();
OnStatusMessage?.Invoke(null, new StatusMessageEventArg(new List<StatusMessage>()));
}
public static bool IsEnabled { get; set; }
2022-07-23 19:23:32 +00:00
}
}