123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System.Reflection;
- using System.Windows.Forms;
- using Uestc.Auto6.Dso.Core;
- using Uestc.Auto6.Dso.Core.Decode;
- using Uestc.Auto6.Dso.ComModel;
- using Uni_Trend.MSO7000X.Language;
- using Uni_Trend.MSO7000X.Common.Helper;
- using Uni_Trend.MSO7000X.UserControls;
- namespace Uestc.Auto6.Dso.Protocol.XXXX
- {
- public partial class XXXXSetControl : UserControl, IProtocolView
- {
- #region 属性定义
- protected new Boolean DesignMode
- {
- get
- {
- Boolean rtnflag = false;
- #if DEBUG
- rtnflag = DesignTimeHelper.InDesignMode(this);
- #endif
- return rtnflag;
- }
- }
- public XXXXDecodePrsnt DestinDecodePrsnt
- {
- get => _DestinDecodePrsnt;
- set
- {
- if (_DestinDecodePrsnt != value)
- {
- _DestinDecodePrsnt = value;
- ///当有新的同步目标时,应先将目标中参数同步到本地<see cref="I2CDecodePsrnt"/>属性中
- if (_XXXXDecodePsrnt != null && value != null)
- {
- typeof(XXXXDecodePrsnt).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.CanWrite).ToList().ForEach(x =>
- {
- x.SetValue(_XXXXDecodePsrnt, x.GetValue(value));
- });
- }
- }
- }
- }
- private XXXXDecodePrsnt _DestinDecodePrsnt;
- private XXXXDecodePrsnt _XXXXDecodePsrnt => Presenter as XXXXDecodePrsnt;
- public IProtocolPrsnt Presenter { get; set; }
- private FloatForm _FloatForm;
- #endregion 属性定义
- public XXXXSetControl()
- {
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- Init();
- }
- private void Init()
- {
- GetDestinPrsnt();
- }
- /// <summary>
- /// 获取需要同步的Prsnt
- /// 当<see cref="_XXXXDecodePsrnt"/>为<see cref="null"/>时表示不需要与其他Prsnt进行同步
- /// </summary>
- private void GetDestinPrsnt()
- {
-
- }
- /// <summary>
- /// 同步两个Prsnt
- /// </summary>
- /// <param name="propertyName">属性名称</param>
- private void DecodeSynchronization(String propertyName)
- {
- if (DestinDecodePrsnt == null)
- return;
- ///由于使用了<see cref="IXXXXDecodePrsnt.SDA"/>进行判断具体同步的目标
- ///因此<see cref="IXXXXDecodePrsnt.SDA"/>参数不进行同步
- if (propertyName == nameof(I2CDecodePrsnt.SDA))
- return;
- if (String.IsNullOrEmpty(propertyName))
- {
- typeof(I2CDecodePrsnt).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.CanWrite).ToList().ForEach(x =>
- {
- x.SetValue(DestinDecodePrsnt, x.GetValue(XXXXDecodePsrnt));
- });
- }
- else
- {
- PropertyInfo propertyInfo = typeof(XXXXDecodePrsnt).GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
- if (propertyInfo != null)
- propertyInfo.SetValue(DestinDecodePrsnt, propertyInfo.GetValue(XXXXDecodePsrnt));
- }
- }
-
- public void UpdateView(String propertyName)
- {
- DecodeSynchronization(propertyName);
- if (String.IsNullOrEmpty(propertyName))
- {
- UpdateView();
- return;
- }
- }
- private void UpdateView()
- {
- this.GetType().GetMethods().Where(x => x.GetCustomAttribute<UpdatePropertyAttribute>() != null).ToList().ForEach(x => x?.Invoke(this, null));
- this.Refresh();
- }
-
- }
- }
|