using System; using System.Windows; using System.Windows.Controls; using XCommon.Log; using XHandler.Class.DataEx; using XImagingXhandler.XDAL; namespace XHandler.View.MethodProperty { /// /// GroupProperty.xaml 的交互逻辑 /// public partial class GroupProperty : UserControl { public MethodCombination methodGroup { get; set; } public MethodCombination currmethodGroup = null; public MethodEx method = null; #region 全局属性变量 string isrun = ""; string status = ""; string name = ""; string label = ""; string title = ""; string remark = ""; int mark = 0; #endregion public GroupProperty() { InitializeComponent(); } public GroupProperty(MethodEx method) { InitializeComponent(); mark = 0; methodGroup = new MethodCombination(); methodGroup.isrun = "disable"; methodGroup.status = (method.isEnabled == true ? "enable" : "disable"); methodGroup.name = method.method_name; methodGroup.label = method.method_name; tbxCommandName.Text = methodGroup.name; DataContext = methodGroup; this.method = method; if (method.tag != null) { methodGroup = (MethodCombination)method.tag; currmethodGroup = methodGroup; isrun = methodGroup.isrun; status = methodGroup.status; name = methodGroup.name; label = methodGroup.label; title = methodGroup.title; remark = methodGroup.remark; if (this.method != null) { this.method.method_name = name; } } } private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e) { try { if (methodGroup != null) { if (methodGroup.name == tbxCommandName.Text) { } else { methodGroup.name = tbxCommandName.Text; } if (this.method != null) { if (methodGroup.name != string.Empty) { this.method.method_name = methodGroup.name; } else { if (tbxCommandName.Text == "") { this.method.method_name = ""; } } } } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } private void tbxTitle_TextChanged(object sender, TextChangedEventArgs e) { try { if (string.IsNullOrEmpty(tbxTitle.Text)) { xtError.Text = "标签不能为空"; return; } else { xtError.Text = ""; } if (methodGroup != null) { methodGroup.title = tbxTitle.Text; } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } private void tbxDetail_TextChanged(object sender, TextChangedEventArgs e) { try { if (methodGroup != null) { methodGroup.remark = tbxDetail.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(title)) { tbxCommandName.Text = name; tbxTitle.Text = title; tbxDetail.Text = remark; if (this.method != null) { this.method.method_name = name; } //if (currmethodGroup != null) //{ // methodGroup = currmethodGroup; //} } else { if (this.method != null) { if (!string.IsNullOrEmpty(name)) { this.method.method_name = name; tbxCommandName.Text = name; } tbxTitle.Text = title; tbxDetail.Text = remark; } //if (currmethodGroup != null) //{ // methodGroup = currmethodGroup; //} } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } } }