黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.R;
 
namespace Shared.Phone.Device.Logic
{
    public class Illumination : FrameLayout
    {
        public Illumination()
        {
            Tag = "Logic";
        }
 
        public void Show(ZigBee.Device.CommonDevice common,string name,int progresValue,bool _bool)
        {
            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            view.toptitleNameBtn.Text = name;
            view.clickBtn.MouseDownEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
            FrameLayout middle = new FrameLayout
            {
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(Method.H - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
            //白色快父控件
            FrameLayout blankFraLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(616),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren(blankFraLayout);
            //照度值控件
            Button illuminationBtn = new Button
            {
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(259 - 184),
                Height = Application.GetRealHeight(50),
                Width = Application.GetRealWidth(300),
                Text =Language.StringByID(MyInternationalizationString.illuminanceValue)+ progresValue+"lux",
                //TextID = MyInternationalizationString.Save,
                TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                TextSize = 12,
            };
            middle.AddChidren(illuminationBtn);
            //-图标控件
            Button lessBtn = new Button
            {
                X = Application.GetRealWidth(847),
                Y = Application.GetRealHeight(46),
                Height = Application.GetMinRealAverage(104),
                Width = Application.GetMinRealAverage(104),
                UnSelectedImagePath = "ZigeeLogic/lesLuminositys.png",
            };
            middle.AddChidren(lessBtn);
            //+图标控件
            Button addBtn = new Button
            {
                X = lessBtn.Right,
                Y = Application.GetRealHeight(46),
                Height = Application.GetMinRealAverage(104),
                Width = Application.GetMinRealAverage(104),
                UnSelectedImagePath = "ZigeeLogic/addLuminosity.png",
            };
            middle.AddChidren(addBtn);
            //进度条控件
            var horizontalSeekBarVol = new DiyImageSeekBar
            {
                Y = Application.GetRealHeight(173),//进度条父控件Y坐标
                X = Application.GetRealWidth(104),//进度条X坐标
                Width = Application.GetRealWidth(873),//进度条的长度
                Height = Application.GetRealHeight(56),//进度条父控件高度
                IsProgressTextShow = false,//显示百分比
                IsClickable = true,//进度条是否滑动
                ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected,//选中进度条颜色
                SeekBarBackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,//进度条颜色
                ThumbImagePath = "ZigeeLogic/progressbtn2.png",//进度条按钮图标
                ThumbImageHeight = Application.GetRealHeight(56),//进度条按钮图标的高度(默认正方形:宽和高一样)
                ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                //ProgressTextSize = 9,//显示百分比字体大小12
                SeekBarViewHeight = Application.GetRealHeight(7),//进度条的高度10
                MaxValue = 100,
                MinValue = 0,
                Progress = progresValue,
            };
            middle.AddChidren(horizontalSeekBarVol);
            lessBtn.MouseUpEventHandler += (sender, e) =>
            {
                horizontalSeekBarVol.Progress = horizontalSeekBarVol.Progress - 1;
                illuminationBtn.Text = Language.StringByID(MyInternationalizationString.illuminanceValue) + horizontalSeekBarVol.Progress.ToString() + "lux";
            };
            addBtn.MouseUpEventHandler += (sender, e) =>
            {
                horizontalSeekBarVol.Progress = horizontalSeekBarVol.Progress + 1;
                illuminationBtn.Text = Language.StringByID(MyInternationalizationString.illuminanceValue) + horizontalSeekBarVol.Progress.ToString() + "lux";
            };
            EventHandler<int> progressclick = (sender, e) =>
            {
                illuminationBtn.Text = Language.StringByID(MyInternationalizationString.illuminanceValue) + horizontalSeekBarVol.Progress.ToString() + "lux";
            };
            horizontalSeekBarVol.OnProgressChangedEvent += progressclick;
            horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick;
 
            Button text1Btn = new Button()
            {
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(426 - 184),
                Height = Application.GetRealHeight(100),
                Width = Application.GetRealWidth(63+15),
                Text = Language.StringByID(MyInternationalizationString.dark).Replace("{\\r\\n}", "\r\n"),
                TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                TextSize = 12,
                TextAlignment = TextAlignment.Center,
                IsMoreLines = true,
            };
            middle.AddChidren(text1Btn);
 
            Button text2Btn = new Button()
            {
                X = Application.GetRealWidth(913-20),
                Y = Application.GetRealHeight(426 - 184),
                Height = Application.GetRealHeight(100),
                Width = Application.GetRealWidth(109+20),
                Text = Language.StringByID(MyInternationalizationString.bright).Replace("{\\r\\n}", "\r\n"),
                TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                TextSize = 12,
                TextAlignment = TextAlignment.Center,
                IsMoreLines = true,
 
            };
            middle.AddChidren(text2Btn);
            //提示图标
            Button tipIconBtn = new Button
            {
                X = Application.GetRealWidth(109),
                Y = Application.GetRealHeight(616 - 184),
                Height = Application.GetMinRealAverage(58),
                Width = Application.GetMinRealAverage(58),
                UnSelectedImagePath = "ZigeeLogic/tipIcon.png",
            };
            middle.AddChidren(tipIconBtn);
 
            //提示文字
            Button tipTextBtn = new Button()
            {
                X = Application.GetRealWidth(173),
                Y = Application.GetRealHeight(616 - 184),
                Height = Application.GetRealHeight(138),
                Width = Application.GetRealWidth(818),
                Text = Language.StringByID(MyInternationalizationString.tipIlluminanceValue).Replace("{\\r\\n}", "\r\n"),
                TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                TextSize = 12,
                TextAlignment = TextAlignment.Center,
                IsMoreLines = true,
 
            };
            middle.AddChidren(tipTextBtn);
 
            //保存控件
            LogicView.SaveView saveView = new LogicView.SaveView();
            saveView.frameLayout.Y = middle.Height - Application.GetRealHeight(260);
            middle.AddChidren(saveView.Show());
            saveView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                var deviceConditionsInfo = new Dictionary<string, string>();
                deviceConditionsInfo.Add("Type", "1");
                deviceConditionsInfo.Add("IsValid", "1");
                deviceConditionsInfo.Add("MacAddr", common.DeviceAddr);
                deviceConditionsInfo.Add("Epoint", common.DeviceEpoint.ToString());
                deviceConditionsInfo.Add("Cluster_ID", "1024");
                deviceConditionsInfo.Add("AttriButeId", "0");
                deviceConditionsInfo.Add("AttriButeData1", horizontalSeekBarVol.Progress.ToString());
                deviceConditionsInfo.Add("AttriButeData2", "0");
                deviceConditionsInfo.Add("Range", "7");
                if (_bool && progresValue != horizontalSeekBarVol.Progress)
                {
                   
                    LogicIfon.AddDeviceconditions(common, deviceConditionsInfo);
                }
                if (!_bool)
                {
                    //不是编辑进来的;
                    LogicIfon.AddDeviceconditions(common, deviceConditionsInfo);
                }
                var logicCommunalPage = new LogicCommunalPage();
                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicCommunalPage.Show(() => { });
            };
           
            
        }
 
 
    }
}