JLChen
2021-11-08 66bee2246076cd2b88b359cba13a13ca3302bafa
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
using System;
using System.Collections.Generic;
using HDL_ON.UI.UI2.Intelligence.Automation.LogicView;
using HDL_ON.UI.UI2.PersonalCenter.PirDevice.View;
using Shared;
namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice
{
 
    public class SetPir : FrameLayout
    {
        public SetPir()
        {
            Tag = "PirView";
        }
        public void Show()
        {
            #region 界面布局
            this.BackgroundColor = CSS.CSS_Color.viewMiddle;
            Intelligence.Automation.LogicView.TopView topView = new Intelligence.Automation.LogicView.TopView();
            this.AddChidren(topView.FLayoutView());
            topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
            {
                RemoveFromParent();
            };
            topView.topNameBtn.TextID = StringId.setlogic;
            FrameLayout viewLayout = new FrameLayout
            {
                Y = Application.GetRealHeight(64),
                Width = Application.GetRealWidth(Intelligence.Automation.LogicView.TextSize.view375),
                Height = Application.GetRealHeight(Intelligence.Automation.LogicView.TextSize.view667 - 64 - 76),
                BackgroundColor = CSS.CSS_Color.viewMiddle,
            };
            this.AddChidren(viewLayout);
            ///名称
            FrameLayout50 editNameFLayout = new FrameLayout50();
            editNameFLayout.btnText.Text = Language.StringByID(StringId.yaokongqimingcheng) + ":";
            editNameFLayout.btnEditText.Text = Pir.currPir.name;
            editNameFLayout.btnNextIcon.Height = Application.GetRealWidth(28);
            editNameFLayout.btnNextIcon.Width = Application.GetRealWidth(28);
            editNameFLayout.btnNextIcon.UnSelectedImagePath = "LogicIcon/editname.png";
            viewLayout.AddChidren(editNameFLayout.FLayoutView());
            /////版本升级
            //FrameLayout50 banbenshengjiFL = new FrameLayout50();
            //banbenshengjiFL.btnText.Text = Language.StringByID(StringId.banbenshengji);
            //banbenshengjiFL.frameLayout.Y = editNameFLayout.frameLayout.Bottom;
            //viewLayout.AddChidren(banbenshengjiFL.FLayoutView());
 
 
            var versions = Pir.currPir.versions.Find((c) => c.module.Contains("FW"));
            if (versions == null)
            {
                versions = new Entity.VersionInfo();
            }
            ///版本号:v1.3.5
            FrameLayout50 banbenhaoFLayout = new FrameLayout50();
            banbenhaoFLayout.btnNextIcon.Visible = false;
            banbenhaoFLayout.btnText.Text = Language.StringByID(StringId.banbenhao) + ":";// + versions.version;
            banbenhaoFLayout.btnEditText.Text = versions.version;
            banbenhaoFLayout.btnEditText.TextAlignment = TextAlignment.CenterRight;
            banbenhaoFLayout.btnEditText.X = Application.GetRealWidth(357 - 200 - 16);
            banbenhaoFLayout.btnEditText.Width = Application.GetRealWidth(200);
            banbenhaoFLayout.btnText.Width = Application.GetRealWidth(280);
            banbenhaoFLayout.frameLayout.Y = editNameFLayout.frameLayout.Bottom;// banbenshengjiFL.frameLayout.Bottom;
            viewLayout.AddChidren(banbenhaoFLayout.FLayoutView());
         
            //删除
            FrameLayout frameLayout = new FrameLayout
            {
                Y = Application.GetRealHeight(Intelligence.Automation.LogicView.TextSize.view667 - 50),
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS.CSS_Color.view,
                Gravity = Gravity.BottomCenter,//置底的属性
            };
            this.AddChidren(frameLayout);
            Button btnDel = new Button
            {
                TextSize = Intelligence.Automation.LogicView.TextSize.text16,
                Width = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(22),
                TextColor = CSS.CSS_Color.textRedColor,
                Gravity = Gravity.Center,
                TextID = StringId.Del,
            };
            frameLayout.AddChidren(btnDel);
            #endregion
            #region  界面点击事件
            //修改名称的点击事件
            editNameFLayout.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                List<string> list = new List<string>();
                PirMethod method = new PirMethod();
                method.EditControlName(StringId.editName, list, Pir.currPir.name, (name, dialog) =>
                {
                    PirMethod.ThreadSend(new Control { deviceId = Pir.currPir.deviceId, name = name }, (responsePackNew) =>
                    {
                        dialog.Close();
                        editNameFLayout.btnEditText.Text = name;
                        Pir.currPir.name = name;
 
                    }, "修改名称", "dialog", null, dialog);
 
                }, () => { });
            };
            //删除红外宝的点击事件
            EventHandler<MouseEventArgs> delClick = (sender, e) =>
            {
                string text = Language.StringByID(StringId.shanchushebei) + Pir.currPir.name + "?";
                TipPopView tipPopView = new TipPopView();
                tipPopView.TipBox(StringId.tip, text, (dialog) =>
                {
 
                    PirMethod.ThreadSend(new Control { deviceId = Pir.currPir.deviceId }, (responsePackNew) =>
                    {
                        var pir = Pir.pirDeviceList.Find((c) => c.deviceId == Pir.currPir.deviceId);
                        if (pir != null)
                        {
                            Pir.pirDeviceList.Remove(Pir.currPir);
                        }
                        dialog.Close();
                        this.RemoveFromParent();
                        PirMethod.RemoveView("PirMain");
                    }, "删除", "dialog", null, dialog);
 
                }, () =>
                {
                }, false);
 
 
            };
            btnDel.MouseUpEventHandler += delClick;
            frameLayout.MouseUpEventHandler += delClick;
            #endregion
 
        }
        /// <summary>
        /// 移除界面
        /// </summary>
        public override void RemoveFromParent()
        {
            //刷新PirMain界面
            PirMethod.RefreshView("PirMain");
            base.RemoveFromParent();
          
        }
    }
}