From 78289c64a16dd02cc9fec595bf758a9e30a30926 Mon Sep 17 00:00:00 2001 From: patrick.xu <patrick.xu@broconcentric.com> Date: 星期六, 20 二月 2021 10:51:11 +0800 Subject: [PATCH] gocator修改异步模式下图片获取操作 --- src/Bro.Common.Model/Model/MotionCardRelated.cs | 563 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 347 insertions(+), 216 deletions(-) diff --git a/src/Bro.Common.Model/Model/MotionCardRelated.cs b/src/Bro.Common.Model/Model/MotionCardRelated.cs index 5b4f5ac..7cb2221 100644 --- a/src/Bro.Common.Model/Model/MotionCardRelated.cs +++ b/src/Bro.Common.Model/Model/MotionCardRelated.cs @@ -1,9 +1,11 @@ 锘縰sing Bro.Common.Helper; using Newtonsoft.Json; using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; +using System.Globalization; using System.Linq; using System.Text; using System.Threading; @@ -35,66 +37,73 @@ [Category("鎹㈢畻閰嶇疆")] [DisplayName("鑴夊啿鏁版崲绠楁瘮渚�")] [Description("鑴夊啿鏁板拰鍏朵粬璁¢噺鍗曚綅鐨勬崲绠楁瘮渚嬶紝渚嬪璁剧疆涓�1000锛岃〃绀�1000涓剦鍐茬瓑浜�1uint")] - public int PulseRatio { get; set; } = 1; + public int AxisRatio { get; set; } = 1; - [Category("閫熷害閰嶇疆")] - [DisplayName("榛樿閫熷害鍙傛暟")] - [Description("VelocityPara锛氶粯璁ら�熷害鍙傛暟")] + //[Category("閫熷害閰嶇疆")] + //[DisplayName("榛樿閫熷害鍙傛暟")] + //[Description("VelocityPara锛氶粯璁ら�熷害鍙傛暟")] + //[TypeConverter(typeof(ComplexObjectConvert))] + //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] + //public VelocityPara VelocityPara { get; set; } = new VelocityPara(); + + //[Category("鍥炲師鐐硅缃�")] + //[DisplayName("鍥炲師鐐规ā寮�")] + //[Description("HomeMode锛氬洖鍘熺偣妯″紡銆�0锛氫竴鑸ā寮� 1锛氭瀬闄愰檺浣嶆ā寮� 2锛氬閮ㄨЕ鍙戞ā寮�")] + //public int HomeMode { get; set; } = 0; + + //[Category("鍥炲師鐐硅缃�")] + //[DisplayName("鍥炲師鐐规柟鍚�")] + //[Description("IsHomePositive锛氬洖鍘熺偣鏂瑰悜銆� true锛氭鏂瑰悜寮�濮� false锛氳礋鏂瑰悜寮�濮�")] + //public bool IsHomePositive { get; set; } = true; + + //[Category("鍥炲師鐐硅缃�")] + //[DisplayName("鏄惁鑷姩鍥炲師鐐�")] + //[Description("IsAutoGoHome锛氭槸鍚﹁嚜鍔ㄥ洖鍘熺偣銆� true锛氭槸 false锛氬惁")] + //public bool IsAutoGoHome { get; set; } = false; + + //[Category("瓒呮椂璁剧疆")] + //[DisplayName("鍥炲師鐐硅秴鏃�")] + //[Description("TimeOutHome锛氬洖鍘熺偣瓒呮椂锛屽崟浣嶆绉�")] + //public int TimeOutHome { get; set; } = 30000; + + //[Category("瓒呮椂璁剧疆")] + //[DisplayName("杩愬姩瓒呮椂")] + //[Description("TimeOutMove锛氳繍鍔ㄨ秴鏃讹紝鍗曚綅姣")] + //public int TimeOutMove { get; set; } = 10000; + + //[Category("寮�闂幆璁剧疆")] + //[DisplayName("鏄惁浣跨敤Cmmd鍥為")] + //[Description("IsUseCmmdPosition锛氭槸鍚︿娇鐢–mmd鍥為")] + //public bool IsUseCmmdPosition { get; set; } = false; + + //[Category("寮�闂幆璁剧疆")] + //[DisplayName("鏄惁浣跨敤鏉垮崱鍙嶉鍋滄淇″彿")] + //[Description("IsUseMDNStopSignal锛氭槸鍚︿娇鐢ㄦ澘鍗″弽棣堝仠姝俊鍙�")] + //public bool IsUseMDNStopSignal { get; set; } = false; + + //[Category("寮�闂幆璁剧疆")] + //[DisplayName("鏄惁鍚敤鎶ヨ")] + //[Description("IsUseWarning锛氭槸鍚﹀惎鐢ㄦ姤璀�")] + //public bool IsUseWarning { get; set; } = false; + + [Category("鍘熺偣閰嶇疆")] + [DisplayName("鍥炲師鐐瑰弬鏁�")] + [Description("鍥炲師鐐瑰弬鏁�")] [TypeConverter(typeof(ComplexObjectConvert))] [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] - public VelocityPara VelocityPara { get; set; } = new VelocityPara(); - - [Category("鍥炲師鐐硅缃�")] - [DisplayName("鍥炲師鐐规ā寮�")] - [Description("HomeMode锛氬洖鍘熺偣妯″紡銆�0锛氫竴鑸ā寮� 1锛氭瀬闄愰檺浣嶆ā寮� 2锛氬閮ㄨЕ鍙戞ā寮�")] - public int HomeMode { get; set; } = 0; - - [Category("鍥炲師鐐硅缃�")] - [DisplayName("鍥炲師鐐规柟鍚�")] - [Description("IsHomePositive锛氬洖鍘熺偣鏂瑰悜銆� true锛氭鏂瑰悜寮�濮� false锛氳礋鏂瑰悜寮�濮�")] - public bool IsHomePositive { get; set; } = true; - - [Category("鍥炲師鐐硅缃�")] - [DisplayName("鏄惁鑷姩鍥炲師鐐�")] - [Description("IsAutoGoHome锛氭槸鍚﹁嚜鍔ㄥ洖鍘熺偣銆� true锛氭槸 false锛氬惁")] - public bool IsAutoGoHome { get; set; } = false; - - [Category("瓒呮椂璁剧疆")] - [DisplayName("鍥炲師鐐硅秴鏃�")] - [Description("TimeOutHome锛氬洖鍘熺偣瓒呮椂锛屽崟浣嶆绉�")] - public int TimeOutHome { get; set; } = 30000; - - [Category("瓒呮椂璁剧疆")] - [DisplayName("杩愬姩瓒呮椂")] - [Description("TimeOutMove锛氳繍鍔ㄨ秴鏃讹紝鍗曚綅姣")] - public int TimeOutMove { get; set; } = 10000; - - [Category("寮�闂幆璁剧疆")] - [DisplayName("鏄惁浣跨敤Cmmd鍥為")] - [Description("IsUseCmmdPosition锛氭槸鍚︿娇鐢–mmd鍥為")] - public bool IsUseCmmdPosition { get; set; } = false; - - [Category("寮�闂幆璁剧疆")] - [DisplayName("鏄惁浣跨敤鏉垮崱鍙嶉鍋滄淇″彿")] - [Description("IsUseMDNStopSignal锛氭槸鍚︿娇鐢ㄦ澘鍗″弽棣堝仠姝俊鍙�")] - public bool IsUseMDNStopSignal { get; set; } = false; - - [Category("寮�闂幆璁剧疆")] - [DisplayName("鏄惁鍚敤鎶ヨ")] - [Description("IsUseWarning锛氭槸鍚﹀惎鐢ㄦ姤璀�")] - public bool IsUseWarning { get; set; } = false; + public GoHomePara GoHomePara { get; set; } = new GoHomePara(); [Category("鏆傚仠閰嶇疆")] [DisplayName("鏄惁鍚敤绔嬪嵆鏆傚仠")] [Description("IsImmediatePause锛氭槸鍚﹀惎鐢ㄧ珛鍗虫殏鍋�")] public bool IsImmediatePause { get; set; } = false; - [Category("鏆傚仠閰嶇疆")] - [DisplayName("杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] - [Description("ImmediatePauseSections锛氬綋杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] - [TypeConverter(typeof(CollectionCountConvert))] - [Editor(typeof(ComplexCollectionEditor<Section>), typeof(UITypeEditor))] - public List<Section> ImmediatePauseSections { get; set; } = new List<Section>(); + //[Category("鏆傚仠閰嶇疆")] + //[DisplayName("杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] + //[Description("ImmediatePauseSections锛氬綋杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] + //[TypeConverter(typeof(CollectionCountConvert))] + //[Editor(typeof(ComplexCollectionEditor<Section>), typeof(UITypeEditor))] + //public List<Section> ImmediatePauseSections { get; set; } = new List<Section>(); public string GetDisplayText() { @@ -136,12 +145,12 @@ [Category("閫熷害閰嶇疆")] [DisplayName("鍔犻�熷害")] [Description("Acc锛氬姞閫熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] - public double Acc { get; set; } = 1; + public double Acc { get; set; } = 0; [Category("閫熷害閰嶇疆")] [DisplayName("鍑忛�熷害")] [Description("鍑忛�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] - public double Dec { get; set; } = 1; + public double Dec { get; set; } = 0; } /// <summary> @@ -149,163 +158,242 @@ /// </summary> public class GoHomePara { - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鍥炲師鐐规柟寮�")] - [Description("HomeMode锛氬洖鍘熺偣鏂瑰紡 锛圚OME_MODE_LIMIT = 10; HOME_MODE_LIMIT_HOME = 11; HOME_MODE_LIMIT_INDEX = 12; HOME_MODE_LIMIT_HOME_INDEX = 13;HOME_MODE_HOME = 20;HOME_MODE_HOME_INDEX = 22;HOME_MODE_INDEX = 30;")] - public short HomeMode { get; set; } = 11; + //[Category("鍥炲師鐐瑰弬鏁�")] + //[DisplayName("鍥炲師鐐规柟寮�")] + //[Description("HomeMode锛氬洖鍘熺偣鏂瑰紡 锛圚OME_MODE_LIMIT = 10; HOME_MODE_LIMIT_HOME = 11; HOME_MODE_LIMIT_INDEX = 12; HOME_MODE_LIMIT_HOME_INDEX = 13;HOME_MODE_HOME = 20;HOME_MODE_HOME_INDEX = 22;HOME_MODE_INDEX = 30;")] + //public short HomeMode { get; set; } = 11; - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鍥炲師鐐规柟鍚�")] - [Description("HomeDir锛�1 姝e悜锛�-1 璐熷悜")] - public short HomeDir { get; set; } = 1; + //[Category("鍥炲師鐐瑰弬鏁�")] + //[DisplayName("杈圭紭")] + //[Description("edge锛氳竟缂�")] + //public short Edge { get; set; } = 0; - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鍥炲師鐐规柟鍚�")] - [Description("HomeDir锛�1 姝e悜锛�-1 璐熷悜")] - public short Edge { get; set; } = 0; + //[Category("鍥炲師鐐归�熷害")] + //[DisplayName("鍥炲師鐐规渶浣庨�熷害")] + //[Description("LowVelocity锛氶�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] + //public double LowVelocity { get; set; } = 50; - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鍥炲師鐐规渶浣庨�熷害")] - [Description("LowVelocity锛氶�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] - public double LowVelocity { get; set; } = 50; + [Category("鍥炲師鐐归�熷害")] + [DisplayName("鍥炲師鐐归�熷害")] + [Description("HomeVelocity锛氶�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] + public double HomeVelocity { get; set; } = 50; + //[Category("鍥炲師鐐瑰弬鏁�")] + //[DisplayName("鎼滅储璺濈")] + //[Description("SearchHomeDistance锛氭悳绱㈣窛绂�")] + //public int SearchHomeDistance { get; set; } = 9999999; - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鍥炲師鐐规渶楂橀�熷害")] - [Description("HighVelocity锛氶�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] - public double HighVelocity { get; set; } = 50; - - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("鎼滄悳璺濈")] - [Description("SearchHomeDistance锛氭悳鎼滆窛绂�")] - public int SearchHomeDistance { get; set; } = 9999999; - - [Category("鍥炲師鐐瑰弬鏁�")] + [Category("鍥炲師鐐瑰亸绉�")] [DisplayName("鍋忕Щ璺濈")] [Description("HomeOffset锛氬亸绉昏窛绂�")] public int HomeOffset { get; set; } = 0; - [Category("鍥炲師鐐瑰弬鏁�")] - [DisplayName("璺宠繃姝ラ暱")] - [Description("EscapeStep锛氳烦杩囨闀�")] - public int EscapeStep { get; set; } = 1000; + //[Category("鍥炲師鐐瑰亸绉�")] + //[DisplayName("璺宠繃姝ラ暱")] + //[Description("EscapeStep锛氳烦杩囨闀�")] + //public int EscapeStep { get; set; } = 1000; + [Category("鍥炲師鐐规柟鍚�")] + [DisplayName("璧峰杩愬姩鏂瑰悜")] + [Description("鍥炲師鐐规椂锛岃酱鐨勫垵濮嬭繍鍔ㄦ柟鍚戯細true 姝e悜锛宖alse 璐熷悜")] + public bool IsHomeDirPositive { get; set; } = true; + + [Category("鍥炲師鐐规柟鍚�")] + [DisplayName("鍘熺偣鎹曟崏鏂瑰悜")] + [Description("鎹曟崏鍘熺偣鏃讹紝杞寸殑杩愬姩鏂瑰悜锛歵rue 姝e悜锛宖alse 璐熷悜")] + public bool IsCaptureDirPositive { get; set; } = true; + + [Category("鍥炲師鐐硅秴鏃�")] + [DisplayName("鍥炲師鐐硅秴鏃�")] + [Description("鍥炲師鐐硅秴鏃讹紝鍗曚綅绉�")] + public int GoHomeTimeOut { get; set; } = 60; + + [Category("鍘熺偣鎹曡幏妯″紡")] + [Description("鍘熺偣鎹曡幏妯″紡锛宼rue锛氫娇鐢ㄦ崟鑾锋ā寮忥紝false锛氫娇鐢ㄥ師鐐硅緭鍏ヤ俊鍙�")] + [DisplayName("鍘熺偣鎹曡幏妯″紡")] + public bool IsCaptureMode { get; set; } = true; + } + + /// <summary> + /// 鏉垮崱杩愬姩鐘舵�佸璞� + /// </summary> + public class AxisMovingStatus : IComplexDisplay + { + /// <summary> + /// 杞寸储寮� + /// </summary> + public int AxisIndex { get; set; } + + /// <summary> + /// 杞村悕绉� + /// </summary> + public string AxisName { get; set; } + + /// <summary> + /// 褰撳墠浣嶇疆 + /// </summary> + public int CurPosition { get; set; } + + /// <summary> + /// 鐩殑鍦� + /// </summary> + public int Destination { get; set; } + + /// <summary> + /// 褰撳墠閫熷害鍙傛暟 + /// </summary> + public double CurVelocity { get; set; } + + /// <summary> + /// 瑙勫垝閫熷害鍙傛暟 + /// </summary> + public double PrfVelocity { get; set; } + + /// <summary> + /// 杞寸姸鎬� + /// </summary> + public int AxisStatus { get; set; } + + public string GetDisplayText() + { + return $"杞磠AxisIndex}:{AxisName}-褰撳墠鐘舵�侊細{AxisStatus}-褰撳墠浣嶇疆锛歿CurPosition}-瑙勫垝浣嶇疆锛歿Destination}"; + } } /// <summary> /// 杩愬姩瀵硅薄 /// </summary> - public class MovingOption : INotifyPropertyChanged, IComplexDisplay + public class MovingOption : IComplexDisplay { - private int axisIndex = 0; [Category("杩愬姩閰嶇疆")] [DisplayName("杩愬姩杞寸储寮�")] [Description("AxisIndex锛氳繍鍔ㄨ酱绱㈠紩")] [TypeConverter(typeof(AxisIndexConvert))] + public string AxisIndexStr { get; set; } = "1"; + + [Browsable(false)] + [JsonIgnore] public int AxisIndex { - get => axisIndex; - set - { - if (axisIndex != value) - { - axisIndex = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex")); - } - axisIndex = value; - } + get => int.Parse(AxisIndexStr); + set => AxisIndexStr = value.ToString(); } - private MotorMoveMode moveMode = MotorMoveMode.Normal; + //private int axisIndex = 0; + //[Category("杩愬姩閰嶇疆")] + //[DisplayName("杩愬姩杞寸储寮�")] + //[Description("AxisIndex锛氳繍鍔ㄨ酱绱㈠紩")] + //[TypeConverter(typeof(AxisIndexConvert))] + //public int AxisIndex { get; set; } + //{ + // get => axisIndex; + // set + // { + // if (axisIndex != value) + // { + // axisIndex = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex")); + // } + // axisIndex = value; + // } + //} + + //private MotionMode moveMode = MotionMode.Normal; [Category("杩愬姩閰嶇疆")] [DisplayName("杩愬姩妯″紡")] [Description("MoveMode锛氳繍鍔ㄦā寮�")] - public MotorMoveMode MoveMode - { - get => moveMode; - set - { - if (moveMode != value) - { - moveMode = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode")); - } + public MotionMode MoveMode { get; set; } = MotionMode.Normal; + //{ + // get => moveMode; + // set + // { + // if (moveMode != value) + // { + // moveMode = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode")); + // } - moveMode = value; - } - } + // moveMode = value; + // } + //} - private bool isAbsolute = true; + //private bool isAbsolute = true; [Category("杩愬姩閰嶇疆")] [DisplayName("鏄惁缁濆杩愬姩")] [Description("IsAbsolute锛氭槸鍚︾粷瀵硅繍鍔�")] - public bool IsAbsolute - { - get => isAbsolute; - set - { - if (isAbsolute != value) - { - isAbsolute = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsAbsolute")); - } + public bool IsAbsolute { get; set; } = true; + //{ + // get => isAbsolute; + // set + // { + // if (isAbsolute != value) + // { + // isAbsolute = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsAbsolute")); + // } - isAbsolute = value; - } - } + // isAbsolute = value; + // } + //} - private int destination = 0; + //private int destination = 0; [Category("杩愬姩閰嶇疆")] [DisplayName("鐩殑鍦�")] [Description("Destination锛氱洰鐨勫湴")] - public int Destination - { - get => destination; - set - { - if (destination != value) - { - destination = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Destination")); - } + public int Destination { get; set; } + //{ + // get => destination; + // set + // { + // if (destination != value) + // { + // destination = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Destination")); + // } - destination = value; - } - } + // destination = value; + // } + //} - private VelocityPara velocityPara = new VelocityPara(); + //private VelocityPara velocityPara = new VelocityPara(); [Category("杩愬姩閰嶇疆")] [DisplayName("閫熷害鍙傛暟")] [Description("VelocityPara锛氶�熷害鍙傛暟")] [TypeConverter(typeof(ComplexObjectConvert))] [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] - public VelocityPara VelocityPara - { - get => velocityPara; - set - { - velocityPara = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VelocityPara")); - } - } + public VelocityPara VelocityPara { get; set; } = new VelocityPara(); + //{ + // get => velocityPara; + // set + // { + // velocityPara = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VelocityPara")); + // } + //} - private GoHomePara goHomePara = new GoHomePara(); - [Category("杩愬姩閰嶇疆")] - [DisplayName("鍥炲師鐐瑰弬鏁�")] - [Description("GoHomePara锛氶�熷害鍙傛暟")] - [TypeConverter(typeof(ComplexObjectConvert))] - [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] - public GoHomePara GoHomePara - { - get => goHomePara; - set - { - goHomePara = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara")); - } - } + //private GoHomePara goHomePara = new GoHomePara(); + //[Category("杩愬姩閰嶇疆")] + //[DisplayName("鍥炲師鐐瑰弬鏁�")] + //[Description("GoHomePara锛氶�熷害鍙傛暟")] + //[TypeConverter(typeof(ComplexObjectConvert))] + //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] + //public GoHomePara GoHomePara { get; set; } = new GoHomePara(); + //{ + // get => goHomePara; + // set + // { + // goHomePara = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara")); + // } + //} + + [Category("鏉垮崱杩愬姩閰嶇疆")] + [Description("瓒呮椂璁剧疆锛屽崟浣嶏細ms")] + [DisplayName("杩愬姩瓒呮椂")] + public int MovingTimeout { get; set; } = 0; internal List<AxisSetting> _axisSettingList = new List<AxisSetting>(); + public void SetAxisSetting(List<AxisSetting> settings) { if (settings != null) @@ -314,7 +402,7 @@ public string GetDisplayText() { - string axisName = AxisIndex.ToString(); + string axisName = AxisIndexStr; var axisSet = _axisSettingList.FirstOrDefault(a => a.AxisIndex == AxisIndex); if (axisSet != null) { @@ -322,70 +410,113 @@ } return axisName + "," + MoveMode.ToString() + "," + (IsAbsolute ? "Abs" : "Rel") + "," + Destination; } - public event PropertyChangedEventHandler PropertyChanged; + //public event PropertyChangedEventHandler PropertyChanged; } - public class AxisIndexConvert : TypeConverter + public class AxisIndexConvert : ComboBoxItemTypeConvert { - Dictionary<int, string> _indexNameDict = new Dictionary<int, string>(); - - public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + public override Hashtable GetConvertHash(ITypeDescriptorContext context) { - return true; - } - - public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) - { - MovingOption mo = context.Instance as MovingOption; - - _indexNameDict = mo._axisSettingList.ToDictionary(a => a.AxisIndex, a => a.AxisIndex + "-" + a.AxisName); - - return new StandardValuesCollection(_indexNameDict.Keys); - } - - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - if (sourceType == typeof(string)) + Hashtable table = new Hashtable(); + if (context.Instance is MovingOption op) { - return true; - } - return base.CanConvertFrom(context, sourceType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v) - { - if (v is string) - { - foreach (var indexName in _indexNameDict) + op._axisSettingList.ForEach(a => { - if (indexName.Value == v.ToString()) - { - return indexName.Key; - } - } - return Convert.ToInt32(v); + table[a.AxisIndex.ToString()] = a.AxisName; + }); } - return base.ConvertFrom(context, culture, v); + + return table; } - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v, Type destinationType) - { - if (destinationType == typeof(string)) - { - if (_indexNameDict.ContainsKey(Convert.ToInt32(v))) - { - return _indexNameDict[Convert.ToInt32(v)]; - } - } - return base.ConvertTo(context, culture, v, destinationType); - } + //public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + //{ + // bool flag = base.CanConvertFrom(context, sourceType); + // return flag; + //} - public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) - { - return false; - } + //public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + //{ + // return base.CanConvertTo(context, destinationType); + //} + + //public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object v) + //{ + // //if (string.IsNullOrWhiteSpace(v.ToString())) + // //{ + // // return 0; + // //} + + // return base.ConvertFrom(context, culture, Convert.ToInt32(v)); + //} + + //public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object v, Type destinationType) + //{ + // return base.ConvertTo(context, culture, v, destinationType); + //} } + //public class AxisIndexConvert : TypeConverter + //{ + // Dictionary<int, string> _indexNameDict = new Dictionary<int, string>(); + + // public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + // { + // return true; + // } + + // public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + // { + // MovingOption mo = context.Instance as MovingOption; + + // _indexNameDict = mo._axisSettingList.ToDictionary(a => a.AxisIndex, a => a.AxisIndex + "-" + a.AxisName); + + // return new StandardValuesCollection(_indexNameDict.Keys); + // } + + // public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + // { + // if (sourceType == typeof(string)) + // { + // return true; + // } + // return base.CanConvertFrom(context, sourceType); + // } + + // public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v) + // { + // if (v is string) + // { + // foreach (var indexName in _indexNameDict) + // { + // if (indexName.Value == v.ToString()) + // { + // return indexName.Key; + // } + // } + // return Convert.ToInt32(v); + // } + // return base.ConvertFrom(context, culture, v); + // } + + // public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v, Type destinationType) + // { + // if (destinationType == typeof(string)) + // { + // if (_indexNameDict.ContainsKey(Convert.ToInt32(v))) + // { + // return _indexNameDict[Convert.ToInt32(v)]; + // } + // } + // return base.ConvertTo(context, culture, v, destinationType); + // } + + // public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) + // { + // return false; + // } + //} + public class AxisConflictSet : IComplexDisplay { [Category("1.杞村啿绐佹潯浠�")] -- Gitblit v1.8.0