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;
|
namespace XHandler.View.MethodProperty
|
{
|
/// <summary>
|
/// TimerProperty.xaml 的交互逻辑
|
/// </summary>
|
public partial class TimerProperty : UserControl
|
{
|
public MethodTimer methodTimer { get; set; }
|
public MethodTimer currmethodTimer = null;
|
public MethodEx method = null;
|
|
#region 全局属性变量
|
string isrun = "";
|
string status = "";
|
string name = "";
|
string label = "";
|
string duringTime = "";
|
string duringTimeInfo = "";
|
int mark = 0;
|
#endregion
|
|
public TimerProperty()
|
{
|
InitializeComponent();
|
}
|
|
public TimerProperty(MethodEx method)
|
{
|
InitializeComponent();
|
mark = 0;
|
methodTimer = new MethodTimer();
|
methodTimer.name = method.method_name;
|
methodTimer.label = method.method_name;
|
methodTimer.status = (method.isEnabled == true ? "enable" : "disable");
|
methodTimer.isrun = "disable";
|
methodTimer.strIndex = method.strIndex;
|
|
this.method = method;
|
if (method.tag != null)
|
{
|
methodTimer = (MethodTimer)method.tag;
|
|
currmethodTimer = methodTimer;
|
isrun = methodTimer.isrun;
|
status = methodTimer.status;
|
name = methodTimer.name;
|
label = methodTimer.label;
|
duringTime = methodTimer.duringTime;
|
duringTimeInfo = methodTimer.duringTimeInfo;
|
}
|
this.DataContext = methodTimer;
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
mark += 1;
|
try
|
{
|
if (mark > 1)
|
{
|
return;
|
}
|
if (!string.IsNullOrEmpty(duringTime) || !string.IsNullOrEmpty(duringTimeInfo))
|
{
|
tbxCommandName.Text = name;
|
|
|
tbxDuringTime.Text = duringTime;
|
tbxDuringTimeMsg.Text = duringTimeInfo;
|
|
if (currmethodTimer != null)
|
{
|
methodTimer = currmethodTimer;
|
}
|
}
|
else
|
{
|
tbxDuringTime.Text = "1";
|
|
if (currmethodTimer != null)
|
{
|
methodTimer = currmethodTimer;
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxDuringTime_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
string message = "";
|
if (!Consumables.ConsumablesValidationRule.IsNullOrEmpty(tbxDuringTime.Text, out message))
|
{
|
ptError.Text = message;
|
return;
|
}
|
if (!Consumables.ConsumablesValidationRule.IsPositiveIntegerr(tbxDuringTime.Text, out message))
|
{
|
ptError.Text = message;
|
return;
|
}
|
ptError.Text = "";
|
if (methodTimer != null)
|
{
|
methodTimer.duringTime = tbxDuringTime.Text;
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("{0}s", methodTimer.duringTime.ToString());
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxDuringTimeMsg_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
string message = "";
|
if (!Consumables.ConsumablesValidationRule.IsNullOrEmpty(tbxDuringTimeMsg.Text, out message))
|
{
|
pmError.Text = message;
|
return;
|
}
|
if (!Consumables.ConsumablesValidationRule.IsLength(tbxDuringTimeMsg.Text, 200, out message))
|
{
|
pmError.Text = message;
|
return;
|
}
|
pmError.Text = "";
|
if (methodTimer != null)
|
{
|
methodTimer.duringTimeInfo = tbxDuringTimeMsg.Text;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
if (methodTimer != null)
|
{
|
methodTimer.name = tbxCommandName.Text;
|
//调用更新Wairfor中的Timer
|
var mainWin = (MainWindow)Application.Current.MainWindow;
|
if (mainWin != null)
|
{
|
if (mark > 1)
|
{
|
mainWin.testDesign.updateWaitforOnWorkflow();
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
}
|
}
|