using DataEntity.Share;
using System;
using System.Collections.Generic;
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.Shapes;
using XCommon.Log;
using XHandler.Class.DataEx;
using XImagingXhandler.XDAL;
namespace XHandler.View.Dialog
{
///
/// PlsArmChannelWin.xaml 的交互逻辑
///
public partial class PlsArmChannelWin : Window
{
public string armText= string.Empty;
public string armValue = string.Empty;
public string channelText= string.Empty;
public int[] channelArray=new int[0];
public PlsArmChannelWin()
{
InitializeComponent();
this.Owner = (Window)Shared.Main;
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
#region 界面加载
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
List armList = DataModule.getInstance().GetDeviceArmWithAll();
cbArm.ItemsSource = armList;
cbArm.SelectedIndex = 0;
if (Shared.ChannelCount > 1)
{
tipsChannel.CanEdit = true;
if (Shared.ChannelCount.Equals(96))
{
tipsChannel.Visibility = Visibility.Collapsed;
}
}
}
catch(Exception ex)
{
LoggerHelper.ErrorLog("page load error", ex);
}
}
#endregion
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
}
private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
DeviceArm arm = cbArm.SelectedItem as DeviceArm;
armText = arm.device_arm_name;
armValue = arm.device_arm_id.ToString();
channelArray = tipsChannel.SelectedChannels.ToArray();
if (arm.arm_type.Equals(-1))
{
gdContent.RowDefinitions[2].Height = new GridLength(0);
return;
}
else
{
gdContent.RowDefinitions[2].Height = new GridLength(60);
}
if (Shared.ChannelCount.Equals(96))
{
channelArray = 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 )
{
gdContent.RowDefinitions[2].Height = new GridLength(0);
return;
}
tipsChannel_SelectedChangedEvent(null, null);
}
ReceiveAndUpdate(armValue);
}
catch (Exception ex)
{
LoggerHelper.ErrorLog(" cbArm_SelectionChanged ERROR:", ex);
}
}
///
/// 通道设置变更后,更新节点
///
///
public void ReceiveAndUpdate(string armVale)
{
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.arm_type.Equals(1) && x.device_arm_id.Equals(Convert.ToInt32(armVale)));
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();
}
channelArray = iChannels.ToArray();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("tipsChannel_SelectedChangedEvent ERROR:", ex);
}
}
private void tipsChannel_SelectedChangedEvent(object sender, EventArgs e)
{
try
{
channelArray = tipsChannel.SelectedChannels.ToArray();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("tipsChannel_SelectedChangedEvent ERROR:", ex);
}
}
}
}