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.Navigation;
|
using System.Windows.Shapes;
|
using XImagingXhandler.XDAL;
|
using XCommon.Log;
|
using System.Collections.ObjectModel;
|
|
namespace XHandler.View.MethodProperty
|
{
|
/// <summary>
|
/// WaitforProperty.xaml 的交互逻辑
|
/// </summary>
|
public partial class WaitforProperty : UserControl,ITimerObserver
|
{
|
public MethodWaitFor methodWaitFor { get; set; }
|
public MethodWaitFor currmethodWaitFor = null;
|
public MethodEx method = null;
|
|
#region 全局属性变量
|
string isrun = "";
|
string status = "";
|
string name = "";
|
string label = "";
|
string duringTimeText = "";
|
string duringTimeStrIndex = "";
|
bool endTimer = false;
|
int mark = 0;
|
#endregion
|
|
public WaitforProperty()
|
{
|
InitializeComponent();
|
}
|
|
#region timer变更后,更新节点内的Timer绑定
|
/// <summary>
|
/// timer变更后,更新节点内的Timer绑定
|
/// </summary>
|
/// <param name="duringTimerList">节点内的Timer管理对象</param>
|
public void ReceiveAndUpdate(List<DropdownName> duringTimerList)
|
{
|
cbTimerList.ItemsSource = duringTimerList;
|
if (methodWaitFor.duringTimeTextStrIndex == "")
|
{
|
if (duringTimerList.Count > 0)
|
{
|
cbTimerList.SelectedIndex = 0;
|
}
|
}
|
else
|
{
|
if (duringTimerList.Count > 0)
|
{
|
var containsValue = (cbTimerList.ItemsSource as List<DropdownName>).FirstOrDefault(x=>x.dropdown_id.Equals(methodWaitFor.duringTimeTextStrIndex));
|
if (containsValue != null)
|
{
|
cbTimerList.SelectedValue = methodWaitFor.duringTimeTextStrIndex;
|
}
|
}
|
}
|
}
|
#endregion
|
|
public WaitforProperty(MethodEx method, List<DropdownName> duringTimerList)
|
{
|
InitializeComponent();
|
mark = 0;
|
methodWaitFor = new MethodWaitFor();
|
methodWaitFor.name = method.method_name;
|
methodWaitFor.label = method.method_name;
|
methodWaitFor.status = (method.isEnabled == true ? "enable" : "disable");
|
methodWaitFor.isrun = "disable";
|
methodWaitFor.strIndex = method.strIndex;
|
cbTimerList.ItemsSource = duringTimerList;
|
|
this.method = method;
|
if (method.tag != null)
|
{
|
methodWaitFor = (MethodWaitFor)method.tag;
|
|
currmethodWaitFor = methodWaitFor;
|
isrun = methodWaitFor.isrun;
|
status = methodWaitFor.status;
|
name = methodWaitFor.name;
|
label = methodWaitFor.label;
|
duringTimeText = methodWaitFor.duringTimeText;
|
duringTimeStrIndex = methodWaitFor.duringTimeTextStrIndex;
|
endTimer = methodWaitFor.enableEndWaitfor = true;
|
}
|
this.DataContext = methodWaitFor;
|
}
|
|
private void cbTimerList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
try
|
{
|
if (methodWaitFor != null)
|
{
|
var currentItem = cbTimerList.SelectedItem as DropdownName;
|
if(currentItem == null)
|
{
|
return;
|
}
|
methodWaitFor.duringTimeText = (currentItem).dropdown_name;
|
methodWaitFor.duringTimeTextStrIndex = cbTimerList.SelectedValue.ToString();
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("{0}", methodWaitFor.duringTimeText.ToString());
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void cbxEndTimer_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
if (methodWaitFor != null)
|
{
|
methodWaitFor.enableEndWaitfor = (bool)cbxEndTimer.IsChecked;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
if (methodWaitFor != null)
|
{
|
methodWaitFor.name = tbxCommandName.Text;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
mark += 1;
|
try
|
{
|
if (mark > 1)
|
{
|
return;
|
}
|
if (!string.IsNullOrEmpty(duringTimeText))
|
{
|
tbxCommandName.Text = name;
|
|
|
cbTimerList.Text = duringTimeText;
|
cbxEndTimer.IsChecked = endTimer;
|
|
if (currmethodWaitFor != null)
|
{
|
methodWaitFor = currmethodWaitFor;
|
}
|
}
|
else
|
{
|
cbTimerList.SelectedIndex = -1;
|
|
if (currmethodWaitFor != null)
|
{
|
methodWaitFor = currmethodWaitFor;
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
}
|
}
|