You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.4 KiB
C#
116 lines
3.4 KiB
C#
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
|
|
using Mesnac.Controls.Base;
|
|
using Mesnac.Controls.ChemicalWeighing;
|
|
using Mesnac.Controls.Default;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.AutoControl
|
|
{
|
|
public class ControlsHelper
|
|
{
|
|
/// <summary>
|
|
/// 控件导入
|
|
/// </summary>
|
|
public static void ControlImport(MCTextBoxEntity textE, ButtonEntity buttonE,
|
|
MCComboBoxEntity comboE, MCLabelEntity labelE, MCRadioButtonEntity radioE,
|
|
List<Control> McControls)
|
|
{
|
|
FillBase<MCTextBox>(textE, McControls);
|
|
FillBase<System.Windows.Forms.Button>(buttonE, McControls);
|
|
FillBase<MCCombobox>(comboE, McControls);
|
|
FillBase<MCLabel>(labelE, McControls);
|
|
FillBase<MCRadioButton>(radioE, McControls);
|
|
}
|
|
|
|
private static void FillBase<T>(object E, List<Control> McControls) where T : class
|
|
{
|
|
PropertyInfo[] sourcePropertyInfoList = E.GetType().GetProperties();
|
|
foreach (PropertyInfo sourceProperty in sourcePropertyInfoList)
|
|
{
|
|
string name = sourceProperty.Name;
|
|
var pro = McControls.FirstOrDefault(x => x.Name == name) as T;
|
|
sourceProperty.SetValue(E, pro);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单选选择
|
|
/// </summary>
|
|
/// <returns>返回单选的产线号 如果未选择返回0</returns>
|
|
public static int SingleSelect(MCRadioButtonEntity RadioE)
|
|
{
|
|
int no = 0;
|
|
if (Convert.ToBoolean(RadioE.Line1.MCValue))
|
|
{
|
|
no = 1;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line2.MCValue))
|
|
{
|
|
no = 2;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line3.MCValue))
|
|
{
|
|
no = 3;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line4.MCValue))
|
|
{
|
|
no = 4;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line5.MCValue))
|
|
{
|
|
no = 5;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line6.MCValue))
|
|
{
|
|
no = 6;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line7.MCValue))
|
|
{
|
|
no = 7;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line8.MCValue))
|
|
{
|
|
no = 8;
|
|
}
|
|
|
|
return no;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 单混机单选选择
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static int DrySelect(MCRadioButtonEntity RadioE)
|
|
{
|
|
if (Convert.ToBoolean(RadioE.Dry1.MCValue) == true)
|
|
{
|
|
return 1;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Dry2.MCValue) == true)
|
|
{
|
|
return 2;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Dry3.MCValue) == true)
|
|
{
|
|
return 3;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Dry4.MCValue) == true)
|
|
{
|
|
return 4;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|