增加日志

This commit is contained in:
2025-04-01 18:15:30 +08:00
parent e08386333a
commit 409089e2ca
21 changed files with 1838 additions and 354 deletions

View File

@ -120,6 +120,40 @@ namespace DH.Commons.Enums
.FirstOrDefault() as DescriptionAttribute;
return attribute?.Description ?? value.ToString();
}
public static System.Drawing.Color GetEnumSelectedColor(this Enum enumObj)
{
Type t = enumObj.GetType();
FieldInfo f = t.GetField(enumObj.ToString());
ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
if (attr != null)
{
return System.Drawing.Color.FromName(attr.SelectedColor);
}
else
{
return System.Drawing.Color.Transparent;
}
}
public static System.Drawing.Color GetEnumSelectedFontColor(this Enum enumObj)
{
Type t = enumObj.GetType();
FieldInfo f = t.GetField(enumObj.ToString());
var attr = f.GetCustomAttribute<FontColorSelectAttribute>();
if (attr != null)
{
return System.Drawing.Color.FromName(attr.SelectedColor);
}
else
{
return System.Drawing.Color.Transparent;
}
}
[Flags]
public enum DeviceAttributeType
{
@ -303,7 +337,44 @@ namespace DH.Commons.Enums
// NG = -1,
// IGNORE = -999,
//}
public enum DeviceState
{
TBD = -1,
[ColorSelect("Gray")]
[FontColorSelect("Black")]
[Description("未初始化")]
DSUninit = 1,
[ColorSelect("Gold")]
[FontColorSelect("White")]
[PreState(1 + 2 + 4 + 8 + 32)]
[Description("初始化")]
DSInit = 2,
[ColorSelect("Lime")]
[FontColorSelect("Black")]
[PreState(2 + 4 + 16)]
[Description("运行中")]
DSOpen = 4,
[ColorSelect("Gray")]
[FontColorSelect("White")]
[PreState(1 + 4 + 8 + 16 + 32)]
[Description("关闭")]
DSClose = 8,
[ColorSelect("Gold")]
[FontColorSelect("White")]
[PreState(4 + 16)]
[Description("暂停")]
DSPause = 16,
[ColorSelect("Red")]
[FontColorSelect("White")]
[Description("异常")]
DSExcept = 32
}
public enum PriorityDirection
{
X,

View File

@ -8,6 +8,18 @@ using static DH.Commons.Enums.EnumHelper;
namespace DH.Commons.Enums
{
public interface ILogOutput
{
event Action<LogMsg> OnLogMsgOutput;
void LogDisplay(LogMsg msg);
}
public interface ILogger
{
event Action<LogMsg> OnLog;
LoggerHelper LoggerHelper { get; set; }
//void LogAsync(DateTime dt, LogLevel loglevel, string msg);
void LogAsync(LogMsg msg);
}
public class LoggerHelper
{
public event Action<DateTime, string> OnLogExceptionRaised;