using DataEntity;
using DataEntity.Share;
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.View.Com;
using XImagingXhandler.XDAL;
namespace XHandler.View.Liquids
{
///
/// AspirateParam.xaml 的交互逻辑
///
public partial class AspirateParam : UserControl
{
public Liquid liquid { get; set; }
int nLiquidDetectLevelSelectedIndex = 0;
int nBlockDetectLevelSelectedIndex = 0;
int nApiratePositionSelectedIndex = 0;
int nKnockPositionSelectedIndex = 0;
public AspirateParam()
{
InitializeComponent();
List sensitiveList = new List();
sensitiveList.Add(SensitiveMode.Low.ToString());
sensitiveList.Add(SensitiveMode.Middle.ToString());
sensitiveList.Add(SensitiveMode.High.ToString());
cbLiquidDetectLevel.ItemsSource = sensitiveList;
cbBlockDetectLevel.ItemsSource = sensitiveList;
List aspiratePositionList = new List();
aspiratePositionList.Add(MixPositionEnum.Liquid.ToString());
aspiratePositionList.Add(MixPositionEnum.Top.ToString());
aspiratePositionList.Add(MixPositionEnum.Bottom.ToString());
cbAspiratePosition.ItemsSource = aspiratePositionList;
cbKnockPosition.ItemsSource = aspiratePositionList;
dgPointListData.ItemsSource = spaceCoordinates;
dgPointListData.DataContext= spaceCoordinates;
}
public AspirateParam(Liquid l)
{
InitializeComponent();
liquid = l;
List sensitiveList = new List();
sensitiveList.Add(SensitiveMode.Low.ToString());
sensitiveList.Add(SensitiveMode.Middle.ToString());
sensitiveList.Add(SensitiveMode.High.ToString());
cbLiquidDetectLevel.ItemsSource = sensitiveList;
cbBlockDetectLevel.ItemsSource = sensitiveList;
List aspiratePositionList = new List();
aspiratePositionList.Add(MixPositionEnum.Liquid.ToString());
aspiratePositionList.Add(MixPositionEnum.Top.ToString());
aspiratePositionList.Add(MixPositionEnum.Bottom.ToString());
cbAspiratePosition.ItemsSource = aspiratePositionList;
cbKnockPosition.ItemsSource = aspiratePositionList;
dgPointListData.ItemsSource = spaceCoordinates;
if (l!=null&&l.aspirate_well_bottom_length != "")
{
spaceCoordinates.Clear();
string[] strZOffsite = l.aspirate_well_bottom_length.Split(',');
string[] strXOffsite = l.aspirate_well_x.Split(',');
string[] strYOffsite = l.aspirate_well_y.Split(',');
for (int i = 0; i < strZOffsite.Length; i++)
{
SpaceCoordinate spaceCoordinate = new SpaceCoordinate();
spaceCoordinate.Index = i + 1;
spaceCoordinate.x = strXOffsite[i];
spaceCoordinate.y = strYOffsite[i];
spaceCoordinate.z = strZOffsite[i];
spaceCoordinates.Add(spaceCoordinate);
}
}
dgPointListData.DataContext = spaceCoordinates;
if (liquid == null)
return;
this.DataContext = liquid;
nLiquidDetectLevelSelectedIndex = Convert.ToInt16(liquid.sensibility==""?"0": liquid.sensibility);
nBlockDetectLevelSelectedIndex = Convert.ToInt16(liquid.blocking_sensibility==""?"0": liquid.blocking_sensibility);
nApiratePositionSelectedIndex = liquid.aspirate_position_type;
nKnockPositionSelectedIndex = liquid.knock_wall_position_type;
}
public void SetLiquid(Liquid l)
{
liquid = l;
this.DataContext = liquid;
nLiquidDetectLevelSelectedIndex = Convert.ToInt16(liquid.sensibility == "" ? "0" : liquid.sensibility);
nBlockDetectLevelSelectedIndex = Convert.ToInt16(liquid.blocking_sensibility == "" ? "0" : liquid.blocking_sensibility);
nApiratePositionSelectedIndex = liquid.aspirate_position_type;
nKnockPositionSelectedIndex = liquid.knock_wall_position_type;
cbKnockPosition.SelectedIndex = nKnockPositionSelectedIndex;
if (liquid.knock_direction == 4)
{
radiobuttonN.IsChecked = true;
}
else
{
radiobuttonN.IsChecked = false;
}
if (liquid.knock_direction == 3)
{
radiobuttonS.IsChecked = true;
}
else
{
radiobuttonS.IsChecked = false;
}
if (liquid.knock_direction == 2)
{
radiobuttonW.IsChecked = true;
}
else
{
radiobuttonW.IsChecked = false;
}
if (liquid.knock_direction == 1)
{
radiobuttonE.IsChecked = true;
}
else
{
radiobuttonE.IsChecked = false;
}
if (liquid.aspirate_is_knock_wall == 1)
{
checkBoxIsKnock.IsChecked = true;
tbBoxIsKnock.Text = "枪头碰壁-开";
}
else
{
checkBoxIsKnock.IsChecked = false;
tbBoxIsKnock.Text = "枪头碰壁-关";
}
if (liquid.divorcedgum_enable == 1)
{
tbdivorcedgum_xaxis.IsEnabled = true;
tbdivorcedgum_yaxis.IsEnabled = true;
checkBoxEnableDivGum.IsChecked = true;
}
else
{
tbdivorcedgum_xaxis.IsEnabled = false;
tbdivorcedgum_yaxis.IsEnabled = false;
checkBoxEnableDivGum.IsChecked = false;
}
cbBlockDetectLevel.SelectedIndex = Convert.ToInt32(liquid.blocking_sensibility == "" ? "0" : liquid.blocking_sensibility);
cbLiquidDetectLevel.SelectedIndex = Convert.ToInt32(liquid.sensibility == "" ? "0" : liquid.sensibility);
cbAspiratePosition.SelectedIndex = liquid.aspirate_position_type;
if (liquid != null && liquid.aspirate_well_bottom_length != "")
{
spaceCoordinates.Clear();
string[] strZOffsite = liquid.aspirate_well_bottom_length.Split(',');
string[] strXOffsite = liquid.aspirate_well_x.Split(',');
string[] strYOffsite = liquid.aspirate_well_y.Split(',');
for (int i = 0; i < strZOffsite.Length; i++)
{
SpaceCoordinate spaceCoordinate = new SpaceCoordinate();
spaceCoordinate.Index = i + 1;
spaceCoordinate.x = strXOffsite[i];
spaceCoordinate.y = strYOffsite[i];
spaceCoordinate.z = strZOffsite[i];
spaceCoordinates.Add(spaceCoordinate);
}
}
dgPointListData.DataContext = spaceCoordinates;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
if(Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceHXELEC))
{
HiddenOnElectroSys();
}
else
{
DisplayToOthersSys();
}
cbLiquidDetectLevel.SelectedIndex = nLiquidDetectLevelSelectedIndex;
cbBlockDetectLevel.SelectedIndex = nBlockDetectLevelSelectedIndex;
cbAspiratePosition.SelectedIndex = nApiratePositionSelectedIndex;
cbKnockPosition.SelectedIndex = nKnockPositionSelectedIndex;
if (liquid == null)
return;
if (liquid.aspirate_is_knock_wall == 1)
{
tbBoxIsKnock.Text = "枪头碰壁-开";
checkBoxIsKnock.IsChecked = true;
}
else
{
tbBoxIsKnock.Text = "枪头碰壁-关";
checkBoxIsKnock.IsChecked = false;
}
if (liquid.divorcedgum_enable == 1)
{
tbdivorcedgum_xaxis.IsEnabled = true;
tbdivorcedgum_yaxis.IsEnabled = true;
checkBoxEnableDivGum.IsChecked = true;
}
else
{
tbdivorcedgum_xaxis.IsEnabled = false;
tbdivorcedgum_yaxis.IsEnabled = false;
checkBoxEnableDivGum.IsChecked = false;
}
if (liquid.knock_direction == (int)KnockDirection.North)
radiobuttonN.IsChecked = true;
else if (liquid.knock_direction == (int)KnockDirection.South)
radiobuttonS.IsChecked = true;
else if (liquid.knock_direction == (int)KnockDirection.West)
radiobuttonW.IsChecked = true;
else if (liquid.knock_direction == (int)KnockDirection.East)
radiobuttonE.IsChecked = true;
string userid = UserDB.GetUserInfByUserName(Shared.User.username).id;
//所有菜单
List roleMenuAllList = UserDB.GetWholeRoleMenuByUserId(userid);
//权限控制
var MenuLiquidManage = roleMenuAllList.FirstOrDefault(x => x.rolemenuname.Equals(MenuName.MenuLiquidManage));
if (MenuLiquidManage != null)
{
var MenuLiquidEdit = MenuLiquidManage.rolemenuchildren.FirstOrDefault(x => x.rolemenuname.Equals(MenuName.SubMenuEdit));
if (MenuLiquidEdit != null)
{
gdContent.IsEnabled = true;
}
else
{
gdContent.IsEnabled = false;
}
}
dgPointListData.ItemsSource = spaceCoordinates;
dgPointListData.DataContext = spaceCoordinates;
}
///
/// 为切胶系统隐藏控件
///
private void HiddenOnElectroSys()
{
gdGunLiquidMark.Visibility = Visibility.Hidden;
gdContent.RowDefinitions[4].Height = new GridLength(0);
gdContent.RowDefinitions[5].Height = new GridLength(0);
gdContent.RowDefinitions[6].Height = new GridLength(0);
gdContent.RowDefinitions[7].Height = new GridLength(0);
//gdContent.RowDefinitions[8].Height = new GridLength(0);
//gdContent.RowDefinitions[9].Height = new GridLength(0);
//gdContent.RowDefinitions[10].Height = new GridLength(0);
gdContent.RowDefinitions[11].Height = new GridLength(0);
gdContent.RowDefinitions[12].Height = new GridLength(0);
gdContent.RowDefinitions[13].Height = new GridLength(0);
gdContent.RowDefinitions[14].Height = new GridLength(0);
gdContent.RowDefinitions[15].Height = new GridLength(0);
gdContent.RowDefinitions[16].Height = new GridLength(0);
gdContent.RowDefinitions[17].Height = new GridLength(0);
gdContent.RowDefinitions[18].Height = new GridLength(0);
gdContent.RowDefinitions[19].Height = new GridLength(0);
gdContent.RowDefinitions[20].Height = new GridLength(0);
gdContent.RowDefinitions[21].Height = new GridLength(0);
gdContent.RowDefinitions[22].Height = new GridLength(0);
gdContent.RowDefinitions[23].Height = new GridLength(0);
gdContent.RowDefinitions[24].Height = new GridLength(0);
gdContent.RowDefinitions[25].Height = new GridLength(0);
gdContent.RowDefinitions[26].Height = new GridLength(0);
gdContent.RowDefinitions[27].Height = new GridLength(40);
gdContent.RowDefinitions[28].Height = new GridLength(40);
gdContent.RowDefinitions[29].Height = new GridLength(40);
gdContent.RowDefinitions[30].Height = new GridLength(40);
}
///
/// 反显--切胶系统隐藏控件
///
///
///
private void DisplayToOthersSys()
{
gdGunLiquidMark.Visibility = Visibility.Visible;
gdContent.RowDefinitions[4].Height = new GridLength(40);
gdContent.RowDefinitions[5].Height = new GridLength(40);
gdContent.RowDefinitions[6].Height = new GridLength(40);
gdContent.RowDefinitions[7].Height = new GridLength(40);
gdContent.RowDefinitions[8].Height = new GridLength(40);
gdContent.RowDefinitions[9].Height = new GridLength(40);
gdContent.RowDefinitions[10].Height = new GridLength(40);
gdContent.RowDefinitions[11].Height = new GridLength(40);
gdContent.RowDefinitions[12].Height = new GridLength(40);
gdContent.RowDefinitions[13].Height = new GridLength(300);
gdContent.RowDefinitions[14].Height = new GridLength(40);
gdContent.RowDefinitions[15].Height = new GridLength(40);
gdContent.RowDefinitions[16].Height = new GridLength(40);
gdContent.RowDefinitions[17].Height = new GridLength(40);
gdContent.RowDefinitions[18].Height = new GridLength(40);
gdContent.RowDefinitions[19].Height = new GridLength(40);
gdContent.RowDefinitions[20].Height = new GridLength(40);
gdContent.RowDefinitions[21].Height = new GridLength(40);
gdContent.RowDefinitions[22].Height = new GridLength(40);
gdContent.RowDefinitions[23].Height = new GridLength(40);
gdContent.RowDefinitions[24].Height = new GridLength(40);
gdContent.RowDefinitions[25].Height = new GridLength(40);
gdContent.RowDefinitions[26].Height = new GridLength(40);
gdContent.RowDefinitions[27].Height = new GridLength(0);
gdContent.RowDefinitions[28].Height = new GridLength(0);
gdContent.RowDefinitions[29].Height = new GridLength(0);
gdContent.RowDefinitions[30].Height = new GridLength(0);
}
private void cbKnockPosition_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (liquid == null)
return;
liquid.knock_wall_position_type = (int)cbKnockPosition.SelectedIndex;
}
private void radiobuttonN_Click(object sender, RoutedEventArgs e)
{
if ((bool)radiobuttonN.IsChecked)
{
if (liquid == null)
return;
liquid.knock_direction = 4;
}
}
private void radiobuttonS_Click(object sender, RoutedEventArgs e)
{
if ((bool)radiobuttonS.IsChecked)
{
if (liquid == null)
return;
liquid.knock_direction = 3;
}
}
private void radiobuttonW_Click(object sender, RoutedEventArgs e)
{
if ((bool)radiobuttonW.IsChecked)
{
if (liquid == null)
return;
liquid.knock_direction = 2;
}
}
private void radiobuttonE_Click(object sender, RoutedEventArgs e)
{
if ((bool)radiobuttonE.IsChecked)
{
if (liquid == null)
return;
liquid.knock_direction = 1;
}
}
private void checkBoxIsKnock_Click(object sender, RoutedEventArgs e)
{
if ((bool)checkBoxIsKnock.IsChecked)
{
if (liquid == null)
return;
liquid.aspirate_is_knock_wall = 1;
}
else
{
if (liquid == null)
return;
liquid.aspirate_is_knock_wall = 0;
}
}
private void cbBlockDetectLevel_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (liquid == null)
return;
liquid.blocking_sensibility = cbBlockDetectLevel.SelectedIndex.ToString();
}
private void cbLiquidDetectLevel_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (liquid == null)
return;
liquid.sensibility = cbLiquidDetectLevel.SelectedIndex.ToString();
}
private void cbAspiratePosition_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (liquid == null)
return;
liquid.aspirate_position_type = cbAspiratePosition.SelectedIndex;
cbAspiratePosition.Focus();
}
private void awblError_SizeChanged(object sender, SizeChangedEventArgs e)
{
awblError.Visibility = Visibility.Visible;
awxlError.Visibility = Visibility.Hidden;
awylError.Visibility = Visibility.Hidden;
}
private void awxlError_SizeChanged(object sender, SizeChangedEventArgs e)
{
awblError.Visibility = Visibility.Hidden;
awxlError.Visibility = Visibility.Visible;
awylError.Visibility = Visibility.Hidden;
}
private void awylError_SizeChanged(object sender, SizeChangedEventArgs e)
{
awblError.Visibility = Visibility.Hidden;
awxlError.Visibility = Visibility.Hidden;
awylError.Visibility = Visibility.Visible;
}
private void checkBoxIsKnock_Checked(object sender, RoutedEventArgs e)
{
if ((bool)checkBoxIsKnock.IsChecked)
{
radiobuttonN.IsEnabled = true;
radiobuttonS.IsEnabled = true;
radiobuttonW.IsEnabled = true;
radiobuttonE.IsEnabled = true;
tbknock_speed.IsEnabled = true;
tbknock_wall_delay.IsEnabled = true;
cbKnockPosition.IsEnabled = true;
tbknock_well_height.IsEnabled = true;
tbBoxIsKnock.Text = "枪头碰壁-开";
}
else
{
radiobuttonN.IsEnabled = false;
radiobuttonS.IsEnabled = false;
radiobuttonW.IsEnabled = false;
radiobuttonE.IsEnabled = false;
tbknock_speed.IsEnabled = false;
tbknock_wall_delay.IsEnabled = false;
cbKnockPosition.IsEnabled = false;
tbknock_well_height.IsEnabled = false;
tbBoxIsKnock.Text = "枪头碰壁-关";
}
}
private void cbAspiratePosition_GotFocus(object sender, RoutedEventArgs e)
{
cbAspiratePosition.IsDropDownOpen = true;
}
private void cbAspiratePosition_DropDownOpened(object sender, EventArgs e)
{
cbAspiratePosition.Focus();
}
private void cbAspiratePosition_DropDownClosed(object sender, EventArgs e)
{
}
public ObservableCollection spaceCoordinates= new ObservableCollection();
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
try
{
SpaceCoordinate spaceCoordinate = new SpaceCoordinate();
spaceCoordinate.Index = spaceCoordinates.Count + 1;
spaceCoordinate.x = "0";
spaceCoordinate.y = "0";
spaceCoordinate.z = "0";
spaceCoordinates.Add(spaceCoordinate);
//更新现在有的数据进入液体对象
UpdateSpaceCoordinates();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
///
/// 更新现在有的数据进入液体对象
///
public void UpdateSpaceCoordinates()
{
//更新现在有的数据进入液体对象
string strZOffsite = "";
string strXOffsite = "";
string strYOffsite = "";
foreach (SpaceCoordinate s in spaceCoordinates)
{
strXOffsite += s.x + ",";
strYOffsite += s.y + ",";
strZOffsite += s.z + ",";
}
if (strZOffsite != "")
{
strXOffsite = strXOffsite.Substring(0, strXOffsite.Length - 1);
strYOffsite = strYOffsite.Substring(0, strYOffsite.Length - 1);
strZOffsite = strZOffsite.Substring(0, strZOffsite.Length - 1);
}
if (liquid != null)
{
liquid.aspirate_well_bottom_length = strZOffsite;
liquid.aspirate_well_x = strXOffsite;
liquid.aspirate_well_y = strYOffsite;
}
}
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