黄学彪
2021-01-28 1fcf2302f79f9cbea5ef17c3688311ed65cfabb4
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
using System;
using Shared;
using System.Collections.Generic;
namespace HDL_ON.UI.UI2.Intelligence.Automation.LogicView
{
    public class TemperatureView
    {
        /// <summary>
        /// view
        /// </summary>
        /// <param name="frameLayout">弹窗父控件</param>
        /// <param name="stateValue">之前状态值</param>
        /// <param name="action">返回结果</param>
        public void FLayoutView(FrameLayout frameLayout, string stateValue, Action<string> action)
        {
            FrameLayout frame = new FrameLayout
            {
                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
            };
            frameLayout.AddChidren(frame);
            LogicView.TimeView view = new LogicView.TimeView();
            view.FLayoutView(frame);
            //取消点击事件
            view.btnCancel.MouseUpEventHandler += (sender1, e1) =>
            {
                //移除fLayout界面
                frame.RemoveFromParent();
            };
            //初始化列表
            var temperatureList = new List<string>();
            for (int i = 16; i < 32; i++)
            {
                //添加数据
                temperatureList.Add(i.ToString() + "℃");
                temperatureList.Add((i + 0.5).ToString() + "℃");
            }
            //加载数据界面的设置方法(列表互不联动)
            view.mUIPickerView.setNPicker(temperatureList, null, null);
            //默认初始选中状态
            view.mUIPickerView.setCurrentItems(9, 0, 0);
            //定义一个局部变量记录选中时间
            string temperature = "25℃";
            for (int i = 0; i < temperatureList.Count; i++)
            {
                if (temperatureList[i] == stateValue)
                {
                    //更新状态
                    view.mUIPickerView.setCurrentItems(i, 0, 0);
                    //更新状态
                    temperature = temperatureList[i];
                    break;
                }
            }
            //选中时间回调方法,时间变化一次回调一次
            view.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
            {
                temperature = temperatureList[index1];
            };
            //确定点击事件
            view.btnConfirm.MouseUpEventHandler += (sender2, e2) =>
            {
                action(temperature);
                frame.RemoveFromParent();
            };
        }
    }
}