From 34ee2c9c1e7287ca1002ede66a70bdbf9268cd27 Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期四, 02 七月 2020 18:22:46 +0800 Subject: [PATCH] 合并 --- src/Bro.Common.Model/Model/IOItem.cs | 71 +++++++++++++++++++++++++++++++++-- 1 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/Bro.Common.Model/Model/IOItem.cs b/src/Bro.Common.Model/Model/IOItem.cs index 64a2bca..486d0ff 100644 --- a/src/Bro.Common.Model/Model/IOItem.cs +++ b/src/Bro.Common.Model/Model/IOItem.cs @@ -1,6 +1,9 @@ 锘縰sing Bro.Common.Helper; +using Newtonsoft.Json; using System; +using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using static Bro.Common.Helper.EnumHelper; namespace Bro.Common.Model @@ -10,21 +13,81 @@ /// <summary> /// IO鐐圭紪鍙� /// </summary> - public int IONum { get; set; } + [Category("IO閰嶇疆")] + [Description("IO鐐圭紪鍙�")] + public virtual int IONum { get; set; } /// <summary> /// IO鐐圭殑鍊� /// </summary> - public int Value { get; set; } + [Category("IO閰嶇疆")] + [Description("IO鏁板��")] + public virtual int Value { get; set; } /// <summary> /// IO鐐规槸in杩樻槸out /// </summary> - public IOModel Model { get; set; } + [Category("IO閰嶇疆")] + [Description("IO绫诲瀷")] + public virtual IOType IOType { get; set; } public string GetDisplayText() { - return $"{Model.GetEnumDescription()},缂栧彿{IONum}锛孖O鐐圭殑鍊納Value}"; + return $"{IOType.GetEnumDescription()},缂栧彿{IONum}锛孖O鐐圭殑鍊納Value}"; + } + } + + public class IODefinition : IOItem + { + [Category("IO閰嶇疆")] + [Description("IO鐢ㄩ�旀弿杩�")] + public string IODesc { get; set; } + + [Category("IO閰嶇疆")] + [Description("澶囨敞璇存槑")] + public string Remark { get; set; } + + [Browsable(false)] + [JsonIgnore] + public override int Value { get; set; } + + public new string GetDisplayText() + { + return $"{IODesc} {IOType.GetEnumDescription()} {IONum}"; + } + } + + public class IORefrenceItem + { + [Category("IO鎿嶄綔閰嶇疆")] + [Description("闇�瑕佹搷浣滅殑IO")] + [TypeConverter(typeof(IORefrenceItemSourceConverter))] + public IOItem IOItem { get; set; } = new IOItem(); + + [Category("IO鎿嶄綔閰嶇疆")] + [Description("闇�瑕佹搷浣滅殑IO鐨勬暟鍊�")] + public int CheckValue { get => IOItem.Value; set => IOItem.Value = value; } + + [Browsable(false)] + [JsonIgnore] + public List<IODefinition> IOItemSource { get; set; } = new List<IODefinition>(); + } + + public class IORefrenceItemSourceConverter : ComboBoxItemTypeConvert + { + public override Hashtable GetConvertHash(ITypeDescriptorContext context) + { + Hashtable table = new Hashtable(); + + if (context.Instance is IORefrenceItem item) + { + item.IOItemSource.ForEach(i => + { + table[i.IODesc + i.IOType.GetEnumDescription() + i.IONum] = i as IOItem; + }); + } + + return table; } } } -- Gitblit v1.8.0