diff --git a/DeedyDesigner/Deedy.Activity/ActionViewer.cs b/DeedyDesigner/Deedy.Activity/ActionViewer.cs
index 4f88b0e..0317cc0 100644
--- a/DeedyDesigner/Deedy.Activity/ActionViewer.cs
+++ b/DeedyDesigner/Deedy.Activity/ActionViewer.cs
@@ -23,7 +23,7 @@ namespace Deedy.Activity
///
/// 用于为Action提供显示视图
///
- [IconKey(ThemeKeys.KEY_Activity_DefaultIcon)]
+ [IconKey(ThemeKeys.Keys.Activity_DefaultIcon)]
[TemplatePart(Name = PART_ItemsContainer, Type = typeof(ItemsControl))]
[TemplatePart(Name = PART_TitleContainer, Type = typeof(FrameworkElement))]
[TemplatePart(Name = PART_StateDecorator, Type = typeof(ViewerStateDecorator))]
@@ -250,7 +250,6 @@ namespace Deedy.Activity
if (e.NewValue is LogInfo logInfo)
{
this.ToolTip = logInfo.ToString();
- //TODO:更新消息显示图标
this.LogInfos.Add(logInfo);
}
}
diff --git a/DeedyDesigner/Deedy.Activity/Contract/Entities/LogInfo.cs b/DeedyDesigner/Deedy.Activity/Contract/Entities/LogInfo.cs
index b52995a..70406c1 100644
--- a/DeedyDesigner/Deedy.Activity/Contract/Entities/LogInfo.cs
+++ b/DeedyDesigner/Deedy.Activity/Contract/Entities/LogInfo.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
@@ -9,16 +11,94 @@ using System.Windows.Shapes;
namespace Deedy.Activity
{
- public class LogInfo
+ public class LogInfo : INotifyPropertyChanged
{
- private LogInfo() { }
- [AllowNull]
- public ImageSource Icon { get; set; }
- public readonly static LogInfo Empty = new();
- public override string ToString()
+ #region 定义属性通知事件相关方法
+ public event PropertyChangedEventHandler? PropertyChanged;
+ protected virtual void OnPropertyChanged([CallerMemberName, AllowNull] string propertyName = null)
{
- //TODO:返回序列化后的消息
- return "";
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
+ protected virtual T GetField(ref T field, [CallerMemberName, AllowNull] string propertyName = null)
+ {
+ T result = field;
+ switch (propertyName)
+ {
+ //返回前的自定义逻辑
+ default: break;
+ }
+ return result;
+ }
+ protected virtual bool SetField(ref T field, T value, [CallerMemberName, AllowNull] string propertyName = null)
+ {
+ if (EqualityComparer.Default.Equals(field, value)) return false;
+ T _Value = value;
+ switch (propertyName)
+ {
+ //赋值前的自定义逻辑
+ default: break;
+ }
+ field = _Value;
+ OnPropertyChanged(propertyName);
+ return true;
+ }
+ #endregion
+ public static LogInfo Empty => new("");
+
+ public LogInfo(string info, InfoType type = InfoType.日志) { this.Info = info; this.Type = type; }
+ [AllowNull]
+ protected internal ImageSource _Icon = null;
+ ///
+ /// 消息图标
+ ///
+ public ImageSource? Icon
+ {
+ get { return GetField(ref _Icon); }
+ private set
+ {
+ if (SetField(ref _Icon, value))
+ {
+ // 这里可以加入属性变更后的处理逻辑
+ }
+ }
+ }
+ protected internal InfoType _Type = InfoType.日志;
+ ///
+ /// 消息类型
+ ///
+ public InfoType Type
+ {
+ get { return GetField(ref _Type); }
+ set
+ {
+ if (SetField(ref _Type, value))
+ {
+ switch (value)
+ {
+ case InfoType.日志: this.Icon = new ThemeResources().InfoIcon_None; break;
+ case InfoType.提示: this.Icon = new ThemeResources().InfoIcon_Info; break;
+ case InfoType.警告: this.Icon = new ThemeResources().InfoIcon_Warning; break;
+ case InfoType.错误: this.Icon = new ThemeResources().InfoIcon_Error; break;
+ default: this.Icon = new ThemeResources().InfoIcon_None; break;
+ }
+ }
+ }
+ }
+ protected internal string _Info = "";
+ ///
+ /// 信息内容
+ ///
+ public string Info
+ {
+ get { return GetField(ref _Info); }
+ set
+ {
+ if (SetField(ref _Info, value))
+ {
+ // 这里可以加入属性变更后的处理逻辑
+ }
+ }
+ }
+ public override string ToString() => $"「{this.Type}\t」「{this.Info}」";
}
}
diff --git a/DeedyDesigner/Deedy.Activity/Contract/Enums/InfoType.cs b/DeedyDesigner/Deedy.Activity/Contract/Enums/InfoType.cs
index 3891556..e1373f8 100644
--- a/DeedyDesigner/Deedy.Activity/Contract/Enums/InfoType.cs
+++ b/DeedyDesigner/Deedy.Activity/Contract/Enums/InfoType.cs
@@ -8,9 +8,21 @@ namespace Deedy.Activity
{
public enum InfoType : int
{
- None = 0,
- Info = 1,
- Warn = 2,
- Error = 3
+ ///
+ /// None
+ ///
+ 日志 = 0,
+ ///
+ /// Info
+ ///
+ 提示 = 1,
+ ///
+ /// Warning
+ ///
+ 警告 = 2,
+ ///
+ /// Error
+ ///
+ 错误 = 3
}
}
diff --git a/DeedyDesigner/Deedy.Activity/Resources/ThemeKeys.cs b/DeedyDesigner/Deedy.Activity/Resources/ThemeKeys.cs
index cee1e77..77129f2 100644
--- a/DeedyDesigner/Deedy.Activity/Resources/ThemeKeys.cs
+++ b/DeedyDesigner/Deedy.Activity/Resources/ThemeKeys.cs
@@ -10,7 +10,16 @@ namespace Deedy.Activity
{
public static class ThemeKeys
{
- public const string KEY_Activity_DefaultIcon = "Activity_DefaultIcon";
+ public static class Keys
+ {
+ public const string Activity_DefaultIcon = "Activity_DefaultIcon";
+
+ public const string InfoIcon_None = "InfoIcon_None";
+ public const string InfoIcon_Info = "InfoIcon_Info";
+ public const string InfoIcon_Warning = "InfoIcon_Warning";
+ public const string InfoIcon_Error = "InfoIcon_Error";
+ }
+
public static ComponentResourceKey? LookupResourceKey(string themeKey)
{
if (typeof(ThemeKeys).GetProperty(themeKey, typeof(ComponentResourceKey)) is PropertyInfo pInfo)
@@ -18,7 +27,10 @@ namespace Deedy.Activity
return null;
}
- public static ComponentResourceKey Activity_DefaultIcon => new ComponentResourceKey(typeof(ThemeKeys), "Activity_DefaultIcon");
-
+ public static ComponentResourceKey Activity_DefaultIcon => new ComponentResourceKey(typeof(ThemeKeys), Keys.Activity_DefaultIcon);
+ public static ComponentResourceKey InfoIcon_None = new ComponentResourceKey(typeof(ThemeKeys), Keys.InfoIcon_None);
+ public static ComponentResourceKey InfoIcon_Info = new ComponentResourceKey(typeof(ThemeKeys), Keys.InfoIcon_Info);
+ public static ComponentResourceKey InfoIcon_Warning = new ComponentResourceKey(typeof(ThemeKeys), Keys.InfoIcon_Warning);
+ public static ComponentResourceKey InfoIcon_Error = new ComponentResourceKey(typeof(ThemeKeys), Keys.InfoIcon_Error);
}
}
diff --git a/DeedyDesigner/Deedy.Activity/Resources/ThemeResources.cs b/DeedyDesigner/Deedy.Activity/Resources/ThemeResources.cs
index 1b9af5e..bd05bc5 100644
--- a/DeedyDesigner/Deedy.Activity/Resources/ThemeResources.cs
+++ b/DeedyDesigner/Deedy.Activity/Resources/ThemeResources.cs
@@ -11,5 +11,9 @@ namespace Deedy.Activity
public partial class ThemeResources : ResourceDictionary
{
public ImageSource? Activity_DefaultIcon => this[ThemeKeys.Activity_DefaultIcon] as ImageSource;
+ public ImageSource? InfoIcon_None => this[ThemeKeys.InfoIcon_None] as ImageSource;
+ public ImageSource? InfoIcon_Info => this[ThemeKeys.InfoIcon_Info] as ImageSource;
+ public ImageSource? InfoIcon_Warning => this[ThemeKeys.InfoIcon_Warning] as ImageSource;
+ public ImageSource? InfoIcon_Error => this[ThemeKeys.InfoIcon_Error] as ImageSource;
}
}
diff --git a/DeedyDesigner/Deedy.Activity/Themes/ThemeResources.xaml b/DeedyDesigner/Deedy.Activity/Themes/ThemeResources.xaml
index cb11664..01115c1 100644
--- a/DeedyDesigner/Deedy.Activity/Themes/ThemeResources.xaml
+++ b/DeedyDesigner/Deedy.Activity/Themes/ThemeResources.xaml
@@ -5,6 +5,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file