using System;
|
using System.Windows;
|
using System.Windows.Controls;
|
using XCommon.Log;
|
using XHandler.Class.DataEx;
|
using XImagingXhandler.XDAL;
|
|
namespace XHandler.View.MethodProperty
|
{
|
/// <summary>
|
/// PauseProperty.xaml 的交互逻辑
|
/// </summary>
|
public partial class PauseProperty : System.Windows.Controls.UserControl
|
{
|
public MethodPauseMove methodPauseMove { get; set; }
|
public MethodPauseMove currmethodPauseMove = null;
|
public MethodEx method = null;
|
#region 全局属性变量
|
string isrun = "";
|
string status = "";
|
string name = "";
|
string label = "";
|
string pauseTime = "";
|
string pauseTipInfo = "";
|
int pauseModel = 0;
|
int mark = 0;
|
#endregion
|
|
public PauseProperty()
|
{
|
InitializeComponent();
|
}
|
|
public PauseProperty(MethodEx method)
|
{
|
InitializeComponent();
|
mark = 0;
|
methodPauseMove = new MethodPauseMove();
|
methodPauseMove.name = method.method_name;
|
methodPauseMove.label = method.method_name;
|
methodPauseMove.status = (method.isEnabled == true ? "enable" : "disable");
|
methodPauseMove.isrun = "disable";
|
methodPauseMove.pauseMode = (int)PauseMode.Timer;
|
methodPauseMove.strIndex = method.strIndex;
|
|
this.DataContext = methodPauseMove;
|
this.method = method;
|
if (method.tag != null)
|
{
|
methodPauseMove = (MethodPauseMove)method.tag;
|
|
currmethodPauseMove = methodPauseMove;
|
isrun = methodPauseMove.isrun;
|
status = methodPauseMove.status;
|
name = methodPauseMove.name;
|
label = methodPauseMove.label;
|
pauseTime = methodPauseMove.pauseTime;
|
pauseTipInfo = methodPauseMove.pauseTipInfo;
|
pauseModel = methodPauseMove.pauseMode;
|
}
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
mark += 1;
|
try
|
{
|
if (mark > 1)
|
{
|
return;
|
}
|
if (!string.IsNullOrEmpty(pauseTime) || !string.IsNullOrEmpty(pauseTipInfo))
|
{
|
tbxCommandName.Text = name;
|
|
|
if (pauseModel == 0)
|
{
|
radioBtnTimer.IsChecked = true;
|
tbxPauseTime.Text = pauseTime;
|
}
|
else if (pauseModel == 1)
|
{
|
radioBtnPrompt.IsChecked = true;
|
tbxPauseMsg.Text = pauseTipInfo;
|
}
|
|
if (currmethodPauseMove != null)
|
{
|
methodPauseMove = currmethodPauseMove;
|
}
|
}
|
else
|
{
|
if (methodPauseMove.pauseMode == (int)PauseMode.Timer)
|
radioBtnTimer.IsChecked = true;
|
else
|
radioBtnPrompt.IsChecked = true;
|
|
if (currmethodPauseMove != null)
|
{
|
methodPauseMove = currmethodPauseMove;
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void radioBtnTimer_Checked(object sender, RoutedEventArgs e)
|
{
|
if (radioBtnTimer.IsChecked == true)
|
{
|
if (methodPauseMove != null)
|
{
|
methodPauseMove.pauseMode = (int)PauseMode.Timer;
|
}
|
}
|
}
|
|
private void radioBtnPrompt_Checked(object sender, RoutedEventArgs e)
|
{
|
if (radioBtnPrompt.IsChecked == true)
|
{
|
if (methodPauseMove != null)
|
{
|
methodPauseMove.pauseMode = (int)PauseMode.Prompt;
|
}
|
}
|
}
|
|
private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
if (methodPauseMove != null)
|
{
|
methodPauseMove.name = tbxCommandName.Text;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxPauseTime_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
string message = "";
|
if (!Consumables.ConsumablesValidationRule.IsNullOrEmpty(tbxPauseTime.Text, out message))
|
{
|
ptError.Text = message;
|
return;
|
}
|
if (!Consumables.ConsumablesValidationRule.IsPositiveIntegerr(tbxPauseTime.Text, out message))
|
{
|
ptError.Text = message;
|
return;
|
}
|
ptError.Text = "";
|
if (methodPauseMove != null)
|
{
|
methodPauseMove.pauseTime = tbxPauseTime.Text;
|
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("{0};{1}", methodPauseMove.pauseTime, methodPauseMove.pauseTipInfo);
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxPauseMsg_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
string message = "";
|
if (!Consumables.ConsumablesValidationRule.IsNullOrEmpty(tbxPauseMsg.Text, out message))
|
{
|
pmError.Text = message;
|
return;
|
}
|
if (!Consumables.ConsumablesValidationRule.IsLength(tbxPauseMsg.Text, 200, out message))
|
{
|
pmError.Text = message;
|
return;
|
}
|
pmError.Text = "";
|
if (methodPauseMove != null)
|
{
|
methodPauseMove.pauseTipInfo = tbxPauseMsg.Text;
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("{0};{1}", methodPauseMove.pauseTime, methodPauseMove.pauseTipInfo);
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
}
|
}
|