wxr
2020-12-21 f25c6122eb7e26be5e7f036cf29b9019c4953be2
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
using System;
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation.LogicView
{
    public class SwitchView
    {
 
        /// <summary>
        /// 主控件
        /// </summary>
        public FrameLayout frameLayout = new FrameLayout
        {
            BackgroundColor = CSS.CSS_Color.view,
            Y = Application.GetRealHeight(515),
            X = Application.GetRealWidth(16),
            Height = Application.GetRealHeight(44 * 44),
            Width = Application.GetRealWidth(343),
            Radius = (uint)Application.GetRealHeight(12)
        };
        /// <summary>
        /// 取消
        /// </summary>
        public Button btnCancel = new Button
        {
            TextAlignment = TextAlignment.Center,
            TextSize = TextSize.text16,
            TextColor = CSS.CSS_Color.textRedColor,
            TextID = StringId.cancelSelected,
            Y = Application.GetRealHeight(611),
            X = Application.GetRealWidth(16),
            Height = Application.GetRealHeight(44),
            Width = Application.GetRealWidth(343),
            BackgroundColor = CSS.CSS_Color.view,
            Radius = (uint)Application.GetRealHeight(12)
        };
        /// <summary>
        /// 开
        /// </summary>
        public Button btnOn = new Button
        {
            TextAlignment = TextAlignment.Center,
            TextSize = LogicView.TextSize.text16,
            TextColor = CSS.CSS_Color.textCancelColor,
            TextID = StringId.onLogic,
            Height = Application.GetRealHeight(44),
            Width = Application.GetRealWidth(343),
 
        };
        /// <summary>
        /// 线
        /// </summary>
        public Button btnLine = new Button
        {
            Height = 1,
            BackgroundColor = CSS.CSS_Color.viewLine,
            Y = Application.GetRealHeight(43),
        };
        /// <summary>
        /// 关
        /// </summary>
        public Button btnOff = new Button
        {
            Y = Application.GetRealHeight(44),
            TextAlignment = TextAlignment.Center,
            TextSize = LogicView.TextSize.text16,
            TextColor = CSS.CSS_Color.textCancelColor,
            TextID = StringId.offLogic,
            Height = Application.GetRealHeight(44),
            Width = Application.GetRealWidth(343),
        };
        /// <summary>
        /// 线1
        /// </summary>
        public Button btnLine1 = new Button
        {
            Height = 1,
            BackgroundColor = CSS.CSS_Color.viewLine,
            Y = Application.GetRealHeight(43 + 44),
        };
        /// <summary>
        /// 暂停
        /// </summary>
        public Button btnStop = new Button
        {
            Y = Application.GetRealHeight(44 + 44),
            TextAlignment = TextAlignment.Center,
            TextSize = LogicView.TextSize.text16,
            TextColor = CSS.CSS_Color.textCancelColor,
            TextID = StringId.stop,
            Height = Application.GetRealHeight(44),
            Width = Application.GetRealWidth(343),
        };
 
 
 
        /// <summary>
        /// View的方法
        /// </summary>
        ///  <param name="frame">父控件</param>
        /// <param name="i">显示选择View数量</param>
        ///<param name="stateVuale">之前的状态值</param>
        /// <param name="action">返回回调</param>
        /// <returns></returns>
        public void FLayoutView(FrameLayout frame, int i,string stateVuale,Action<string>action)
        {
            frameLayout.Y = Application.GetRealHeight(603 - (44 * i));
            frameLayout.Height = Application.GetRealHeight(44 * i);
            frame.AddChidren(frameLayout);
            frame.AddChidren(btnCancel);
            frameLayout.AddChidren(btnOn);
            frameLayout.AddChidren(btnLine);
            frameLayout.AddChidren(btnOff);
            if (i > 2)
            {
                /// 判断是否要是显示"暂停"按钮
                frameLayout.AddChidren(btnLine1);
                frameLayout.AddChidren(btnStop);
            }
            //取消点击事件
            btnCancel.MouseUpEventHandler += (sender1, e1) =>
            {
                frame.RemoveFromParent();
            };
 
 
            ///显示之前状态
            if (stateVuale != "")
            {
                if (stateVuale ==btnOn.Text)
                {
                    btnOn.TextColor = CSS.CSS_Color.textConfirmColor;
                }
                else if (stateVuale == btnOff.Text)
                {
                    btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
                }
                else if (stateVuale == btnStop.Text)
                {
                    btnStop.TextColor = CSS.CSS_Color.textConfirmColor;
                }
            }
 
            //开-点击事件
            btnOn.MouseUpEventHandler += (sender2, e2) =>
            {
                action("on");
                frame.RemoveFromParent();
            };
            //关-点击事件
            btnOff.MouseUpEventHandler += (sender3, e3) =>
            {
                action("off");
                frame.RemoveFromParent();
            };
            //暂停-点击事件
            btnStop.MouseUpEventHandler += (sender3, e3) =>
            {
                action("stop");
                frame.RemoveFromParent();
            };
 
        }
 
 
 
 
        ///// <summary>
        ///// View的方法
        ///// </summary>
        /////  <param name="frame">父控件</param>
        ///// <param name="i">显示选择View数量</param>
        ///// <returns></returns>
        //public void FLayoutView(FrameLayout frame, int i)
        //{
        //    frameLayout.Y = Application.GetRealHeight(603 - (44 * i));
        //    frameLayout.Height = Application.GetRealHeight(44 * i);
        //    frame.AddChidren(frameLayout);
        //    frame.AddChidren(btnCancel);
        //    frameLayout.AddChidren(btnOn);
        //    frameLayout.AddChidren(btnLine);
        //    frameLayout.AddChidren(btnOff);
        //    if (i > 2)
        //    {
        //        /// 判断是否要是显示"暂停"按钮
        //        frameLayout.AddChidren(btnLine1);
        //        frameLayout.AddChidren(btnStop);
        //    }
        //    btnCancel.MouseUpEventHandler += (sender1, e1) =>
        //    {
        //        frame.RemoveFromParent();
        //    };
        //}
    }
}