using DataEntity.Share;
using DataRWDAL;
using DataRWDalDrive.DB;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using XCommon.Log;
using XCommon.Tip;
using XHandler.Class;
using XHandler.Class.DataEx;
using XHandler.Controls;
using XImagingXhandler.XDAL;
using System.Windows.Media;
using System.Text.RegularExpressions;
using XHandler.View.Liquids;
using DataEntity;
namespace XHandler.View.MethodProperty
{
///
/// MixProperty.xaml 的交互逻辑
///
public partial class MixProperty : UserControl, IMethodProperty,ILiquidObserver,ILatticeObserver,IDeviceArmObserver
{
public MethodMixing methodMix { get; set; }
public MethodMixing currmethodMixing = null;
public MethodEx method = null;
private Labware selectedLabware = null;
int curArmSelectedIndex = -1;
int curLiquidTypeSelectedIndex = -1;
int curLiquidRangeSelectedIndex = -1;
int curLiquidSelectedIndex = -1;
int curMixAspirateSelectIndex = -1;
int curMixDispenseSelectIndex = -1;
#region 全局属性变量
string isrun = "";
string status = "";
string name = "";
string label = "";
string labwareText = "";
string labwareValue = "";
string positionText = "";
string positionValue = "";
string armText = "";
string armValue = "";
private int[] channels = Shared.ChannelsId;
string wellarray = "";
bool enableSingleWellvolume = false;
List singlewellvolume = null;
string liquididText = "";
string liquididValue = "";
string liquidrangeidText = "";
string liquidrangeidValue = "";
string liquidpidText = "";
string liquidpidValue = "";
double mixvolume = 0.0d;
int mixcount = 0;
string mixAspiratePositionText = "";
int mixAspiratePositionValue = 0;
double mixAspirateDistance = 0.0d;
double mixAspirateSpeed = 0.0d;
string mixDispensePositionText = "";
int mixDispensePositionValue = 0;
double mixDispenseDistance = 0.0d;
double mixDispenseSpeed = 0.0d;
bool enableLiquidSensor = false;
int liquidSensorCount = 0;
double liquidSensorDistance = 0.0d;
double liquidSensorEndDistance = 0.0d;
double liquidSensorSpeed = 0.0d;
double liquidSensorRadio = 0.0d;
string liquidSensorDisIdText = "";
double liquidSensorDisIdValue = 0.0d;
bool enableLiquidFollow = false;
int liquidFollowType = 0;
string liquidFollowTypeName = "";
double liquidFollowSpeed = 0.0d;
double liquidFollowDistance = 0.0d;
double liquidFollowArea = 0.0d;
bool enableSensorBlock = false;
double liquidSensorBlockDistance = 0.0d;
string liquidSensorBlockDisIdText = "";
double liquidSensorBlockDisIdValue = 0.0d;
int mark = 0;
#endregion
public MixProperty()
{
InitializeComponent();
}
bool isLiquidUpdate = false;
///
/// 液体参数变更后,更新节点
///
/// 液体参数管理对象
public void ReceiveAndUpdate(LiquidManagement liquidManagement)
{
isLiquidUpdate = true;
ObservableCollection liquidTypeList = DataModule.getInstance().GetLiquidTypes();
cbLiquidType.ItemsSource = liquidTypeList;
cbLiquidType.SelectedIndex = -1;
cbLiquidType.SelectedValue = methodMix.liquididValue;
ObservableCollection liquidRangeList = DataModule.getInstance().GetLiquidRanges();
cbLiquidRange.ItemsSource = liquidRangeList.OrderBy(m => Convert.ToInt32(m.liquid_range_id));
cbLiquidRange.SelectedIndex = -1;
cbLiquidRange.SelectedValue = methodMix.liquidrangeidValue;
if (methodMix.liquidpidValue == "")
{
cbLiquid.SelectedIndex = 0;
}
else
{
cbLiquid.SelectedValue = methodMix.liquidpidValue;
}
}
///
/// 实验设计台面耗材位置变更后,更新节点
///
///
public void ReceiveAndUpdate(TestDesign testDesign)
{
if (testDesign.srcCanvas != null && testDesign.targetCanvas != null)
{
//判断当前的台面选择是不是来源位置上的,如果是就更新,不是就不更新
if (comboboxTablePos.SelectedItem.ToString() == testDesign.srcCanvas.Name)
{
SetTableName(testDesign.targetCanvas.Name, (Labware)(((ControlLabware)testDesign.targetCanvas.Children[testDesign.targetCanvas.Children.Count - 1]).DataContext));
}
else
{
}
}
}
///
/// 通道设置变更后,更新节点
///
///
public void ReceiveAndUpdate()
{
// 获取当前设备臂信息
List deviceArmList = DeviceArmDB.GetDeviceArmFromdb(Shared.SoftwareInformation.software_information_id);
Shared.DeviceArmList = deviceArmList;
DeviceArm deviceArm = Shared.DeviceArmList.SingleOrDefault(x => x.software_information_id.Equals(Shared.SoftwareInformation.software_information_id) && x.device_arm_id.Equals((cbArm.SelectedItem as DeviceArm).device_arm_id) && x.arm_type.Equals(1));
tipsChannel.TotalChannels = deviceArm.channels;
tipsChannel.SetTotalChannelCount(deviceArm.channels);
if (deviceArm.device_arm_property == "")
{
tipsChannel.SelectedChannels = new List { };
tipsChannel.SetSelectedChannels();
//Shared.ChannelsId = new int[];
return;
}
string[] strChannels = deviceArm.device_arm_property.Trim().Split(',');
int[] iChannels = new int[strChannels.Length];
for (int j = 0; j < strChannels.Length; j++)
{
iChannels[j] = Convert.ToInt32(strChannels[j]);
}
if (iChannels.Length > 0)
{
tipsChannel.SelectedChannels = iChannels.ToList();
tipsChannel.SetSelectedChannels();
}
if (methodMix != null)
{
methodMix.channels = iChannels;
}
}
public MixProperty(MethodEx method)
{
mark = 0;
InitializeComponent();
curArmSelectedIndex = 0;
curLiquidTypeSelectedIndex = 0;
curLiquidRangeSelectedIndex = 0;
curLiquidSelectedIndex = 0;
curMixAspirateSelectIndex = 0;
curMixDispenseSelectIndex = 0;
List armList = DataModule.getInstance().GetDeviceArm();
cbArm.ItemsSource = armList;
if (armList.Count == 2) //只有一个臂的情况下默认选中该臂
curArmSelectedIndex = 1;
else
curArmSelectedIndex = 0;
ObservableCollection liquidTypeList = DataModule.getInstance().GetLiquidTypes();
cbLiquidType.ItemsSource = liquidTypeList;
ObservableCollection liquidRangeList = DataModule.getInstance().GetLiquidRanges();
cbLiquidRange.ItemsSource = liquidRangeList.OrderBy(m => Convert.ToInt32(m.liquid_range_id));
ObservableCollection liquidList = new ObservableCollection();
Liquid liquid = new Liquid();
liquid.liquid_name = Properties.Resources.strPleaseSelect;
liquidList.Add(liquid);
cbLiquid.ItemsSource = liquidList;
List list = new List();
List lattices = DataModule.getInstance().GetLattices();
TabletopTemplate tabletopTemplate = TabletopTemplateDB.GetCurrentAppTabletopTemplateCollectionFromdb(); //增加台面模板判断
if (tabletopTemplate == null)
{
for (int i = 0; i < Shared.SoftwareInformation.columns; i++)
{
for (int j = 0; j < Shared.SoftwareInformation.rows; j++)
{
int tmp = i * Shared.SoftwareInformation.rows + j;
Lattice latt = lattices[tmp];
if (latt.is_trash == 1)
continue;
list.Add(latt.lattice_num);
}
}
}
else
{
foreach (Lattice lattice in lattices)
{
if (lattice.is_trash == 1)
continue;
list.Add(lattice.lattice_num);
}
}
//list.Insert(0, Properties.Resources.strPleaseSelect);
comboboxTablePos.ItemsSource = list;
comboboxTablePos.SelectedIndex = 0;
gdLiquidFollow.RowDefinitions[1].Height = new GridLength(0);
gdLiquidFollow.RowDefinitions[2].Height = new GridLength(0);
gdLiquidFollow.RowDefinitions[3].Height = new GridLength(0);
gdLiquidFollow.RowDefinitions[4].Height = new GridLength(0);
if (Shared.ChannelCount.Equals(96))
{
tbxWellPositionTips.IsEnabled = false;
wellPlate.IsEnabled = false;
}
List mixPositionList = new List();
mixPositionList.Add(MixPositionEnum.Liquid.ToString());
mixPositionList.Add(MixPositionEnum.Top.ToString());
mixPositionList.Add(MixPositionEnum.Bottom.ToString());
cbMixAspiratePosition.ItemsSource = mixPositionList;
cbMixDispensePosition.ItemsSource = mixPositionList;
ObservableCollection listProcess = DataModule.getInstance().GetUndetectProcessList();
cbxLiquidSensorDisId.ItemsSource = listProcess;
cbxLiquidSensorBlockDisId.ItemsSource = listProcess;
ObservableCollection listLiquidFollowType = DataModule.getInstance().GetLiquidFollowTypeList();
cbxLiquidFollowType.ItemsSource = listLiquidFollowType;
methodMix = new MethodMixing();
methodMix.name = method.method_name;
methodMix.label = method.method_name;
methodMix.status = (method.isEnabled == true ? "enable" : "disable");
methodMix.strIndex = method.strIndex;
tbxCommandName.Text = method.method_name;
methodMix.wellarray = "";
if (Shared.ChannelCount > 1)
{
tipsChannel.CanEdit = true;
if (Shared.ChannelCount.Equals(96))
{
tipsChannel.Visibility = Visibility.Collapsed;
}
}
this.method = method;
if (method.tag != null)
{
methodMix = (MethodMixing)method.tag;
currmethodMixing = methodMix;
isrun = methodMix.isrun;
status = methodMix.status;
name = methodMix.name;
label = methodMix.label;
labwareText = methodMix.labwareText;
labwareValue = methodMix.labwareValue;
positionText = methodMix.positionText;
positionValue = methodMix.positionValue;
armText = methodMix.armText;
armValue = methodMix.armValue;
channels = methodMix.channels;
wellarray = methodMix.wellarray;
enableSingleWellvolume = methodMix.enableSingleWellvolume;
singlewellvolume = methodMix.singlewellvolume;
liquididText = methodMix.liquididText;
liquididValue = methodMix.liquididValue;
liquidrangeidText = methodMix.liquidrangeidText;
liquidrangeidValue = methodMix.liquidrangeidValue;
liquidpidText = methodMix.liquidpidText;
liquidpidValue = methodMix.liquidpidValue;
mixvolume = methodMix.mixvolume;
mixcount = methodMix.mixcount;
mixAspiratePositionText = methodMix.mixAspiratePositionText;
mixAspiratePositionValue = methodMix.mixAspiratePositionValue;
mixAspirateDistance = methodMix.mixAspirateDistance;
mixAspirateSpeed = methodMix.mixAspirateSpeed;
mixDispensePositionText = methodMix.mixDispensePositionText;
mixDispensePositionValue = methodMix.mixDispensePositionValue;
mixDispenseDistance = methodMix.mixDispenseDistance;
mixDispenseSpeed = methodMix.mixDispenseSpeed;
enableLiquidSensor = methodMix.enableLiquidSensor;
liquidSensorCount = methodMix.liquidSensorCount;
liquidSensorDistance = methodMix.liquidSensorDistance;
liquidSensorEndDistance = methodMix.liquidSensorEndDistance;
liquidSensorSpeed = methodMix.liquidSensorSpeed;
liquidSensorRadio = methodMix.liquidSensorRadio;
liquidSensorDisIdText = methodMix.liquidSensorDisIdText;
liquidSensorDisIdValue = methodMix.liquidSensorDisIdValue;
enableLiquidFollow = methodMix.enableLiquidFollow;
liquidFollowType = methodMix.liquidFollowType;
liquidFollowTypeName = methodMix.liquidFollowTypeName;
liquidFollowSpeed = methodMix.liquidFollowSpeed;
liquidFollowDistance = methodMix.liquidFollowDistance;
liquidFollowArea = methodMix.liquidFollowArea;
enableSensorBlock = methodMix.enableSensorBlock;
liquidSensorBlockDistance = methodMix.liquidSensorBlockDistance;
liquidSensorBlockDisIdText = methodMix.liquidSensorBlockDisIdText;
liquidSensorBlockDisIdValue = methodMix.liquidSensorBlockDisIdValue;
}
this.DataContext = methodMix;
LiquidManagement.loadLiquidsEvent += BindLiquids;
}
public void UserControl_Loaded(object sender, RoutedEventArgs e)
{
mark += 1;
try
{
if (mark > 1)
{
return;
}
if (currmethodMixing != null)
{
if (!string.IsNullOrEmpty(armText))
{
tbxCommandName.Text = name;
cbArm.SelectedValue = armValue;
DeviceArm arm = cbArm.SelectedItem as DeviceArm;
tbxHeadType.Text = arm.head_type.ToString();
comboboxTablePos.SelectedItem = positionText;
if (Shared.ChannelCount.Equals(96))
{
}
else
{
tipsChannel.SelectedChannels = channels.ToList();
tipsChannel.SetSelectedChannels();
tipsChannel_SelectedChangedEvent(null, null);
}
//根据板位上的耗材类型,显示耗材孔位示意图
Labware labwareA = DataRWDAL.LabwareDB.GetLabware(methodMix.labwareValue);
wellPlate.Rows = labwareA.number_row;
wellPlate.Columns = labwareA.number_column;
if (labwareA.labware_type_id.Equals("4"))
{
labwareA.labwareWellInfoList = DataRWDAL.LabwareDB.GetSpecialLabwareWellInfo(labwareA.labware_id);
wellPlate.labwareWellInfoList = labwareA.labwareWellInfoList;
wellPlate.LabwareRealWidth = labwareA.labware_length;
wellPlate.LabwareRealLength = labwareA.labware_width;
}
tbxWellPositionTips.Text = wellarray;
wellPlate.Selection = wellarray;
//wellPlate.SetSelection(wellarray);
//tbxWellvolume.Text = wellvolume.ToString();
if (enableSingleWellvolume)
{
cbSingleVolumn.IsChecked = true;
}
else
{
cbSingleVolumn.IsChecked = false;
}
cbLiquidType.SelectedValue = liquididValue;
cbLiquidRange.SelectedValue = liquidrangeidValue;
cbLiquid.SelectedValue = liquidpidValue;
tbxMixVolume.Text = mixvolume.ToString();
tbxMixCount.Text = mixcount.ToString();
cbMixAspiratePosition.SelectedIndex = mixAspiratePositionValue;
tbxMixAspirateDistance.Text = mixAspirateDistance.ToString();
tbxMixAspirateSpeed.Text = mixAspirateSpeed.ToString();
cbMixDispensePosition.SelectedIndex = mixDispensePositionValue;
tbxMixDispenseDistance.Text = mixDispenseDistance.ToString();
tbxMixDispenseSpeed.Text = mixDispenseSpeed.ToString();
if (enableLiquidSensor)
{
checkboxLiquidDetect.IsChecked = true;
gdLiquidSensor.IsEnabled = true;
txtNameLiquidSensorCount.Text = liquidSensorCount.ToString();
txtLiquidSensorDistance.Text = liquidSensorDistance.ToString();
txtLiquidSensorEndDistance.Text = liquidSensorEndDistance.ToString();
txtLiquidSensorSpeed.Text = liquidSensorSpeed.ToString();
txtLiquidSensorRadio.Text = liquidSensorRadio.ToString();
cbxLiquidSensorDisId.SelectedIndex = Convert.ToInt32(liquidSensorDisIdValue);
if (enableLiquidFollow)
{
checkboxLiquidFollow.IsChecked = true;
cbxLiquidFollowType.SelectedIndex = liquidFollowType;
txtLiquidFollowSpeed.Text = liquidFollowSpeed.ToString();
txtLiquidFollowDistance.Text = liquidFollowDistance.ToString();
if (liquidFollowType == 1)
{
bdrFollowOneType.Visibility = Visibility.Visible;
tbkFollowTwoTypeLabel.Visibility = Visibility.Collapsed;
txtLiquidFollowArea.Visibility = Visibility.Collapsed;
tbkFollowTwoTypeUnit.Visibility = Visibility.Collapsed;
if (methodMix != null)
{
methodMix.liquidFollowType = cbxLiquidFollowType.SelectedIndex;
methodMix.liquidFollowTypeName = cbxLiquidFollowType.Text;
}
}
else if (liquidFollowType == 2)
{
bdrFollowOneType.Visibility = Visibility.Collapsed;
tbkFollowTwoTypeLabel.Visibility = Visibility.Visible;
txtLiquidFollowArea.Visibility = Visibility.Visible;
tbkFollowTwoTypeUnit.Visibility = Visibility.Visible;
if (methodMix != null)
{
methodMix.liquidFollowType = cbxLiquidFollowType.SelectedIndex;
methodMix.liquidFollowTypeName = cbxLiquidFollowType.Text;
}
txtLiquidFollowArea.Text = liquidFollowArea.ToString();
}
}
else
{
checkboxLiquidFollow.IsChecked = false;
cbxLiquidFollowType.SelectedIndex = liquidFollowType;
txtLiquidFollowSpeed.Text = liquidFollowSpeed.ToString();
txtLiquidFollowDistance.Text = liquidFollowDistance.ToString();
txtLiquidFollowArea.Text = liquidFollowArea.ToString();
//gdLiquidFollow.IsEnabled = false;
}
}
else
{
checkboxLiquidDetect.IsChecked = false;
gdLiquidSensor.IsEnabled = false;
checkboxLiquidFollow.IsEnabled = false;
cbxLiquidSensorDisId.SelectedIndex = 0;
cbxLiquidSensorBlockDisId.SelectedIndex = 0;
//gdLiquidFollow.IsEnabled = false;
cbxLiquidFollowType.SelectedIndex = liquidFollowType;
txtLiquidFollowSpeed.Text = liquidFollowSpeed.ToString();
txtLiquidFollowDistance.Text = liquidFollowDistance.ToString();
txtLiquidFollowArea.Text = liquidFollowArea.ToString();
}
if (enableSensorBlock)
{
checkboxBlockDetect.IsChecked = true;
tbxLiquidSensorBlockDistance.Text = liquidSensorBlockDistance.ToString();
cbxLiquidSensorBlockDisId.SelectedIndex = Convert.ToInt32(liquidSensorBlockDisIdValue);
}
else
{
checkboxBlockDetect.IsChecked = false;
gdBlockSensor.IsEnabled = false;
}
if (currmethodMixing != null)
{
methodMix = currmethodMixing;
}
}
}
else
{
cbArm.SelectedIndex = curArmSelectedIndex;
if (cbArm.Items.Count > 1)
{
cbArm.SelectedIndex = 1;
}
DeviceArm arm = cbArm.SelectedItem as DeviceArm;
cbLiquidType.SelectedIndex = curLiquidTypeSelectedIndex;
//cbLiquidRange.SelectedIndex = curLiquidRangeSelectedIndex;
cbMixAspiratePosition.SelectedIndex = curMixAspirateSelectIndex;
cbMixDispensePosition.SelectedIndex = curMixDispenseSelectIndex;
tbxHeadType.Text = arm.head_type.ToString();
//methodDispense = currmethodDispense;
if (currmethodMixing != null)
{
methodMix = currmethodMixing;
}
cbxLiquidSensorDisId.SelectedIndex = 0;
cbxLiquidSensorBlockDisId.SelectedIndex = 0;
}
ReceiveAndUpdate();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
//cbArm.SelectedIndex = curArmSelectedIndex;
//cbLiquidType.SelectedIndex = curLiquidTypeSelectedIndex;
//cbMixAspiratePosition.SelectedIndex = curMixAspirateSelectIndex;
//cbMixDispensePosition.SelectedIndex = curMixDispenseSelectIndex;
}
private void btnSingleVolumnSetting_Click(object sender, RoutedEventArgs e)
{
if (EventResponseController.Instance.CanExecute() == false)
return;
Window wnd = Application.Current.MainWindow;
Grid grid = Utilities.FindVisualChild(wnd);
VolumnSettingPerWell vspw = new VolumnSettingPerWell();
vspw.closeEvent += Vspw_closeEvent;
grid.Children.Add(vspw);
}
private void Vspw_closeEvent(object sender, EventArgs e)
{
Window wnd = Application.Current.MainWindow;
Grid grid = Utilities.FindVisualChild(wnd);
UIElement element = sender as UIElement;
grid.Children.Remove(element);
}
public void SetTableName(string tableName, Labware lb)
{
if (lb == null)
return;
if (string.IsNullOrEmpty(lb.labware_id))
return;
if (string.IsNullOrEmpty(methodMix.armValue))
{
MessageBox.Show(Properties.Resources.msgPlsSelectArm, "Tips");
return;
}
selectedLabware = lb;
wellPlate.Rows = lb.number_row;
wellPlate.Columns = lb.number_column;
wellPlate.labwareWellInfoList = lb.labwareWellInfoList;
wellPlate.LabwareRealWidth = lb.labware_length;
wellPlate.LabwareRealLength = lb.labware_width;
wellPlate.DataContext = lb;
List latticeList = DataRWDAL.LatticeDB.GetLatticeDataFromdb(Shared.SoftwareInformation.software_device_number, Convert.ToInt32(methodMix.armValue));
Lattice lattice = latticeList.Find(s => s.lattice_num == tableName);
if (lattice == null)
{
LoggerHelper.InfoLog("Error: Can't find lattice with lattice_num=" + tableName);
return;
}
comboboxTablePos.SelectedItem = tableName;
if (Shared.ChannelCount.Equals(96))
{
if (!lb.number_row.Equals(8) || !lb.number_column.Equals(12))
{
ShowTip.ShowNotice("请选择96孔板的台面", InfoType.Warning);
tbxWellPositionTips.Text = "";
wellPlate.Selection = "";
return;
}
}
if (lb.labware_tubeshelf_type.Equals(1))//异形管架耗材
{
tbxWellPositionTips.Text = "";
wellPlate.Selection = "";
}
if (methodMix != null)
{
methodMix.positionText = tableName;
methodMix.positionValue = lattice.lattice_id;
methodMix.labwareText = lb.labware_name;
methodMix.labwareValue = lb.labware_id;
if (Shared.ChannelCount.Equals(96))
{
wellarray = "A1,B1,C1,D1,E1,F1,G1,H1,A2,B2,C2,D2,E2,F2,G2,H2,A3,B3,C3,D3,E3,F3,G3,H3,A4,B4,C4,D4,E4,F4,G4,H4,A5,B5,C5,D5,E5,F5,G5,H5,A6,B6,C6,D6,E6,F6,G6,H6,A7,B7,C7,D7,E7,F7,G7,H7,A8,B8,C8,D8,E8,F8,G8,H8,A9,B9,C9,D9,E9,F9,G9,H9,A10,B10,C10,D10,E10,F10,G10,H10,A11,B11,C11,D11,E11,F11,G11,H11,A12,B12,C12,D12,E12,F12,G12,H12";
tbxWellPositionTips.Text = wellarray;
wellPlate.Selection = wellarray;
}
}
}
private void WellPlate_SelectedEvent(object sender, CustomRoutedEventArgs e)
{
string str = (string)e.param;
if (methodMix != null)
{
methodMix.wellarray = str;
}
}
private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
DeviceArm arm = cbArm.SelectedItem as DeviceArm;
methodMix.armText = arm.device_arm_name;
methodMix.armValue = arm.device_arm_id.ToString();
methodMix.headType = arm.head_type;
tbxHeadType.Text = arm.head_type.ToString();
if (arm.arm_type.Equals(0))
{
grid.RowDefinitions[3].Height = new GridLength(0);
grid.RowDefinitions[4].Height = new GridLength(0);
return;
}
else
{
grid.RowDefinitions[3].Height = new GridLength(40);
grid.RowDefinitions[4].Height = new GridLength(80);
}
if (Shared.ChannelCount.Equals(96))
{
curArmSelectedIndex = cbArm.SelectedIndex;
methodMix.channels = new int[] {1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,
49,50,51,52,53,54,55,56,
57,58,59,60,61,62,63,64,
65,66,67,68,69,70,71,72,
73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,
89,90,91,92,93,94,95,96};
}
else
{
// 臂未选择
if (cbArm.SelectedIndex < 0 || cbArm.SelectedIndex == 0)
{
tipsChannel.SetTotalChannelCount(0);
tipsChannel.SelectedChannels = new List();
tipsChannel.SetSelectedChannels();
tipsChannel_SelectedChangedEvent(null, null);
return;
}
curArmSelectedIndex = cbArm.SelectedIndex;
string armName = ((DeviceArm)cbArm.SelectedItem).device_arm_name.ToString();
tipsChannel.SelectedChannels = Shared.ChannelsId.ToList();
tipsChannel.SetTotalChannelCount(Shared.ChannelCount);
tipsChannel.SetSelectedChannels();
tipsChannel_SelectedChangedEvent(null, null);
}
ReceiveAndUpdate();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
private void cbLiquidType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbLiquidType.SelectedIndex < 0)
return;
if (cbLiquidType.SelectedIndex == 0)
{
cbLiquidRange.SelectedIndex = 0;
cbLiquid.SelectedIndex = 0;
}
curLiquidTypeSelectedIndex = cbLiquidType.SelectedIndex;
if (cbLiquidType.SelectedIndex != 0)
{
if (methodMix != null)
{
methodMix.liquididText = ((LiquidType)cbLiquidType.SelectedItem).liquid_type_name.ToString();
methodMix.liquididValue = ((LiquidType)cbLiquidType.SelectedItem).liquid_type_id.ToString();
}
}
}
private void cbLiquidRange_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbLiquidRange.SelectedIndex < 0)
return;
curLiquidRangeSelectedIndex = cbLiquidRange.SelectedIndex;
string typeID = cbLiquidType.SelectedValue as string;
string rangeID = cbLiquidRange.SelectedValue as string;
string armID = cbArm.SelectedValue.ToString();
ObservableCollection liquidList = LiquidTypeRSRangeDB.GetLiquidFromdbByTypeAndRange(typeID, rangeID, armID);
Liquid liquid = new Liquid();
liquid.liquid_name = Properties.Resources.strPleaseSelect;
liquidList.Insert(0, liquid);
if (cbLiquidRange.SelectedIndex != 0)
{
if (methodMix != null)
{
methodMix.liquidrangeidText = ((LiquidRange)cbLiquidRange.SelectedItem).liquid_range_name.ToString();
methodMix.liquidrangeidValue = ((LiquidRange)cbLiquidRange.SelectedItem).liquid_range_id.ToString();
}
}
cbLiquid.ItemsSource = liquidList;
cbLiquid.SelectedIndex = 0;
}
private void cbLiquid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbLiquid.SelectedIndex < 1)
return;
curLiquidSelectedIndex = cbLiquid.SelectedIndex;
Liquid liquid = cbLiquid.SelectedItem as Liquid;
//methodMix.liquididText = liquid.liquid_name;
//methodMix.liquididValue = liquid.liquid_id;
if (cbLiquid.SelectedIndex != 0)
{
if (methodMix != null)
{
methodMix.liquidpidText = liquid.liquid_name;
methodMix.liquidpidValue = liquid.liquid_id;
}
}
}
private void cbMixAspiratePosition_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbMixAspiratePosition.SelectedIndex < 0)
return;
curMixAspirateSelectIndex = cbMixAspiratePosition.SelectedIndex;
MixPositionEnum position = (MixPositionEnum)Enum.Parse(typeof(MixPositionEnum), (string)cbMixAspiratePosition.SelectedItem);
if (methodMix != null)
{
methodMix.mixAspiratePositionText = position.ToString();
if ((int)position == 0)
{
methodMix.mixAspiratePositionText = "Liquid";
}
else if ((int)position == 1)
{
methodMix.mixAspiratePositionText = "Top";
}
else if ((int)position == 2)
{
methodMix.mixAspiratePositionText = "Bottom";
}
methodMix.mixAspiratePositionValue = (int)position;
}
}
private void cbMixDispensePosition_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cbMixDispensePosition.SelectedIndex < 0)
return;
curMixDispenseSelectIndex = cbMixDispensePosition.SelectedIndex;
MixPositionEnum position = (MixPositionEnum)Enum.Parse(typeof(MixPositionEnum), (string)cbMixDispensePosition.SelectedItem);
if (methodMix != null)
{
methodMix.mixDispensePositionValue = (int)position;
if ((int)position == 0)
{
methodMix.mixDispensePositionText = "Liquid";
}
else if ((int)position == 1)
{
methodMix.mixDispensePositionText = "Top";
}
else if ((int)position == 2)
{
methodMix.mixDispensePositionText = "Bottom";
}
}
}
private void comboboxTablePos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (comboboxTablePos.SelectedItem == null)
return;
string name = comboboxTablePos.SelectedItem as string;
SetTableName(name, selectedLabware);
#region 验证台面耗材类型
if (TestDesign.SelectLabwares.Count() <= 0 || TestDesign.SelectLabwares.FirstOrDefault(m => m.Label.Equals(comboboxTablePos.SelectedValue.ToString())) == null)
return;
ControlLabware labware = TestDesign.SelectLabwares.FirstOrDefault(m => m.Label.Equals(comboboxTablePos.SelectedValue.ToString()));
if ("1,3,5,4".Contains(labware.LabwareType.ToString()))
{
cmbTablePos.Text = "";
}
else
{
cmbTablePos.Text = $"不能在耗材 [{labware.LabwareName}] 执行混匀";
}
#endregion
if (this.method != null)
{
this.method.method_Tipcontent = string.Format("{0};{1}", methodMix.positionText, methodMix.mixcount);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
private void txtNameLiquidSensorCount_TextChanged(object sender, TextChangedEventArgs e)
{
if (!Consumables.ConsumablesValidationRule.IsPositiveIntegerr(txtNameLiquidSensorCount.Text, out string message))
{
lscError.Text = message;
return;
}
else
{
lscError.Text = "";
}
}
private void txtLiquidSensorDistance_TextChanged(object sender, TextChangedEventArgs e)
{
if (!Consumables.ConsumablesValidationRule.IsRange(txtLiquidSensorDistance.Text, 0.0, 100, false, out string message))
{
lsdError.Text = message;
return;
}
else
{
lsdError.Text = "";
}
}
private void tbxLiquidSensorBlockDistance_TextChanged(object sender, TextChangedEventArgs e)
{
if (!Consumables.ConsumablesValidationRule.IsRange(tbxLiquidSensorBlockDistance.Text, 0.0, 100, false, out string message))
{
lsbdError.Text = message;
return;
}
else
{
lsbdError.Text = "";
}
}
///
/// 刷新液体下拉
///
/// 需要删除的液体ID
/// 是否删除
private void BindLiquids(string liquid_id, bool IsDelete)
{
if (IsDelete)
{
//记录所选值
string id = cbLiquid.SelectedValue.ToString();
int index = cbLiquid.SelectedIndex;
//刷新下拉数据
cbLiquidRange_SelectionChanged(null, null);
//删除的液体是所需液体
if (id.Equals(liquid_id))
//重置为请选择
cbLiquid.SelectedIndex = 0;
else
//保持之前选择
cbLiquid.SelectedIndex = index;
}
else
{
//记录所选值
int index = cbLiquid.SelectedIndex;
//刷新下拉数据
cbLiquidRange_SelectionChanged(null, null);
//保持之前选择
cbLiquid.SelectedIndex = index;
}
}
#region 可用通道鼠标选择变更事件
///
/// 可用通道鼠标选择变更事件
///
///
///
private void tipsChannel_SelectedChangedEvent(object sender, EventArgs e)
{
if (Shared.ChannelCount.Equals(96))
{
methodMix.channels = new int[] {1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,
49,50,51,52,53,54,55,56,
57,58,59,60,61,62,63,64,
65,66,67,68,69,70,71,72,
73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,
89,90,91,92,93,94,95,96};
}
else
{
methodMix.channels = tipsChannel.SelectedChannels.ToArray();
}
}
#endregion
private void checkboxLiquidFollow_Click(object sender, RoutedEventArgs e)
{
try
{
if (checkboxLiquidDetect.IsChecked == false)
{
checkboxLiquidFollow.IsChecked = false;
return;
}
if (checkboxLiquidFollow.IsChecked == true)
{
cbxLiquidFollowType.SelectedIndex = 1;
if (methodMix != null)
{
methodMix.enableLiquidFollow = true;
methodMix.liquidFollowType = Convert.ToInt32(cbxLiquidFollowType.SelectedIndex);
methodMix.liquidFollowTypeName = cbxLiquidFollowType.Text;
methodMix.liquidFollowSpeed = Convert.ToDouble(txtLiquidFollowSpeed.Text);
methodMix.liquidFollowDistance = Convert.ToDouble(txtLiquidFollowDistance.Text);
methodMix.liquidFollowArea = Convert.ToDouble(txtLiquidFollowArea.Text);
methodMix.liquidSensorDisIdText = cbxLiquidSensorDisId.Text;
methodMix.liquidSensorDisIdValue = Convert.ToDouble(cbxLiquidSensorDisId.SelectedIndex);
//gdLiquidFollow.IsEnabled = true;
}
}
else
{
cbxLiquidFollowType.SelectedIndex = 1;
if (methodMix != null)
{
methodMix.enableLiquidFollow = false;
methodMix.liquidFollowType = Convert.ToInt32(cbxLiquidFollowType.SelectedIndex);
methodMix.liquidFollowTypeName = cbxLiquidFollowType.Text;
methodMix.liquidFollowSpeed = Convert.ToDouble(txtLiquidFollowSpeed.Text);
methodMix.liquidFollowDistance = Convert.ToDouble(txtLiquidFollowDistance.Text);
methodMix.liquidFollowArea = Convert.ToDouble(txtLiquidFollowArea.Text);
methodMix.liquidSensorDisIdText = cbxLiquidSensorDisId.Text;
methodMix.liquidSensorDisIdValue = Convert.ToDouble(cbxLiquidSensorDisId.SelectedIndex);
//gdLiquidFollow.IsEnabled = false;
}
}
}
catch (Exception ex)
{
}
}
private void txtLiquidSensorEndDistance_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidSensorEndDistance = Convert.ToDouble(txtLiquidSensorEndDistance.Text);
if (string.IsNullOrEmpty(txtLiquidSensorEndDistance.Text))
{
txtLiquidSensorEndDistance.BorderBrush = Brushes.Red;
txtLiquidSensorEndDistance.BorderThickness = new Thickness(1);
tbkErrorLiquidSensorEndDistance.Text = "[0,50]";
tbkErrorLiquidSensorEndDistance.Foreground = Brushes.Red;
tbkErrorLiquidSensorEndDistance.Visibility = Visibility.Visible;
return;
}
else if (Convert.ToDouble(txtLiquidSensorEndDistance.Text) < 0 || Convert.ToDouble(txtLiquidSensorEndDistance.Text) > 50)
{
txtLiquidSensorEndDistance.BorderBrush = Brushes.Red;
txtLiquidSensorEndDistance.BorderThickness = new Thickness(1);
tbkErrorLiquidSensorEndDistance.Text = "[0,50]";
tbkErrorLiquidSensorEndDistance.Foreground = Brushes.Red;
tbkErrorLiquidSensorEndDistance.Visibility = Visibility.Visible;
return;
}
else
{
txtLiquidSensorEndDistance.BorderBrush = Brushes.Transparent;
txtLiquidSensorEndDistance.BorderThickness = new Thickness(0);
tbkErrorLiquidSensorEndDistance.Foreground = Brushes.Red;
tbkErrorLiquidSensorEndDistance.Visibility = Visibility.Hidden;
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
txtLiquidSensorEndDistance.BorderBrush = Brushes.Red;
txtLiquidSensorEndDistance.BorderThickness = new Thickness(1);
return;
}
}
private void txtLiquidSensorSpeed_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidSensorSpeed = Convert.ToDouble(txtLiquidSensorSpeed.Text);
validationMixDispenseSpeed(txtLiquidSensorSpeed, tbkErrorLiquidSensorSpeed);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
txtLiquidSensorSpeed.BorderBrush = Brushes.Red;
tbkErrorLiquidSensorSpeed.Text = "[1,100]";
tbkErrorLiquidSensorSpeed.Foreground = Brushes.Red;
tbkErrorLiquidSensorSpeed.Visibility = Visibility.Visible;
return;
}
}
private void txtLiquidSensorRadio_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidSensorRadio = Convert.ToDouble(txtLiquidSensorRadio.Text);
if (string.IsNullOrEmpty(txtLiquidSensorRadio.Text))
{
txtLiquidSensorRadio.BorderBrush = Brushes.Red;
txtLiquidSensorRadio.BorderThickness = new Thickness(1);
tbkErrorLiquidSensorRadio.Text = "[0,100]";
tbkErrorLiquidSensorRadio.Foreground = Brushes.Red;
tbkErrorLiquidSensorRadio.Visibility = Visibility.Visible;
return;
}
else if (Convert.ToDouble(txtLiquidSensorRadio.Text) < 0 || Convert.ToDouble(txtLiquidSensorRadio.Text) > 100)
{
txtLiquidSensorRadio.BorderBrush = Brushes.Red;
txtLiquidSensorRadio.BorderThickness = new Thickness(1);
tbkErrorLiquidSensorRadio.Text = "[0,100]";
tbkErrorLiquidSensorRadio.Foreground = Brushes.Red;
tbkErrorLiquidSensorRadio.Visibility = Visibility.Visible;
return;
}
else
{
txtLiquidSensorRadio.BorderBrush = Brushes.Transparent;
txtLiquidSensorRadio.BorderThickness = new Thickness(0);
tbkErrorLiquidSensorRadio.Foreground = Brushes.Red;
tbkErrorLiquidSensorRadio.Visibility = Visibility.Hidden;
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
txtLiquidSensorRadio.BorderBrush = Brushes.Red;
txtLiquidSensorRadio.BorderThickness = new Thickness(1);
return;
}
}
private void cbxLiquidFollowType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (cbxLiquidFollowType.SelectedIndex == 1)
{
bdrFollowOneType.Visibility = Visibility.Visible;
tbkFollowTwoTypeLabel.Visibility = Visibility.Collapsed;
txtLiquidFollowArea.Visibility = Visibility.Collapsed;
tbkFollowTwoTypeUnit.Visibility = Visibility.Collapsed;
if (methodMix != null)
{
methodMix.liquidFollowType = cbxLiquidFollowType.SelectedIndex;
methodMix.liquidFollowTypeName = ((string)cbxLiquidFollowType.SelectedItem).ToString();
}
}
else if (cbxLiquidFollowType.SelectedIndex == 2)
{
bdrFollowOneType.Visibility = Visibility.Collapsed;
tbkFollowTwoTypeLabel.Visibility = Visibility.Visible;
txtLiquidFollowArea.Visibility = Visibility.Visible;
tbkFollowTwoTypeUnit.Visibility = Visibility.Visible;
if (methodMix != null)
{
methodMix.liquidFollowType = cbxLiquidFollowType.SelectedIndex;
methodMix.liquidFollowTypeName = ((string)cbxLiquidFollowType.SelectedItem).ToString();
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
private void txtLiquidFollowDistance_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidFollowDistance = Convert.ToDouble(txtLiquidFollowDistance.Text);
//if(methodMix.mixAspiratePositionText.Equals("Top"))
//{
if (string.IsNullOrEmpty(txtLiquidFollowDistance.Text))
{
txtLiquidFollowDistance.BorderBrush = Brushes.Red;
txtLiquidFollowDistance.BorderThickness = new Thickness(1);
tbkErrorLiquidFollowDistance.Text = "[0,50]";
tbkErrorLiquidFollowDistance.Foreground = Brushes.Red;
tbkErrorLiquidFollowDistance.Visibility = Visibility.Visible;
return;
}
else if (Convert.ToDouble(txtLiquidFollowDistance.Text) < 0 || Convert.ToDouble(txtLiquidFollowDistance.Text) > 50)
{
txtLiquidFollowDistance.BorderBrush = Brushes.Red;
txtLiquidFollowDistance.BorderThickness = new Thickness(1);
tbkErrorLiquidFollowDistance.Text = "[0,50]";
tbkErrorLiquidFollowDistance.Foreground = Brushes.Red;
tbkErrorLiquidFollowDistance.Visibility = Visibility.Visible;
return;
}
else
{
txtLiquidFollowDistance.BorderBrush = Brushes.Transparent;
txtLiquidFollowDistance.BorderThickness = new Thickness(0);
tbkErrorLiquidFollowDistance.Foreground = Brushes.Red;
tbkErrorLiquidFollowDistance.Visibility = Visibility.Hidden;
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
txtLiquidFollowDistance.BorderBrush = Brushes.Red;
txtLiquidFollowDistance.BorderThickness = new Thickness(1);
return;
}
}
private void txtLiquidFollowSpeed_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidFollowSpeed = Convert.ToDouble(txtLiquidFollowSpeed.Text);
validationMixDispenseSpeed(txtLiquidFollowSpeed, tbkErrorLiquidFollowSpeed);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
txtLiquidFollowSpeed.BorderBrush = Brushes.Red;
tbkErrorLiquidFollowSpeed.Text = "[1,100]";
tbkErrorLiquidFollowSpeed.Foreground = Brushes.Red;
tbkErrorLiquidFollowSpeed.Visibility = Visibility.Visible;
return;
}
}
public void validationMixDispenseSpeed(TextBox textBoxObj, TextBlock textBlockObj)
{
string volumeString = textBoxObj.Text;
Regex rg = new Regex(@"^[1-9]\\d*.\\d*|0\\.\\d*[1-9]\\d*$");
if (string.IsNullOrEmpty(volumeString))
{
textBoxObj.BorderBrush = Brushes.Red;
textBlockObj.Text = "[1,100]";
textBlockObj.Foreground = Brushes.Red;
textBlockObj.Visibility = Visibility.Visible;
return;
}
else if (rg.IsMatch(volumeString))
{
textBoxObj.BorderBrush = Brushes.Red;
textBlockObj.Text = "[1,100]";
textBlockObj.Foreground = Brushes.Red;
textBlockObj.Visibility = Visibility.Visible;
return;
}
else if (Convert.ToDouble(volumeString) < 0 || Convert.ToDouble(volumeString) > 100)
{
textBoxObj.BorderBrush = Brushes.Red;
textBlockObj.Text = "[1,100]";
textBlockObj.Foreground = Brushes.Red;
textBlockObj.Visibility = Visibility.Visible;
return;
}
else
{
textBoxObj.BorderBrush = Brushes.Transparent;
textBlockObj.Foreground = Brushes.Transparent;
textBlockObj.Visibility = Visibility.Hidden;
}
}
private void txtLiquidFollowArea_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidFollowArea = Convert.ToDouble(txtLiquidSensorRadio.Text);
//if(methodMix.mixAspiratePositionText.Equals("Top"))
//{
if (string.IsNullOrEmpty(txtLiquidSensorRadio.Text))
{
txtLiquidSensorRadio.BorderBrush = Brushes.Red;
txtLiquidSensorRadio.BorderThickness = new Thickness(1);
tbkErrorLiquidFollowArea.Text = "[0,30000]";
tbkErrorLiquidFollowArea.Foreground = Brushes.Red;
tbkErrorLiquidFollowArea.Visibility = Visibility.Visible;
return;
}
else if (Convert.ToDouble(txtLiquidSensorRadio.Text) < 0 || Convert.ToDouble(txtLiquidSensorRadio.Text) > 30000)
{
txtLiquidSensorRadio.BorderBrush = Brushes.Red;
txtLiquidSensorRadio.BorderThickness = new Thickness(1);
tbkErrorLiquidFollowArea.Text = "[0,30000]";
tbkErrorLiquidFollowArea.Foreground = Brushes.Red;
tbkErrorLiquidFollowArea.Visibility = Visibility.Visible;
return;
}
else
{
txtLiquidSensorRadio.BorderBrush = Brushes.Transparent;
txtLiquidSensorRadio.BorderThickness = new Thickness(0);
tbkErrorLiquidFollowArea.Foreground = Brushes.Red;
tbkErrorLiquidFollowArea.Visibility = Visibility.Hidden;
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
txtLiquidSensorRadio.BorderBrush = Brushes.Red;
txtLiquidSensorRadio.BorderThickness = new Thickness(1);
return;
}
}
private void checkboxLiquidDetect_Click(object sender, RoutedEventArgs e)
{
try
{
if ((bool)checkboxLiquidDetect.IsChecked)
{
checkboxLiquidFollow.IsEnabled = true;
if (methodMix != null)
{
methodMix.enableLiquidSensor = true;
methodMix.liquidSensorCount = Convert.ToInt32(txtNameLiquidSensorCount.Text);
methodMix.liquidSensorDistance = Convert.ToDouble(txtLiquidSensorDistance.Text);
methodMix.liquidSensorEndDistance = Convert.ToDouble(txtLiquidSensorEndDistance.Text);
methodMix.liquidSensorSpeed = Convert.ToDouble(txtLiquidSensorSpeed.Text);
methodMix.liquidSensorRadio = Convert.ToDouble(txtLiquidSensorRadio.Text);
methodMix.liquidSensorDisIdText = cbxLiquidSensorDisId.Text;
methodMix.liquidSensorDisIdValue = Convert.ToDouble(cbxLiquidSensorDisId.SelectedIndex);
gdLiquidSensor.IsEnabled = true;
}
}
else
{
if (methodMix != null)
{
methodMix.enableLiquidSensor = false;
methodMix.liquidSensorCount = Convert.ToInt32(txtNameLiquidSensorCount.Text);
methodMix.liquidSensorDistance = Convert.ToDouble(txtLiquidSensorDistance.Text);
methodMix.liquidSensorEndDistance = Convert.ToDouble(txtLiquidSensorEndDistance.Text);
methodMix.liquidSensorSpeed = Convert.ToDouble(txtLiquidSensorSpeed.Text);
methodMix.liquidSensorRadio = Convert.ToDouble(txtLiquidSensorRadio.Text);
methodMix.liquidSensorDisIdText = cbxLiquidSensorDisId.Text;
methodMix.liquidSensorDisIdValue = Convert.ToDouble(cbxLiquidSensorDisId.SelectedIndex);
methodMix.enableLiquidFollow = false;
gdLiquidSensor.IsEnabled = false;
//gdLiquidFollow.IsEnabled = false;
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
private void cbxLiquidSensorDisId_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.liquidSensorDisIdText = ((string)cbxLiquidSensorDisId.SelectedItem).ToString();
methodMix.liquidSensorDisIdValue = Convert.ToDouble(cbxLiquidSensorDisId.SelectedIndex);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
private void tbxWellPositionTips_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.wellarray = tbxWellPositionTips.Text;
if (Shared.ChannelCount.Equals(96))
{
methodMix.channels = new int[] {1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,
49,50,51,52,53,54,55,56,
57,58,59,60,61,62,63,64,
65,66,67,68,69,70,71,72,
73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,
89,90,91,92,93,94,95,96};
}
else
{
methodMix.channels = tipsChannel.SelectedChannels.ToArray();
}
validationWellPosition();
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
tbxWellPositionTips.BorderBrush = Brushes.Red;
tbxWellPositionTips.BorderThickness = new Thickness(1);
wptError.Text = "请先选择孔位,例如:A1,B1";
wptError.Foreground = Brushes.Red;
wptError.Visibility = Visibility.Visible;
return;
}
}
public void validationWellPosition()
{
string wellString = tbxWellPositionTips.Text;
if (string.IsNullOrEmpty(wellString))
{
tbxWellPositionTips.BorderBrush = Brushes.Red;
tbxWellPositionTips.BorderThickness = new Thickness(1);
wptError.Text = "请先选择孔位";
wptError.Foreground = Brushes.Red;
wptError.Visibility = Visibility.Visible;
return;
}
else if (wellString.Contains("=") && !wellString.Substring(0, 1).Equals("="))
{
tbxWellPositionTips.BorderBrush = Brushes.Red;
tbxWellPositionTips.BorderThickness = new Thickness(1);
wptError.Text = "输入的孔位,包含“=”时,格式应为:=i,i为命令前设置的变量名称";
wptError.TextWrapping = TextWrapping.WrapWithOverflow;
wptError.Foreground = Brushes.Red;
wptError.Visibility = Visibility.Visible;
return;
}
else if (wellString.Contains("&") && !wellString.Substring(0, 1).Equals("&"))
{
tbxWellPositionTips.BorderBrush = Brushes.Red;
tbxWellPositionTips.BorderThickness = new Thickness(1);
wptError.Text = "输入的孔位,包含“&”时,格式应为:&i,i为命令前设置的变量名称";
wptError.TextWrapping = TextWrapping.WrapWithOverflow;
wptError.Foreground = Brushes.Red;
wptError.Visibility = Visibility.Visible;
return;
}
else if (wellString.Contains(";") || wellString.Contains("|") ||
wellString.Contains("*") || wellString.Contains("!") ||
wellString.Contains("@") || wellString.Contains("#") ||
wellString.Contains("$") || wellString.Contains("%") ||
wellString.Contains("^") || wellString.Contains("(") ||
wellString.Contains(")") || wellString.Contains("{") ||
wellString.Contains("}") || wellString.Contains("[") ||
wellString.Contains("]") || wellString.Contains("?") ||
wellString.Contains("/") || wellString.Contains("\\") ||
wellString.Contains("~") || wellString.Contains("`") ||
wellString.Contains(":") || wellString.Contains("\"") ||
wellString.Contains("'"))
{
tbxWellPositionTips.BorderBrush = Brushes.Red;
tbxWellPositionTips.BorderThickness = new Thickness(1);
wptError.Text = "输入的孔位,不能包含“;”、“|”、“*”、“!”、“@”、“#”、“$”、“%”、" +
"“^”、“(”、“)”、“{”、“}”、“[”、“]”、“?”、“/”、“\\”、“~”、" +
"“`”、“:”、“\"”、“'”";
wptError.TextWrapping = TextWrapping.WrapWithOverflow;
wptError.Foreground = Brushes.Red;
wptError.Visibility = Visibility.Visible;
return;
}
else
{
tbxWellPositionTips.BorderBrush = Brushes.Transparent;
tbxWellPositionTips.BorderThickness = new Thickness(0);
wptError.Foreground = Brushes.Transparent;
wptError.Visibility = Visibility.Hidden;
}
}
private void tbxMixCount_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (methodMix != null)
{
methodMix.mixcount = Convert.ToInt32(tbxMixCount.Text);
//validationWellVolume();
if (this.method != null)
{
this.method.method_Tipcontent = string.Format("{0};{1}", methodMix.positionText, methodMix.mixcount);
}
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
private void wellPlate_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
try
{
tbxWellPositionTips.Text = wellPlate.Selection;
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
}
}