JLChen
2020-05-28 04bd96cbf5d12a4e4b116d2b05fd0d05ea81ee23
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
203
204
205
206
207
208
209
210
211
212
//using System;
//namespace Shared.SimpleControl.Phone
//{
//    public class UserSensorSettingTempPushDialog
//    {
//        string TriggerTemp = "";
//        public UserSensorSettingTempPushDialog ()
//        {
//            TriggerTemp = Language.StringByID (R.MyInternationalizationString.TriggerTemp);
//        }
 
 
//        public void ShowSettingTempPushDialog (Sensor device, byte targetPushLoopId, byte [] pushEnableRevertBytes, Button btn)
//        {
//            MainPage.Loading.Start ("Loading...");
//            System.Threading.Tasks.Task.Run (() => {
//                try {
//                    var pushRevertBytes = Control.ControlBytesSendHasReturn (Command.ReadSensorPushMessage, device.SubnetID, device.DeviceID, new byte [] { device.DevicePushType, device.LoopID, 255 });
//                    System.Collections.Generic.List<byte []> pushTempList = new System.Collections.Generic.List<byte []> ();
//                    Application.RunOnMainThread (() => {
//                        if (pushRevertBytes == null) {
//                            new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
//                            pushRevertBytes = new byte [27];
//                            return;
//                        }
//                        Dialog dialog = new Dialog ();
 
//                        FrameLayout bodyView = new FrameLayout () {
//                            BackgroundColor = SkinStyle.Current.DialogColor,
//                            Gravity = Gravity.Center,
//                            Width = Application.GetRealWidth (550),
//                            Height = Application.GetRealHeight (450),
//                        };
//                        dialog.AddChidren (bodyView);
 
//                        Button btnDialogTitle = new Button () {
//                            Height = Application.GetRealHeight (100),
//                            TextID = R.MyInternationalizationString.Overheat,
//                            TextColor = SkinStyle.Current.TextColor1,
//                            BackgroundColor = SkinStyle.Current.DialogTitle,
//                            TextAlignment = TextAlignment.Center,
//                        };
//                        bodyView.AddChidren (btnDialogTitle);
//                        if (targetPushLoopId == 1) {
//                            btnDialogTitle.TextID = R.MyInternationalizationString.Overcooling;
//                        }
 
 
//                        //for (int i = targetPushLoopId; i < targetPushLoopId + 4; i++) {
//                        int pushTemp = 0;
//                        var pushValuesRevertBytes = Control.ControlBytesSendHasReturn (Command.ReadSensorPushValues, device.SubnetID, device.DeviceID, new byte [] { device.DevicePushType, (byte)targetPushLoopId });
//                        if (pushValuesRevertBytes == null) {
//                            pushValuesRevertBytes = new byte [] { device.DevicePushType, (byte)targetPushLoopId, 0, 0, 0, 255 };
//                        }
//                        if (targetPushLoopId == 0) {
//                            pushTemp = pushValuesRevertBytes [4] * 256 + pushValuesRevertBytes [5];
//                        } else {
//                            pushTemp = pushValuesRevertBytes [2] * 256 + pushValuesRevertBytes [3];
//                        }
//                        pushTempList.Add (pushValuesRevertBytes);
 
//                        FrameLayout setTargetTemp1View = new FrameLayout () {
//                            Y = Application.GetRealHeight (140),
//                            BackgroundColor = SkinStyle.Current.DialogColor,
//                            Height = Application.GetRealHeight (200),
//                        };
//                        bodyView.AddChidren (setTargetTemp1View);//40448
//                        string setTemp = (pushTemp > 32768 ? ((32768 - pushTemp) / 10).ToString () : ((pushTemp / 10).ToString ())) + "°";
//                        Button btnTip = new Button () {
//                            X = Application.GetRealWidth (30),
//                            Width = Application.GetRealWidth (300),
//                            Height = Application.GetRealHeight (80),
//                            TextColor = SkinStyle.Current.TextColor,
//                            TextAlignment = TextAlignment.CenterLeft,
//                        };
//                        setTargetTemp1View.AddChidren (btnTip);
//                        if (targetPushLoopId == 0) {
//                            btnTip.Text = TriggerTemp + ":> " + setTemp;
//                        } else {
//                            btnTip.Text = TriggerTemp + ":< " + setTemp;
//                        }
 
//                        Button btnMin = new Button () {
//                            X = Application.GetRealWidth (25),
//                            Gravity = Gravity.CenterVertical,
//                            Width = Application.GetRealWidth (60),
//                            Text = "-20",
//                            TextColor = SkinStyle.Current.TextColor,
//                            TextAlignment = TextAlignment.CenterLeft
//                        };
//                        setTargetTemp1View.AddChidren (btnMin);
 
//                        var tempSeekBarFrame = new FrameLayout () {
//                            Width = Application.GetRealWidth (550 - 160),
//                            Height = Application.GetRealHeight (80),
//                            X = Application.GetRealWidth (10) + btnMin.Right,
//                            Gravity = Gravity.CenterVertical
//                        };
//                        setTargetTemp1View.AddChidren (tempSeekBarFrame);
//                        var horizontalSeekBar = new HorizontalSeekBar () {
//                            ThumbColor = SkinStyle.Current.SelectedColor,
//                            Max = 60,
//                            Progress = (pushTemp > 32768 ? ((pushTemp - 32768) / 10) : ((pushTemp / 10))) + 20,
//                        };
//                        tempSeekBarFrame.AddChidren (horizontalSeekBar);
//                        Button btnMax = new Button () {
//                            Width = Application.GetRealWidth (90),
//                            Height = Application.GetRealHeight (80),
//                            X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
//                            Gravity = Gravity.CenterVertical,
//                            Text = "40",
//                            TextAlignment = TextAlignment.CenterLeft,
//                            TextColor = SkinStyle.Current.TextColor
//                        };
//                        setTargetTemp1View.AddChidren (btnMax);
//                        if (targetPushLoopId == 0) {
//                            horizontalSeekBar.ProgressColor = 0xFFCADBE1;
//                            horizontalSeekBar.BackgroundColor = 0xFFFF0000;
//                        } else {
//                            horizontalSeekBar.BackgroundColor = 0xFFCADBE1;
//                            horizontalSeekBar.ProgressColor = 0xFF6BDFFE;
//                        }
//                        horizontalSeekBar.ProgressChanged += (sender22, e4) => {
//                            if (targetPushLoopId == 0) {
//                                btnTip.Text = TriggerTemp + ":> " + (horizontalSeekBar.Progress - 20) + "°";
//                            } else {
//                                btnTip.Text = TriggerTemp + ":< " + (horizontalSeekBar.Progress - 20) + "°";
//                            }
//                            if (20 > e4) {
//                                pushTemp = (20 - e4) * 10 + 32768;
//                            } else {
//                                pushTemp = (e4 - 20) * 10;
//                            }
//                        };
//                        horizontalSeekBar.MouseUpEventHandler += (asss, ddd) => {
//                            if (targetPushLoopId == 0) {
//                                pushValuesRevertBytes [2] = 32768 / 256;
//                                pushValuesRevertBytes [3] = 32768 % 256;
//                                pushValuesRevertBytes [4] = (byte)(pushTemp / 256);
//                                pushValuesRevertBytes [5] = (byte)(pushTemp % 256);
//                            } else {
//                                pushValuesRevertBytes [2] = (byte)(pushTemp / 256);
//                                pushValuesRevertBytes [3] = (byte)(pushTemp % 256);
//                                pushValuesRevertBytes [4] = 1250 / 256;
//                                pushValuesRevertBytes [5] = 1250 % 256;
//                            }
//                        };
 
//                        Button btnClose = new Button () {
//                            Y = bodyView.Height - Application.GetRealHeight (110),
//                            Width = Application.GetRealWidth (275),
//                            Height = Application.GetRealHeight (110),
//                            TextID = R.MyInternationalizationString.Close,
//                            TextColor = SkinStyle.Current.TextColor1,
//                            BackgroundColor = SkinStyle.Current.DialogTitle,
//                        };
//                        bodyView.AddChidren (btnClose);
//                        btnClose.MouseUpEventHandler += (kkk, ddd) => {
//                            dialog.Close ();
//                        };
 
//                        Button btnSave = new Button () {
//                            Y = btnClose.Y,
//                            X = btnClose.Right + 1,
//                            Width = Application.GetRealWidth (280),
//                            Height = btnClose.Height,
//                            TextID = R.MyInternationalizationString.SAVE,
//                            TextColor = SkinStyle.Current.TextColor1,
//                            BackgroundColor = SkinStyle.Current.DialogTitle,
//                        };
//                        bodyView.AddChidren (btnSave);
//                        btnSave.MouseUpEventHandler += (kkk, ddd) => {
//                            MainPage.Loading.Start ("Saving...");
//                            System.Threading.Tasks.Task.Run (() => {
//                                try {
//                                    foreach (var sendPushBytes in pushTempList) {
//                                        var setPushValuesACK = Control.ControlBytesSendHasReturn (Command.SetSensorPushValues, device.SubnetID, device.DeviceID, sendPushBytes);
//                                        if (setPushValuesACK == null) {
//                                            Application.RunOnMainThread (() => {
//                                                new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TargetsSetFail), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
//                                            });
//                                        } else {
//                                            Application.RunOnMainThread (() => {
//                                                dialog.Close ();
//                                            });
//                                        }
//                                    }
//                                } catch { } finally {
//                                    Application.RunOnMainThread (() => {
//                                                    setTemp = (pushTemp > 32768 ? ((32768 - pushTemp) / 10).ToString () : ((pushTemp / 10).ToString ())) + "°";
//                                        if (targetPushLoopId == 0) {
//                                            btn.Text = Language.StringByID (R.MyInternationalizationString.TriggerTemp) + ":> " + setTemp;
//                                        } else {
//                                            btn.Text = Language.StringByID (R.MyInternationalizationString.TriggerTemp) + ":< " + setTemp;
//                                        }
//                                        MainPage.Loading.Hide ();
//                                    });
//                                }
//                            });
//                        };
 
//                        dialog.Show ();
//                    });
//                } catch { } finally {
//                    Application.RunOnMainThread (() => {
//                        MainPage.Loading.Hide ();
//                    });
//                }
//            });
//        }
//    }
//}