123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Uestc.Auto6.Dso.Core;
- using Uestc.Auto6.Dso.Core.Decode;
- using Uestc.Auto6.Dso.ComModel;
- using Uni_Trend.MSO7000X.Common.Helper;
- using Uni_Trend.MSO7000X.UserControls;
- using Uni_Trend.MSO7000X.UserControls.Style;
- using Uni_Trend.MSO7000X.Language;
- namespace Uestc.Auto6.Dso.Protocol.FlexRay
- {
- public partial class FlexRayIndicatorPage : UserControl, ITriggerSerialView
- {
- #region 属性
- public FlexRayTrigSerialPrsnt Presenter { get; set; }
- ITriggerPrsnt IView<ITriggerPrsnt>.Presenter
- {
- get => Presenter;
- set => Presenter = (FlexRayTrigSerialPrsnt)value;
- }
- protected new Boolean DesignMode
- {
- get
- {
- Boolean rtnflag = false;
- #if DEBUG
- rtnflag = DesignTimeHelper.InDesignMode(this);
- #endif
- return rtnflag;
- }
- }
- #endregion 属性
- public FlexRayIndicatorPage()
- {
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- Uni_Trend.MSO7000X.UserControls.Style.DefaultStyleManager.Instance.RegisterControlRecursion(this, StyleFlag.FontSize);
- InitView();
- }
- private void InitView()
- {
- InitIndicator();
- UpdateView();
- }
- public void UpdateView(Object presenter, String propertyName)
- {
- if (String.IsNullOrEmpty(propertyName))
- {
- UpdateView();
- return;
- }
- this.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(x =>
- {
- UpdatePropertyAttribute attribute = x.GetCustomAttribute<UpdatePropertyAttribute>();
- return attribute != null && attribute.PropertyName == propertyName;
- }).FirstOrDefault()?.Invoke(this, null);
- }
- private void UpdateView()
- {
- this.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(x => x.GetCustomAttribute<UpdatePropertyAttribute>() != null).ToList().ForEach(x =>
- {
- x?.Invoke(this, null);
- });
- this.Refresh();
- }
- private void InitIndicator()
- {
- this.CbxIndicatorRelation.DataSource = Enum.GetValues<ProtocolFlexRay.Indicator>().Select(x =>
- {
- String key = String.Empty;
- key = Properties.Resources.ResourceManager.GetString(x.GetType().ReflectedType.FullName + "." + x.GetType().Name + "." + x.ToString());
- if (String.IsNullOrEmpty(key))
- {
- key = x.ToString();
- }
- return new KeyValuePair<String, ProtocolFlexRay.Indicator>(key, x);
- }).ToList();
- this.CbxIndicatorRelation.ValueMember = "Value";
- this.CbxIndicatorRelation.DisplayMember = "Key";
- this.CbxIndicatorRelation.SelectedValueChanged += (_, _) =>
- {
- Presenter.Indicator = (ProtocolFlexRay.Indicator)CbxIndicatorRelation.SelectedValue;
- };
- UpdateIndicator();
- }
- [UpdateProperty(nameof(FlexRayTrigSerialPrsnt.Indicator))]
- private void UpdateIndicator()
- {
- this.CbxIndicatorRelation.SelectedValue = Presenter.Indicator;
- }
- }
- }
|