wei
2021-06-06 e63d7efbe2a41783989bdaea94d37bb6f16deb22
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
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.UI2.PersonalCenter.PirDevice;
using Shared;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 添加毫米波步骤1界面
    /// </summary>
    public class SenesorMegahealthManagerPage : 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 is planned to be used in the corresponding category for security sensor.";
            }
 
            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();
                }else
                {
                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                }
            };
 
        }
 
        #endregion
 
        #region ■ 关闭界面___________________________
 
        /// <summary>
        /// 关闭界面
        /// </summary>
        public override void CloseFormBefore()
        {
            this.DelDeviceEvent = null;
            base.CloseFormBefore();
        }
 
        #endregion
    }
}