Files
2026-09-09 19:21:21 +08:00

350 lines
9.1 KiB
C#

using JinYuan.ControlLib.Models;
using JinYuan.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace JinYuan.ControlLib
{
public partial class UCElectricityMeterV : UserControl
{
public UCElectricityMeterV()
{
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.TitleName = smartMeter;
}
}
#region 相电压
private string phaseVoltageA = "A相电压";
[Browsable(true)]
[Category("自定义属性")]
[Description("设置或获取控件A相电压")]
public string Text1
{
get { return phaseVoltageA; }
set
{
phaseVoltageA = value;
this.txtPhaseVoltageA.Text = 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.txtTotalPower.Text = activePower;
}
}
private string powerFactor = "总功率因素";
[Browsable(true)]
[Category("自定义属性")]
[Description("设置或获取控件总功率因素")]
public string Text11
{
get { return powerFactor; }
set
{
powerFactor = value;
this.txtPowerFactor.Text = powerFactor;
}
}
private string pt = "电压变比";
[Browsable(true)]
[Category("自定义属性")]
[Description("设置或获取控件电压变比")]
public string Text12
{
get { return pt; }
set
{
pt = value;
this.txtPt.Text = pt;
}
}
private string ct = "电流变比";
[Browsable(true)]
[Category("自定义属性")]
[Description("设置或获取控件电流变比")]
public string Text13
{
get { return ct; }
set
{
ct = value;
this.txtCt.Text = ct;
}
}
private string accumulatedElectricity = "累计电能";
[Browsable(true)]
[Category("自定义属性")]
[Description("设置或获取控件累计电能")]
public string Text14
{
get { return accumulatedElectricity; }
set
{
accumulatedElectricity = value;
this.txtAccumulatedElectricity.Text = 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.lblAccumulatedElectricity.Text = m.AccumulatedElectricity.ToString();
//A相电压 V
this.lblPhaseVoltageA.Text = m.PhaseVoltageA.ToString();
//B相电压
this.lblPhaseVoltageB.Text = m.PhaseVoltageB.ToString();
//C相电压
this.lblPhaseVoltageC.Text = m.PhaseVoltageC.ToString();
// A相电流
this.lblPhaseCurrentA.Text = m.PhaseCurrentA.ToString();
// B相电流
this.lblPhaseCurrentB.Text = m.PhaseCurrentB.ToString();
// C相电流
this.lblPhaseCurrentC.Text = m.PhaseCurrentC.ToString();
// A相功率
this.lblPhasePowerA.Text = m.PhasePowerA.ToString();
// B相功率
this.lblPhasePowerB.Text = m.PhasePowerB.ToString();
// C相功率
this.lblPhasePowerC.Text = m.PhasePowerC.ToString();
// 总有功功率
this.lblActivePower.Text = m.ActivePower.ToString();
// 总功率因数
this.lblPowerFactor.Text = m.PowerFactor.ToString();
// 电压变比
this.lblPt.Text = m.pt.ToString();
// 电流变比
this.lblCt.Text = m.ct.ToString();
}
}
}