using XCommon.Log; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using XCore; using XHandler.Class; using XHandler.Class.DataEx; using XHandler.Controls; using XImagingXhandler.XDAL; using DataEntity.Share; using DataRWDAL; using XHandler.View.Consumables; using HandyControl.Expression.Shapes; namespace XHandler.View.MethodProperty { /// /// LoadTipsProperty.xaml 的交互逻辑 /// public partial class LoadTipsProperty : UserControl, IMethodProperty,IConsumableObserver,IDeviceArmObserver { public MethodLoadTips methodLoadTips { get; set; } public MethodEx method = null; AspirateBll aspirateBll = new AspirateBll(); Labware selectedLabware = null; int curArmSelectedIndex = -1; int curTipsSelectedIndex = -1; string curName = string.Empty; private int[] channels = Shared.ChannelsId; int mark = 0; public LoadTipsProperty() { InitializeComponent(); } bool isConsumableUpdate = false; /// /// 耗材变更后,更新节点 /// /// 耗材管理对象 public void ReceiveAndUpdate(ConsumableManagement consumableManagement) { // 放在耗材上 isConsumableUpdate = true; ObservableCollection tipsList = LabwareDB.GetTipLabwareFromdb(); cbTipsType.ItemsSource = tipsList; cbTipsType.SelectedValue = methodLoadTips.labwaretipValue; } /// /// 通道设置变更后,更新节点 /// /// public void ReceiveAndUpdate() { try { // 获取当前设备臂信息 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)); if (deviceArm == null) { return; } 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 (methodLoadTips != null) { methodLoadTips.channels = iChannels; } } catch(Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } public LoadTipsProperty(MethodEx method) { InitializeComponent(); mark = 0; curArmSelectedIndex = 0; curTipsSelectedIndex = 0; List armList = DataModule.getInstance().GetDeviceArm(); cbArm.ItemsSource = armList; if (armList.Count == 2) //只有一个臂的情况下默认选中该臂 curArmSelectedIndex = 1; else curArmSelectedIndex = 0; ObservableCollection tipsList = LabwareDB.GetTipLabwareFromdb(); cbTipsType.ItemsSource = tipsList; if (Shared.ChannelCount > 1) { tipsChannel.CanEdit = true; } methodLoadTips = new MethodLoadTips(); methodLoadTips.isrun = "disable"; methodLoadTips.status = (method.isEnabled == true ? "enable" : "disable"); methodLoadTips.name = method.method_name; methodLoadTips.label = method.method_name; methodLoadTips.strIndex = method.strIndex; this.DataContext = methodLoadTips; this.method = method; if (method.tag != null) { methodLoadTips = (MethodLoadTips)method.tag; List ichs = methodLoadTips.channels.ToList(); tbxLabel.Text = methodLoadTips.label; tbxName.Text = methodLoadTips.name; //tipsChannel.SelectedChannels = methodLoadTips.channels.ToList(); //tipsChannel.SetSelectedChannels(); curName = tbxName.Text; channels = methodLoadTips.channels; } } public void SetTableName(string tableName, Labware lb) { methodLoadTips.positionText = tableName; selectedLabware = lb; } private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e) { DeviceArm arm = cbArm.SelectedItem as DeviceArm; methodLoadTips.armText = arm.device_arm_name; methodLoadTips.armValue = arm.device_arm_id.ToString(); methodLoadTips.headType = arm.head_type; tbxHeadType.Text = arm.head_type.ToString(); if (arm.arm_type.Equals(0)) { gdContent.RowDefinitions[3].Height = new GridLength(0); gdContent.RowDefinitions[4].Height = new GridLength(0); return; } else { gdContent.RowDefinitions[3].Height = new GridLength(40); gdContent.RowDefinitions[4].Height = new GridLength(80); } if (Shared.ChannelCount.Equals(96)) { methodLoadTips.channels = new int[] {1}; } 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; tipsChannel.SelectedChannels = Shared.ChannelsId.ToList(); tipsChannel.SetTotalChannelCount(Shared.ChannelCount); tipsChannel.SetSelectedChannels(); tipsChannel_SelectedChangedEvent(null, null); } ReceiveAndUpdate(); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { try { mark += 1; //cbArm.SelectedIndex = curArmSelectedIndex; //cbTipsType.SelectedIndex = curTipsSelectedIndex; if (mark > 1) { return; } if (!string.IsNullOrEmpty(methodLoadTips.armValue)) { cbArm.SelectedValue = methodLoadTips.armValue; DeviceArm arm = cbArm.SelectedItem as DeviceArm; tbxHeadType.Text = arm.head_type.ToString(); cbTipsType.SelectedValue = methodLoadTips.labwaretipValue; tipsChannel.SelectedChannels = channels.ToList(); tipsChannel.SetSelectedChannels(); tipsChannel_SelectedChangedEvent(null, null); if (!string.IsNullOrEmpty(curName)) { tbxName.Text = curName; } if (!string.IsNullOrEmpty(methodLoadTips.label)) { tbxLabel.Text = methodLoadTips.label; } } else { cbArm.SelectedIndex = curArmSelectedIndex; if (cbArm.Items.Count > 1) { cbArm.SelectedIndex = 1; } cbTipsType.SelectedIndex = curTipsSelectedIndex; tbxLabel.Text = methodLoadTips.label; } ReceiveAndUpdate(); } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } private void cbTipsType_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cbTipsType.SelectedIndex < 0) return; if (isConsumableUpdate) { isConsumableUpdate = false; return; } curTipsSelectedIndex = cbTipsType.SelectedIndex; Labware labware = cbTipsType.SelectedItem as Labware; methodLoadTips.labwaretipText = labware.labware_name; methodLoadTips.labwaretipValue = labware.labware_id.ToString(); if (this.method != null) { this.method.method_Tipcontent = string.Format("安装{0}", methodLoadTips.labwaretipText); } } private void tbxName_TextChanged(object sender, TextChangedEventArgs e) { try { methodLoadTips.name = tbxName.Text; methodLoadTips.label = tbxLabel.Text; } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } #region 可用通道鼠标选择变更事件 /// /// 可用通道鼠标选择变更事件 /// /// /// private void tipsChannel_SelectedChangedEvent(object sender, EventArgs e) { methodLoadTips.channels = tipsChannel.SelectedChannels.ToArray(); } #endregion } }