黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DeviceLight
{
    /// <summary>
    /// mini夜灯的功能设置界面
    /// </summary>
    public class MiniNightLightFunctionSettionForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 设备的某一回路
        /// </summary>
        private CommonDevice device = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_device">设备的某一回路</param>
        public void ShowForm(CommonDevice i_device)
        {
            this.device = i_device;
 
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //图片
            var btnPic = new PicViewControl(508, 204);
            btnPic.Y = Application.GetRealHeight(179);
            btnPic.Gravity = Gravity.CenterHorizontal;
            btnPic.UnSelectedImagePath = "DeviceItem/MiniNightLightDevice.png";
            bodyFrameLayout.AddChidren(btnPic);
 
            var listBackControl = new VerticalFrameControl();
            listBackControl.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listBackControl);
 
            //初始化桌布
            var tableContr = new InformationEditorControl();
            var listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1166);
 
            //回路备注
            string caption = Language.StringByID(R.MyInternationalizationString.uDeviceEpointNote);
            string nameValue = HdlDeviceCommonLogic.Current.GetDeviceEpointName(this.device);
            var btnDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
            btnDeviceName.txtInput.MaxByte = 48;//限制只能输入48个字节
            listview.AddChidren(btnDeviceName);
            btnDeviceName.InitControl();
            btnDeviceName.AddBottomLine();
            btnDeviceName.txtInput.FinishInputEvent += () =>
            {
                string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(this.device);
                if (btnDeviceName.Text.Trim() == string.Empty)
                {
                    //将名字还原
                    btnDeviceName.Text = oldName;
                }
                if (oldName != btnDeviceName.Text.Trim())
                {
                    //设备名称修改
                    var result = HdlDeviceCommonLogic.Current.ReName(this.device, btnDeviceName.Text.Trim());
                    if (result == false)
                    {
                        return;
                    }
                    //回路备注修改成功!
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceEpointReNoteSuccess);
                    this.ShowMassage(ShowMsgType.Tip, msg);
                }
            };
 
            //所属区域
            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
            listview.AddChidren(rowBeloneArea);
            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.device);
            //底线
            rowBeloneArea.AddBottomLine();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //变更房间
                HdlRoomLogic.Current.ChangedRoom(this.device, roomKeys);
            };
 
            //自定义功能类型控件
            var rowFunction = new DeviceFunctionTypeRowControl(this.device, listview.rowSpace / 2);
            if (rowFunction.CanShowRow == true)
            {
                listview.AddChidren(rowFunction);
                rowFunction.InitControl();
                //底线
                rowFunction.AddBottomLine();
            }
            //初始化桌布完成
            tableContr.FinishInitControl();
 
            //保存
            var btnFinish = new BottomClickButton();
            btnFinish.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                string newName = btnDeviceName.Text.Trim();
                string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                if (oldName != newName)
                {
                    //设备名称修改
                    var result = HdlDeviceCommonLogic.Current.ReName(device, newName);
                    if (result == false)
                    {
                        return;
                    }
                }
                //关闭自身
                this.CloseForm();
            };
        }
 
        #endregion
    }
}