using JinYuan.Models; using System.ComponentModel; using System.Windows.Forms; namespace JinYuan.ControlLib { public partial class UCElectricityMeterH : UserControl { public UCElectricityMeterH() { InitializeComponent(); //设置控件样式,去除缓冲 this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Selectable, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); } //#region 减少闪烁 protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } } //#endregion private string smartMeter = "智能电表"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件A相电压")] public override string Text { get { return smartMeter; } set { smartMeter = value; this.UCtitleName.Text = smartMeter; } } #region 相电压 private string phaseVoltageA = "A相电压"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件A相电压")] public string Text1 { get { return phaseVoltageA; } set { phaseVoltageA = value; this.txtPhaseVoltageA.TitleName = phaseVoltageA; } } private string phaseVoltageB = "B相电压"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件B相电压")] public string Text2 { get { return phaseVoltageB; } set { phaseVoltageB = value; this.txtPhaseVoltageB.Text = phaseVoltageB; } } private string phaseVoltageC = "C相电压"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件C相电压")] public string Text3 { get { return phaseVoltageC; } set { phaseVoltageC = value; this.txtPhaseVoltageC.Text = phaseVoltageC; } } #endregion #region 相电流 private string phaseCurrentA = "A相电流"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件A相电流")] public string Text4 { get { return phaseCurrentA; } set { phaseCurrentA = value; this.txtPhaseCurrentA.Text = phaseCurrentA; } } private string phaseCurrentB = "B相电流"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件B相电流")] public string Text5 { get { return phaseCurrentB; } set { phaseCurrentB = value; this.txtPhaseCurrentB.Text = phaseCurrentB; } } private string phaseCurrentC = "C相电流"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件C相电流")] public string Text6 { get { return phaseCurrentC; } set { phaseCurrentC = value; this.txtPhaseCurrentC.Text = phaseCurrentC; } } #endregion #region 相功率 private string phasePowerA = "A相功率"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件A相功率")] public string Text7 { get { return phasePowerA; } set { phasePowerA = value; this.txtPhasePowerA.Text = phasePowerA; } } private string phasePowerB = "B相功率"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件B相功率")] public string Text8 { get { return phasePowerB; } set { phasePowerB = value; this.txtPhasePowerB.Text = phasePowerB; } } private string phasePowerC = "C相功率"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件C相功率")] public string Text9 { get { return phasePowerC; } set { phasePowerC = value; this.txtPhasePowerC.Text = phasePowerC; } } #endregion private string activePower = "总有功功率"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件总有功功率")] public string Text10 { get { return activePower; } set { activePower = value; this.txtActivePower.TitleName = activePower; } } private string powerFactor = "总功率因数"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件总功率因数")] public string Text11 { get { return powerFactor; } set { powerFactor = value; this.txtPowerFactor.TitleName = powerFactor; } } private string pt = "电压变比"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件电压变比")] public string Text12 { get { return pt; } set { pt = value; this.txtPt.TitleName = pt; } } private string ct = "电流变比"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件电流变比")] public string Text13 { get { return ct; } set { ct = value; this.txtCt.TitleName = ct; } } private string accumulatedElectricity = "累计电能"; [Browsable(true)] [Category("自定义属性")] [Description("设置或获取控件累计电能")] public string Text14 { get { return accumulatedElectricity; } set { accumulatedElectricity = value; this.txtAccumulatedElectricity.TitleName = accumulatedElectricity; } } private JinYuan.Models.ElectricEnergy _electricEnergy = new JinYuan.Models.ElectricEnergy(); [Browsable(false)] [Category("自定义属性")] [Description("设置或获取实体类值")] public ElectricEnergy ElectricEnergy { get { return _electricEnergy; } set { if (value != null) { _electricEnergy = value; SetElectricEnergy(_electricEnergy); } } } private void SetElectricEnergy(ElectricEnergy m) { //累计电能 this.txtAccumulatedElectricity.CurrentValue = m.AccumulatedElectricity.ToString(); //A相电压 V this.txtPhaseVoltageA.CurrentValue = m.PhaseVoltageA.ToString(); //B相电压 this.txtPhaseVoltageB.CurrentValue = m.PhaseVoltageB.ToString(); //C相电压 this.txtPhaseVoltageC.CurrentValue = m.PhaseVoltageC.ToString(); // A相电流 this.txtPhaseCurrentA.CurrentValue = m.PhaseCurrentA.ToString(); // B相电流 this.txtPhaseCurrentB.CurrentValue = m.PhaseCurrentB.ToString(); // C相电流 this.txtPhaseCurrentC.CurrentValue = m.PhaseCurrentC.ToString(); // A相功率 this.txtPhasePowerA.CurrentValue = m.PhasePowerA.ToString(); // B相功率 this.txtPhasePowerB.CurrentValue = m.PhasePowerB.ToString(); // C相功率 this.txtPhasePowerC.CurrentValue = m.PhasePowerC.ToString(); // 总有功功率 this.txtActivePower.CurrentValue = m.ActivePower.ToString(); // 总功率因数 this.txtPowerFactor.CurrentValue = m.PowerFactor.ToString(); // 电压变比 this.txtPt.CurrentValue = m.pt.ToString(); // 电流变比 this.txtCt.CurrentValue = m.ct.ToString(); } } }