黄学彪
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
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
147
148
using System;
using System.Collections.Generic;
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public class Set:FrameLayout
    {
        public Set()
        {
            Tag = "Logic";
        }
 
        public void Show()
        {
 
            this.BackgroundColor = CSS.CSS_Color.viewMiddle;
            LogicView.TopView topView = new 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(LogicView.TextSize.view375),
                Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64 - 76),
                BackgroundColor = CSS.CSS_Color.viewMiddle,
            };
            this.AddChidren(viewLayout);
 
            LogicView.SelectTypeView nameView = new LogicView.SelectTypeView();
            nameView.btnText.X = Application.GetRealWidth(16);
            nameView.btnText.Height = Application.GetRealHeight(22);
            nameView.btnText.TextID = StringId.namelogic;
            nameView.btnIcon.Visible = false;
            nameView.btnNextIcon.Height = Application.GetRealWidth(28);
            nameView.btnNextIcon.Width = Application.GetRealWidth(28);
            nameView.btnNextIcon.UnSelectedImagePath = "LogicIcon/editname.png";
            viewLayout.AddChidren(nameView.FLayoutView());
 
            Button btnAutomationName = new Button
            {
                TextSize = LogicView.TextSize.text14,
                Width = Application.GetRealWidth(375 - 40 - 52),
                Height = Application.GetRealHeight(20),
                TextColor = CSS.CSS_Color.textCancelColor,
                X = Application.GetRealWidth(40),
                Gravity = Gravity.CenterVertical,
                TextAlignment = TextAlignment.CenterRight,
                Text =Logic.currlogic.name,
            };
            nameView.frameLayout.AddChidren(btnAutomationName);
 
 
            EventHandler<MouseEventArgs> editClick = (sender, e) =>
            {
                List<string> list = new List<string>();
                foreach (var logic in Logic.LogicList) {
                    list.Add(logic.name);
                }
 
                new LogicView.TipPopView().InputBox(StringId.editName, Logic.currlogic.name, StringId.nameNull, StringId.NameAlreadyExists, list, (logicName) =>
                {
                    btnAutomationName.Text = logicName;
                    Logic.currlogic.name = logicName;
 
                });
            };
            nameView.btnClick.MouseUpEventHandler += editClick;
            btnAutomationName.MouseUpEventHandler += editClick;
 
 
            #region  删除
            FrameLayout frameLayout = new FrameLayout
            {
                Y = Application.GetRealHeight(LogicView.TextSize.view667 - 50),
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS.CSS_Color.view,
                Gravity = Gravity.BottomCenter,//置底的属性
            };
            this.AddChidren(frameLayout);
            Button btnDel = new Button
            {
                TextSize = 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);
 
 
            EventHandler<MouseEventArgs> delClick = (sender, e) =>
            {
                Loading loading = new Loading();
                this.AddChidren(loading);
                HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
                new LogicView.TipPopView().TipBox(StringId.tip, StringId.delAutomation, () =>
                {
                    loading.Start();
                    new System.Threading.Thread(() =>
                    {
                        try
                        {
                            //发送删除逻辑命令;
                            responsePackNew = Send.DelLogic(Logic.currlogic);
 
                        }
                        catch { }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                loading.Hide();
                                if (responsePackNew != null && responsePackNew.Code == "0")
                                {
                                    LogicMethod.RemoveAllView();
                                    Logic.LogicList.Remove(Logic.currlogic);
                                    MainView.MainShow();
                                    //发送删除逻辑命令;
                                }
                                else if (responsePackNew != null && responsePackNew.Code == "14005")
                                {
                                    new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
                                }
                                else
                                {
                                    new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail));
                                }
                            });
                        }
 
                    })
                    { IsBackground = true }.Start();
                   
                });
 
            };
            btnDel.MouseUpEventHandler += delClick;
            frameLayout.MouseUpEventHandler += delClick;
            #endregion
 
        }
    }
}