xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
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
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.UI2.PersonalCenter.PirDevice;
using Shared;
using System;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 添加毫米波步骤1界面
    /// </summary>
    public class SensorEnvironmentManagerPage : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 添加设备完成之后的回调事件
        /// </summary>
        public Action DelDeviceEvent = null;
 
        Function function = null;
        #endregion
 
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm(Function device)
        {
            function = device;
            //设置头部信息
            base.SetTitleText(Language.StringByID(StringId.Add) + device.name);
            //这个界面的背景需要白色
            bodyFrameLayout.BackgroundColor = CSS.CSS_Color.BackgroundColor;
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //图片
            var btnPic = new PicViewControl(132, 132);
            btnPic.Y = Application.GetRealHeight(69);
            btnPic.Gravity = Gravity.CenterHorizontal;
            btnPic.UnSelectedImagePath = "PersonalCenter/AddDevice/SenesorMegahealthBg.png";
            bodyFrameLayout.AddChidren(btnPic);
 
            var btnTip = new Button()
            {
                Y = Application.GetRealHeight(309 - 44),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(319),
                Height = Application.GetRealHeight(84),
                IsMoreLines = true,
                TextAlignment = TextAlignment.Center,
                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                TextSize = CSS.CSS_FontSize.SubheadingFontSize,
            };
            bodyFrameLayout.AddChidren(btnTip);
 
            if (Language.CurrentLanguage == "Chinese")
            {
                btnTip.Text = "该设备已添加到传感器类别,可到对应功能板块查看";
            }
            else
            {
                btnTip.Text = "The device has been added to the sensor category, which can be viewed in the corresponding function block.";
            }
 
            var btnDel = new Button()
            {
                Y = Application.GetRealHeight(617 - 64),
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS.CSS_Color.WarningColor,
                TextSize = CSS.CSS_FontSize.SubheadingFontSize,
                TextID = StringId.DeleteDevice,
                BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
            };
            bodyFrameLayout.AddChidren(btnDel);
 
            btnDel.MouseUpEventHandler = (sender, e) => {
                var pack = PirSend.DeleteDevice(function.deviceId);
                if (pack.Code == StateCode.SUCCESS)
                {
                    DelDeviceEvent?.Invoke();
                    this.CloseForm();
                    var mes = "";
                    if (Language.CurrentLanguage == "Chinese")
                    {
                        mes = "设备删除成功。";
                    }
                    else
                    {
                        mes = "Device deleted successfully.";
                    }
                    var tip = new Tip()
                    {
                        Text = mes,
                        CloseTime = 2,
                        Direction = AMPopTipDirection.None
                    };
                    tip.Show(MainPage.BaseView);
                }
                else
                {
                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                }
            };
 
        }
 
        #endregion
 
        #region ■ 关闭界面___________________________
 
        /// <summary>
        /// 关闭界面
        /// </summary>
        public override void CloseFormBefore()
        {
            this.DelDeviceEvent = null;
            base.CloseFormBefore();
        }
 
        #endregion
    }
}