using DataEntity.Share;
using DataRWDAL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
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 XImagingXhandler.XDAL;
namespace XHandler.View.Consumables
{
///
/// TipBoxSetting.xaml 的交互逻辑
///
public partial class TipBoxSetting : UserControl
{
public Labware labware { get; set; }
public TipBoxSetting()
{
InitializeComponent();
}
public TipBoxSetting(Labware l)
{
InitializeComponent();
labware = l;
DataContext = labware;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
checkboxWN.IsChecked = true;
if (labware == null)
return;
btnLeftSideColor.RGB = labware.labware_color_lside; // 左侧
btnWideColor.RGB = labware.labware_color_front; // 前侧
btnTopColor.RGB = labware.labware_color_top; // 顶面
btnLineColor.RGB = labware.labware_color_line; // 边框线
int count = (int)labware.number_row * (int)labware.number_column;
textboxWellCount.Text = count.ToString();
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
CheckBox btn = (CheckBox)sender;
int nGap = 0;
if (checkboxWN.IsChecked == true)
{
nGap = nGap | GapLabware.WN;
}
if (checkboxWS.IsChecked == true)
{
nGap = nGap | GapLabware.WS;
}
if (checkboxEN.IsChecked == true)
{
nGap = nGap | GapLabware.EN;
}
if (checkboxES.IsChecked == true)
{
nGap = nGap | GapLabware.ES;
}
AddGapLabware(nGap);
}
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);
}
#region 宽边颜色
private void btnWideColor_SelectedColorChangedEvent(object sender, EventArgs e)
{
if (labware == null)
{
return;
}
labware.labware_color_front = btnWideColor.RGB;
}
#endregion
#region 窄边颜色
private void btnLeftSideColor_SelectedColorChangedEvent(object sender, EventArgs e)
{
if (labware == null)
{
return;
}
labware.labware_color_lside = btnLeftSideColor.RGB;
}
#endregion
#region 顶部颜色
private void btnTopColor_SelectedColorChangedEvent(object sender, EventArgs e)
{
if (labware == null)
{
return;
}
labware.labware_color_top = btnTopColor.RGB;
}
#endregion
#region 边线颜色
private void btnLineColor_SelectedColorChangedEvent(object sender, EventArgs e)
{
if (labware == null)
{
return;
}
labware.labware_color_line = btnLineColor.RGB;
}
#endregion
private void textboxRows_TextChanged(object sender, TextChangedEventArgs 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_TextChanged(object sender, TextChangedEventArgs 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 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 btnTipLoadType_Click(object sender, RoutedEventArgs e)
{
try
{
string strlabwares = labware.tip_loaded_type;
ObservableCollection labwares = new ObservableCollection();
if (!string.IsNullOrEmpty(strlabwares))
{
string[] array = strlabwares.Split(',');
if (array != null)
{
for (int i = 0; i < array.Length; i++)
{
Labware labware = new Labware();
labware = LabwareDB.GetLabware(array[i]);
labwares.Add(labware);
}
}
}
TipLoadedTypeSet tipLoadedTypeSet = new TipLoadedTypeSet(labwares, labware);
tipLoadedTypeSet.Height = this.ActualHeight;
tipLoadedTypeSet.Width = this.ActualWidth;
SolidColorBrush mybtn1_Brush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
tipLoadedTypeSet.Background = (System.Windows.Media.Brush)mybtn1_Brush;
tipLoadedTypeSet.ShowDialog();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
}
}