using System; using System.Windows; using System.Windows.Controls; using XCommon.Log; using XCore; using XHandler.Class.DataEx; using XImagingXhandler.XDAL; namespace XHandler.View.MethodProperty { /// /// ResetProperty.xaml 的交互逻辑 /// public partial class ResetProperty : UserControl { public MethodHome methodHome { get; set; } public MethodHome currmethodHome = null; AspirateBll aspirateBll = new AspirateBll(); int curArmSelectedIndex = -1; #region 全局属性变量 string isrun = ""; string status = ""; string name = ""; string label = ""; string armText = ""; string armValue = ""; int mark = 0; #endregion public ResetProperty() { InitializeComponent(); } public ResetProperty(MethodEx method) { InitializeComponent(); mark = 0; curArmSelectedIndex = 0; //ObservableCollection deviceArms = DataModule.getInstance().GetDeviceArm(); //cbArm.ItemsSource = deviceArms; methodHome = new MethodHome(); methodHome.name = method.method_name; methodHome.label = method.method_name; methodHome.status = (method.isEnabled == true ? "enable" : "disable"); methodHome.strIndex = method.strIndex; this.DataContext = methodHome; if (method.tag != null) { methodHome = (MethodHome)method.tag; currmethodHome = methodHome; isrun = methodHome.isrun; status = methodHome.status; name = methodHome.name; label = methodHome.label; armText = methodHome.armText; armValue = methodHome.armValue; } } private void UserControl_Loaded(object sender, RoutedEventArgs e) { mark += 1; try { if (mark > 1) { return; } if (!string.IsNullOrEmpty(armText)) { tbxCommandName.Text = name; // cbArm.SelectedValue = armValue; if (currmethodHome != null) { methodHome = currmethodHome; } } else { // cbArm.SelectedIndex = curArmSelectedIndex; if (currmethodHome != null) { methodHome = currmethodHome; } } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cbArm.SelectedIndex < 0) return; curArmSelectedIndex= cbArm.SelectedIndex; DeviceArm arm = cbArm.SelectedItem as DeviceArm; if (methodHome != null) { methodHome.armText = arm.device_arm_name; methodHome.armValue = arm.device_arm_id.ToString(); } } private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e) { try { if (methodHome != null) { methodHome.name = tbxCommandName.Text; } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } } }