定义可以设置初始顺序的可变通知集合
This commit is contained in:
@@ -8,10 +8,12 @@ using System.Threading.Tasks;
|
|||||||
namespace Deedy.Activity
|
namespace Deedy.Activity
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||||
public class CombinePartActionAttribute : Attribute
|
public class CombinePartActionAttribute : Attribute, IInitialSortable
|
||||||
{
|
{
|
||||||
public CombinePartActionAttribute(int sort) { this.Sort = sort; }
|
public CombinePartActionAttribute(int initSort) { this.InitialSort = initSort; }
|
||||||
public int Sort { get; private set; }
|
|
||||||
|
public int InitialSort { get; set; } = 0;
|
||||||
|
|
||||||
public void Binding(object target, PropertyInfo property)
|
public void Binding(object target, PropertyInfo property)
|
||||||
{
|
{
|
||||||
if (!property.CanRead || !property.CanWrite) throw new ArgumentException("绑定为组装部件的属性必须具备写访问器...");
|
if (!property.CanRead || !property.CanWrite) throw new ArgumentException("绑定为组装部件的属性必须具备写访问器...");
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ using System.Threading.Tasks;
|
|||||||
namespace Deedy.Activity
|
namespace Deedy.Activity
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||||
public class ParmDefineAttribute : Attribute
|
public class ParamDefineAttribute : Attribute, IInitialSortable
|
||||||
{
|
{
|
||||||
|
public int InitialSort { get; set; } = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
public class ParamGroupAttribute : Attribute, IInitialSortable
|
||||||
|
{
|
||||||
|
public int InitialSort { get; set; } = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用于声明参数的取值
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
|
||||||
|
public class ParamValueAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -8,6 +9,8 @@ using System.Windows;
|
|||||||
|
|
||||||
namespace Deedy.Activity
|
namespace Deedy.Activity
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
public class ActionTemplateCollection : ObservableCollection<DataTemplate>
|
public class ActionTemplateCollection : ObservableCollection<DataTemplate>
|
||||||
{
|
{
|
||||||
public ActionTemplateCollection() { }
|
public ActionTemplateCollection() { }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -8,6 +9,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Deedy.Activity
|
namespace Deedy.Activity
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
public class ElementCollection : ObservableCollection<IElement>
|
public class ElementCollection : ObservableCollection<IElement>
|
||||||
{
|
{
|
||||||
public ElementCollection() : this(false) { }
|
public ElementCollection() : this(false) { }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -9,6 +10,8 @@ namespace Deedy.Activity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用于扩展一个对象的非必要属性
|
/// 用于扩展一个对象的非必要属性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
public class ExpandoMapping : Dictionary<string, string>
|
public class ExpandoMapping : Dictionary<string, string>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
public class InitialSortedObservableCollection<T> : ObservableCollection<T> where T : IInitialSortable
|
||||||
|
{
|
||||||
|
protected internal InitialSortedObservableCollection() { }
|
||||||
|
|
||||||
|
public virtual new void Add(T item) => this.Insert(this.CheckInitialSort(item), item);
|
||||||
|
private int CheckInitialSort(T item)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
foreach (var item2 in this)
|
||||||
|
{
|
||||||
|
if (item2.InitialSort >= item.InitialSort)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Deedy.Activity
|
namespace Deedy.Activity
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
public class LogInfoCollection : ObservableCollection<LogInfo>
|
public class LogInfoCollection : ObservableCollection<LogInfo>
|
||||||
{
|
{
|
||||||
public LogInfoCollection(int limt = 50) { }
|
public LogInfoCollection(int limt = 50) { }
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Deedy.Activity
|
namespace Deedy.Activity
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
public class OutputCollection : ObservableCollection<Output>
|
public class OutputCollection : ObservableCollection<Output>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("「ParamDefineCollection<ParamDefineAttribute>」Count = {Count}",
|
||||||
|
Target = typeof(ParamDefineCollection), Name = "参数定义集合", Type = nameof(ParamDefineCollection))]
|
||||||
|
public class ParamDefineCollection : InitialSortedObservableCollection<ParamDefineAttribute>
|
||||||
|
{
|
||||||
|
private readonly SortedList<int, ParamDefineAttribute> _SoredList = new();
|
||||||
|
internal ParamDefineCollection() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
|
public class ParamGroupCollection : InitialSortedObservableCollection<ParamGroupAttribute>
|
||||||
|
{
|
||||||
|
internal ParamGroupCollection() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
[DebuggerDisplay("Count = {Count}")]
|
||||||
|
public class ParamTemplateCollection : ObservableCollection<DataTemplate>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 可排序对象需要实现的接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IInitialSortable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 初始顺序:这个字段仅仅影响插入集合时的元素顺序,用户在向集合插入数据后仍然可以手动调整顺序
|
||||||
|
/// </summary>
|
||||||
|
public int InitialSort { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Deedy.Activity
|
||||||
|
{
|
||||||
|
public class ParamTemplateSelector : DataTemplateSelector
|
||||||
|
{
|
||||||
|
public ParamTemplateSelector()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||||
|
{
|
||||||
|
if (item is ParamDefineAttribute paramDefine)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return base.SelectTemplate(item, container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user