schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
{
    /// <summary>
    /// ResetProperty.xaml 的交互逻辑
    /// </summary>
    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<DeviceArm> 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);
            }
        }
    }
}