using DataEntity;
|
using NPOI.OpenXmlFormats.Vml;
|
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 XCommon.Log;
|
using XHandler.Class;
|
using XHandler.Class.DataEx;
|
using XHandler.Controls;
|
using XHandler.View.Com;
|
using XImagingXhandler.XDAL;
|
using DataRWDAL;
|
namespace XHandler.View.Consumables
|
{
|
/// <summary>
|
/// PlateSetting.xaml 的交互逻辑
|
/// </summary>
|
public partial class PlateSetting : UserControl
|
{
|
public ConsumableManagement consumableManagement = null;
|
public Labware labware { get; set; }
|
public ObservableCollection<Labware> CentrifugalLabwareList = LabwareDB.GetCentrifugalLabwareFromdb();//离心管耗材
|
|
public PlateSetting()
|
{
|
InitializeComponent();
|
InitializeData();
|
}
|
|
public PlateSetting(Labware l)
|
{
|
InitializeComponent();
|
|
labware = l;
|
InitializeData();
|
|
gdWellType.Visibility = Visibility.Collapsed;
|
|
//控制板架属性
|
if (labware.labware_type_id == "4")
|
{
|
gdWellType.Visibility = Visibility.Visible;
|
if (l.labware_tubeshelf_type.Equals(1))
|
{
|
checkBoxWellType.IsChecked= true;
|
gdPlateTubeInfo.Visibility = Visibility.Visible;
|
gdPlateBaseInfo.Visibility = Visibility.Collapsed;
|
}
|
else
|
{
|
checkBoxWellType.IsChecked = false;
|
gdPlateTubeInfo.Visibility = Visibility.Collapsed;
|
gdPlateBaseInfo.Visibility = Visibility.Visible;
|
}
|
labwareWellInfos = LabwareDB.GetSpecialLabwareWellInfo(labware.labware_id);
|
|
//CentrifugalLabwareList = LabwareDB.GetCentrifugalLabwareFromdb();
|
//foreach(LabwareWellInfo labwareWellInfo in labwareWellInfos)
|
//{
|
// if(labwareWellInfo.labware_well_shape.Equals(1))
|
// {
|
// labwareWellInfo.labware_well_shape = 0;
|
// }
|
// else if (labwareWellInfo.labware_well_shape.Equals(2))
|
// {
|
// labwareWellInfo.labware_well_shape = 1;
|
// }
|
//}
|
labware.labwareWellInfoList = labwareWellInfos;
|
dgPointListData.ItemsSource = labwareWellInfos;
|
dgPointListData.DataContext = labwareWellInfos;
|
cbxLabware.ItemsSource = CentrifugalLabwareList;
|
}
|
else
|
{
|
gdPlateTubeInfo.Visibility = Visibility.Collapsed;
|
gdPlateBaseInfo.Visibility = Visibility.Visible;
|
}
|
|
this.DataContext = labware;
|
}
|
|
private void InitializeData()
|
{
|
List<string> wellShapeList = new List<string>();
|
wellShapeList.Add(Properties.Resources.strPleaseSelect);
|
wellShapeList.Add(Properties.Resources.strCylinder);
|
wellShapeList.Add(Properties.Resources.strCuboid);
|
cbWellShape.ItemsSource = wellShapeList;
|
|
List<string> bottomShapeList = new List<string>();
|
bottomShapeList.Add(Properties.Resources.strPleaseSelect);
|
bottomShapeList.Add(Properties.Resources.strTaper);
|
bottomShapeList.Add(Properties.Resources.strHalfBall);
|
bottomShapeList.Add(Properties.Resources.strFlat);
|
bottomShapeList.Add(Properties.Resources.strPyramid);
|
cbBottomShape.ItemsSource = bottomShapeList;
|
}
|
|
private void AddGapLabware(int gap)
|
{
|
gridGapLabware.Children.Clear();
|
GapLabware labware = new GapLabware()
|
{
|
Width = 200,
|
GapWidth = 15,
|
LabwareGap = gap,
|
HorizontalAlignment = HorizontalAlignment.Left,
|
};
|
gridGapLabware.Children.Add(labware);
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
checkboxWN.IsChecked = true;
|
if (labware == null)
|
return;
|
|
nGap = 0;
|
if (labware.nw == 1)
|
{
|
checkboxWN.IsChecked = true;
|
nGap = nGap | GapLabware.WN;
|
}
|
if (labware.sw == 1)
|
{
|
checkboxWS.IsChecked = true;
|
nGap = nGap | GapLabware.WS;
|
}
|
if (labware.ne == 1)
|
{
|
checkboxEN.IsChecked = true;
|
nGap = nGap | GapLabware.EN;
|
}
|
if (labware.se == 1)
|
{
|
checkboxES.IsChecked = true;
|
nGap = nGap | GapLabware.ES;
|
}
|
AddGapLabware(nGap);
|
|
btnLeftSideColor.RGB = labware.labware_color_lside; // 左侧
|
btnWideColor.RGB = labware.labware_color_front; // 前侧
|
btnTopColor.RGB = labware.labware_color_top; // 顶面
|
btnLineColor.RGB = labware.labware_color_line; // 边框线
|
|
cbWellShape.SelectedIndex = Convert.ToInt16(labware.well_shape);
|
cbBottomShape.SelectedIndex = Convert.ToInt16(labware.well_bottom_shape);
|
|
int count = (int)labware.number_row * (int)labware.number_column;
|
textboxWellCount.Text = count.ToString();
|
}
|
|
int nGap = 0;
|
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
{
|
if (labware == null)
|
return;
|
CheckBox btn = (CheckBox)sender;
|
|
if (checkboxWN.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.WN;
|
labware.nw = 1;
|
}
|
else
|
{
|
nGap = nGap & 14;
|
labware.nw = 0;
|
}
|
if (checkboxWS.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.WS;
|
labware.sw = 1;
|
}
|
else
|
{
|
nGap = nGap & 13;
|
labware.sw = 0;
|
}
|
if (checkboxEN.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.EN;
|
labware.ne = 1;
|
}
|
else
|
{
|
nGap = nGap & 11;
|
labware.ne = 0;
|
}
|
if (checkboxES.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.ES;
|
labware.se = 1;
|
}
|
else
|
{
|
nGap = nGap & 7;
|
labware.se = 0;
|
}
|
AddGapLabware(nGap);
|
if (consumableManagement != null)
|
{
|
var a = consumableManagement.lvConsumable.SelectedItem as Labware;
|
a = labware;
|
}
|
}
|
|
private void CheckBox_UNChecked(object sender, RoutedEventArgs e)
|
{
|
if (labware == null)
|
return;
|
CheckBox btn = (CheckBox)sender;
|
int nGap = 0;
|
|
if (checkboxWN.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.WN;
|
labware.nw = 1;
|
}
|
else
|
{
|
nGap = nGap & 14;
|
labware.nw = 0;
|
}
|
if (checkboxWS.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.WS;
|
labware.sw = 1;
|
}
|
else
|
{
|
nGap = nGap & 13;
|
labware.sw = 0;
|
}
|
if (checkboxEN.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.EN;
|
labware.ne = 1;
|
}
|
else
|
{
|
nGap = nGap & 11;
|
labware.ne = 0;
|
}
|
if (checkboxES.IsChecked == true)
|
{
|
nGap = nGap | GapLabware.ES;
|
labware.se = 1;
|
}
|
else
|
{
|
nGap = nGap & 7;
|
labware.se = 0;
|
}
|
AddGapLabware(nGap);
|
if (consumableManagement != null)
|
{
|
var a = consumableManagement.lvConsumable.SelectedItem as Labware;
|
a = labware;
|
}
|
}
|
|
#region 宽边颜色
|
private void btnWideColor_SelectedColorChangedEvent(object sender, EventArgs e)
|
{
|
if (labware == null)
|
{
|
return;
|
}
|
|
labware.labware_color_front = btnWideColor.RGB;
|
if (consumableManagement != null)
|
{
|
consumableManagement.lvConsumable.SelectedItem = labware;
|
}
|
}
|
#endregion
|
|
#region 窄边颜色
|
private void btnLeftSideColor_SelectedColorChangedEvent(object sender, EventArgs e)
|
{
|
if (labware == null)
|
{
|
return;
|
}
|
|
labware.labware_color_lside = btnLeftSideColor.RGB;
|
if (consumableManagement != null)
|
{
|
consumableManagement.lvConsumable.SelectedItem = labware;
|
}
|
}
|
#endregion
|
|
#region 顶部颜色
|
private void btnTopColor_SelectedColorChangedEvent(object sender, EventArgs e)
|
{
|
if (labware == null)
|
{
|
return;
|
}
|
|
labware.labware_color_top = btnTopColor.RGB;
|
if (consumableManagement != null)
|
{
|
consumableManagement.lvConsumable.SelectedItem = labware;
|
}
|
}
|
#endregion
|
|
#region 边线颜色
|
private void btnLineColor_SelectedColorChangedEvent(object sender, EventArgs e)
|
{
|
if (labware == null)
|
{
|
return;
|
}
|
|
labware.labware_color_line = btnLineColor.RGB;
|
}
|
#endregion
|
|
private void cbWellShape_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
if (cbWellShape.SelectedIndex <= 0)
|
{
|
cbWellShape.BorderThickness = new Thickness(1);
|
return;
|
}
|
else
|
{
|
cbWellShape.BorderThickness = new Thickness(0);
|
}
|
if (labware == null)
|
return;
|
labware.well_shape = cbWellShape.SelectedIndex;
|
if (cbWellShape.SelectedIndex == (int)WellShape.Cylinder)
|
{
|
imgWellShape.Source = BitmapFrame.Create(new Uri("pack://application:,,,./Assets/Consumables/圆桶.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
gridCylinder.Visibility = Visibility.Visible;
|
gridCuboid.Visibility = Visibility.Collapsed;
|
}
|
else if (cbWellShape.SelectedIndex == (int)WellShape.Cuboid)
|
{
|
imgWellShape.Source = BitmapFrame.Create(new Uri("pack://application:,,,./Assets/Consumables/正方形.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
gridCylinder.Visibility = Visibility.Collapsed;
|
gridCuboid.Visibility = Visibility.Visible;
|
}
|
}
|
|
private void cbBottomShape_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
if (cbBottomShape.SelectedIndex <= 0)
|
{
|
cbBottomShape.BorderThickness = new Thickness(1);
|
return;
|
}
|
else
|
{
|
cbBottomShape.BorderThickness = new Thickness(0);
|
}
|
|
if (labware == null)
|
return;
|
|
labware.well_bottom_shape = cbBottomShape.SelectedIndex;
|
if (cbBottomShape.SelectedIndex == (int)BottomShape.Taper)
|
{
|
imgWellBottomShape.Source = BitmapFrame.Create(new Uri("pack://application:,,,./Assets/Consumables/倒锥.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
gridTaper.Visibility = Visibility.Visible;
|
gridHalfBall.Visibility = Visibility.Collapsed;
|
gridFlat.Visibility = Visibility.Collapsed;
|
gridPyramid.Visibility = Visibility.Collapsed;
|
}
|
else if (cbBottomShape.SelectedIndex == (int)BottomShape.HalfBall)
|
{
|
imgWellBottomShape.Source = BitmapFrame.Create(new Uri("pack://application:,,,./Assets/Consumables/半圆.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
gridTaper.Visibility = Visibility.Collapsed;
|
gridHalfBall.Visibility = Visibility.Visible;
|
gridFlat.Visibility = Visibility.Collapsed;
|
gridPyramid.Visibility = Visibility.Collapsed;
|
}
|
else if (cbBottomShape.SelectedIndex == (int)BottomShape.Flat)
|
{
|
imgWellBottomShape.Source = BitmapFrame.Create(new Uri("pack://application:,,,./Assets/Consumables/正方形.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
gridTaper.Visibility = Visibility.Collapsed;
|
gridHalfBall.Visibility = Visibility.Collapsed;
|
gridFlat.Visibility = Visibility.Visible;
|
gridPyramid.Visibility = Visibility.Collapsed;
|
}
|
else if (cbBottomShape.SelectedIndex == (int)BottomShape.Pyramid)
|
{
|
imgWellBottomShape.Source = BitmapFrame.Create(new Uri("pack://application:,,,./Assets/Consumables/倒三角形.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
gridTaper.Visibility = Visibility.Collapsed;
|
gridHalfBall.Visibility = Visibility.Collapsed;
|
gridFlat.Visibility = Visibility.Collapsed;
|
gridPyramid.Visibility = Visibility.Visible;
|
}
|
}
|
|
private void textboxRows_LostFocus(object sender, RoutedEventArgs e)
|
{
|
if (string.IsNullOrEmpty(textboxRows.Text.Trim()) || string.IsNullOrEmpty(textboxColumns.Text.Trim()))
|
return;
|
int rows = 0;
|
int.TryParse(textboxRows.Text.Trim(), out rows);
|
int cols = 0;
|
int.TryParse(textboxColumns.Text.Trim(), out cols);
|
textboxWellCount.Text = (rows * cols).ToString();
|
}
|
|
private void textboxColumns_LostFocus(object sender, RoutedEventArgs e)
|
{
|
if (string.IsNullOrEmpty(textboxRows.Text.Trim()) || string.IsNullOrEmpty(textboxColumns.Text.Trim()))
|
return;
|
|
int rows = 0;
|
int.TryParse(textboxRows.Text.Trim(), out rows);
|
int cols = 0;
|
int.TryParse(textboxColumns.Text.Trim(), out cols);
|
textboxWellCount.Text = (rows * cols).ToString();
|
}
|
|
private void PreviewTextInput(object sender, TextCompositionEventArgs e)
|
{
|
if (!Utilities.isNumberic(e.Text))
|
{
|
e.Handled = true;
|
}
|
else
|
e.Handled = false;
|
}
|
|
private void dgPointListData_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
{
|
|
}
|
|
private void dgPointListData_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
{
|
try
|
{
|
//如果点击了放弃按钮或ESC
|
if (e.EditAction == DataGridEditAction.Cancel)
|
{
|
return;
|
}
|
//获取编辑模式显示的元素,因为使用了模板,因此这里是ContentPresenter类型
|
ContentPresenter cp = e.EditingElement as ContentPresenter;
|
if (cp != null && VisualTreeHelper.GetChildrenCount(cp) > 0)
|
{
|
//找到编辑框
|
System.Windows.Controls.TextBox textBox = VisualTreeHelper.GetChild(cp, 0) as System.Windows.Controls.TextBox;
|
//如果找到
|
if (textBox != null)
|
{
|
string id = Convert.ToString(textBox.Tag);
|
|
//Labware labwareT = (Labware)(comboboxLabwareType.SelectedItem as Labware);
|
|
var labT = labwareWellInfos.FirstOrDefault(x => x.well_id.Equals(id));
|
if (labT != null)
|
{
|
if (textBox.Name == "tbxWellName")
|
{
|
labT.labware_well_name = textBox.Text;
|
}
|
else if (textBox.Name == "tbWellCenterx")
|
{
|
labT.labware_well_center_x = Convert.ToDouble(textBox.Text);
|
}
|
else if (textBox.Name == "tbWellCentery")
|
{
|
labT.labware_well_center_y = Convert.ToDouble(textBox.Text);
|
}
|
else if (textBox.Name == "tbWellDeepVal")
|
{
|
labT.labware_well_deepval = Convert.ToDouble(textBox.Text);
|
}
|
else if (textBox.Name == "tbWellMaxLength")
|
{
|
labT.well_max_length = Convert.ToDouble(textBox.Text);
|
}
|
}
|
|
//更新现在有的数据进入液体对象
|
//UpdateSpaceCoordinates();
|
|
var dataGrid = sender as System.Windows.Controls.DataGrid;
|
dataGrid.BeginEdit();
|
}
|
|
System.Windows.Controls.ComboBox comBox = VisualTreeHelper.GetChild(cp, 0) as System.Windows.Controls.ComboBox;
|
if (comBox != null)
|
{
|
string id = Convert.ToString(comBox.Tag);
|
|
//Labware labwareT = (Labware)(comboboxLabwareType.SelectedItem as Labware);
|
|
var labT = labwareWellInfos.FirstOrDefault(x => x.well_id.Equals(id));
|
if (labT != null)
|
{
|
if (comBox.Name == "cbxShape")
|
{
|
labT.labware_well_shape = comBox.SelectedIndex;
|
}
|
}
|
var dataGrid = sender as System.Windows.Controls.DataGrid;
|
dataGrid.BeginEdit();
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("System error:" + ex.Source + ":" + ex.Message.ToString());
|
}
|
}
|
|
private void dgPointListData_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
|
{
|
|
}
|
|
public ObservableCollection<LabwareWellInfo> labwareWellInfos = new ObservableCollection<LabwareWellInfo>();
|
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
LabwareWellInfo labwareWellInfo = new LabwareWellInfo();
|
labwareWellInfo.Index = labwareWellInfos.Count + 1;
|
labwareWellInfo.labware_id = labware.labware_id;
|
labwareWellInfo.labware_well_name = "";
|
labwareWellInfo.labware_well_center_x = 0d;
|
labwareWellInfo.labware_well_center_y = 0d;
|
labwareWellInfo.labware_well_deepval = 0d;
|
labwareWellInfo.labware_well_shape = 0;
|
labwareWellInfo.well_max_length = 0d;
|
labwareWellInfo.well_id=Guid.NewGuid().ToString();
|
labwareWellInfos.Add(labwareWellInfo);
|
|
//更新现在有的数据进入耗材对象
|
//UpdateSpaceCoordinates();
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void btnDelete_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
int SelectedRow = dgPointListData.SelectedIndex;//尝试解析出所选行
|
if (SelectedRow < 0)
|
{
|
return;
|
}
|
|
FrameworkElement element = dgPointListData.Columns[0].GetCellContent(dgPointListData.Items[SelectedRow]);
|
List<Label> listBtn = ViewCom.GetChildObjects<Label>((DependencyObject)element, typeof(Label));
|
if (listBtn.Count > 0)
|
{
|
string grd = Convert.ToString(listBtn[0].Tag);
|
labwareWellInfos.Remove(labwareWellInfos.FirstOrDefault(x => x.well_id == grd));
|
//更新现在有的数据进入液体对象
|
//UpdateSpaceCoordinates();
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
#region 孔类型变更事件
|
private void cbxShape_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
ComboBox comboBox = sender as ComboBox;
|
string id = Convert.ToString(comboBox.Tag);
|
|
var labT = labwareWellInfos.FirstOrDefault(x => x.well_id.Equals(id));
|
if (labT != null)
|
{
|
labT.labware_well_shape = comboBox.SelectedIndex;
|
}
|
}
|
#endregion
|
|
private void checkBoxWellType_Checked(object sender, RoutedEventArgs e)
|
{
|
if(labware!=null)
|
{
|
labware.labware_tubeshelf_type = 1;
|
}
|
gdPlateTubeInfo.Visibility = Visibility.Visible;
|
gdPlateBaseInfo.Visibility = Visibility.Collapsed;
|
}
|
|
private void checkBoxWellType_Unchecked(object sender, RoutedEventArgs e)
|
{
|
if (labware != null)
|
{
|
labware.labware_tubeshelf_type = 0;
|
}
|
gdPlateTubeInfo.Visibility = Visibility.Collapsed;
|
gdPlateBaseInfo.Visibility = Visibility.Visible;
|
}
|
|
private void cbxAdapterLabware_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
try
|
{
|
var comboBox = sender as ComboBox;
|
if (comboBox == null) return;
|
|
var row = Utilities.FindVisualParent<DataGridRow>(comboBox);
|
if (row == null) return;
|
|
var dataContext = row.DataContext;
|
if (dataContext == null) return;
|
|
string id = ((LabwareWellInfo)dataContext).well_id;
|
|
//ComboBox comboBox = sender as ComboBox;
|
//string id = Convert.ToString(comboBox.Tag);
|
|
var labT = labwareWellInfos.FirstOrDefault(x => x.well_id.Equals(id));
|
if (labT != null)
|
{
|
labT.well_labware_id = comboBox.SelectedValue.ToString();
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("cbxAdapterLabware_SelectionChanged error", ex);
|
}
|
}
|
}
|
}
|