From d878a20366ed2aa0cf3a8e0a560441d1ff5f07af Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 26 三月 2021 14:14:53 +0800
Subject: [PATCH] Merge branch 'master' into wjc

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs |  246 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 185 insertions(+), 61 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
index e96a79f..5fcefb0 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
@@ -177,65 +177,69 @@
             timeView.AddChidren (btnTimelbl);
 
             btnTimelbl.MouseUpEventHandler += (timeSender, eee) => {
-                var dialog = new Dialog ();
-                var chooseTimeBodyView = new FrameLayout () {
-                };
-                dialog.AddChidren (chooseTimeBodyView);
 
-                var chooseTime = new TimeView () {
-                    Y = Application.GetRealHeight (1136 - 420 - 90),
-                    Height = Application.GetRealHeight (420),
-                    BackgroundColor = 0xFFD7D7D7,
-                    //BackgroundColor = SkinStyle.Current.ViewColor,
-                };
-                chooseTimeBodyView.AddChidren (chooseTime);
+                ShowTimePickerView (btnTimelbl);
+                return;
 
-                var bottomView = new FrameLayout () {
-                    Y = chooseTime.Bottom,
-                    Height = Application.GetRealHeight (90) + 1,
-                    BackgroundColor = 0xFFD7D7D7,
-                };
-                chooseTimeBodyView.AddChidren (bottomView);
+                //var dialog = new Dialog ();
+                //var chooseTimeBodyView = new FrameLayout () {
+                //};
+                //dialog.AddChidren (chooseTimeBodyView);
 
-                var btnCloseTime = new Button () {
-                    Y = 1,
-                    Width = Application.GetRealWidth (320),
-                    BackgroundColor = SkinStyle.Current.ViewColor,
-                    TextID = R.MyInternationalizationString.Close,
-                    TextAlignment = TextAlignment.Center,
-                    TextColor = SkinStyle.Current.TextColor1,
-                };
-                bottomView.AddChidren (btnCloseTime);
-                btnCloseTime.MouseUpEventHandler += (ddf, dddf) => {
-                    chooseTimeBodyView.RemoveAll ();
-                    chooseTimeBodyView.RemoveFromParent ();
-                    dialog.Close ();
-                };
+                //var chooseTime = new TimeView () {
+                //    Y = Application.GetRealHeight (1136 - 420 - 90),
+                //    Height = Application.GetRealHeight (420),
+                //    BackgroundColor = 0xFFD7D7D7,
+                //    //BackgroundColor = SkinStyle.Current.ViewColor,
+                //};
+                //chooseTimeBodyView.AddChidren (chooseTime);
 
-                var btnSaveTime = new Button () {
-                    X = btnCloseTime.Right + 1,
-                    Y = 1,
-                    Width = Application.GetRealWidth (320),
-                    TextID = R.MyInternationalizationString.SAVE,
-                    BackgroundColor = SkinStyle.Current.ViewColor,
-                    TextAlignment = TextAlignment.Center,
-                    TextColor = SkinStyle.Current.TextColor1,
-                };
-                bottomView.AddChidren (btnSaveTime);
-                btnSaveTime.MouseUpEventHandler += (sender3, e3) => {
-                    // var chooseHour = chooseTime.Hour - timerTemp.TimeZone;
-                    var chooseTimeString = chooseTime.Hour.ToString ().PadLeft (2, '0') + ":" + chooseTime.Minute.ToString ().PadLeft (2, '0');
-                    //if (chooseTime.Hour > 12) {
-                    //    chooseTimeString = (chooseTime.Hour -12) + ":" + chooseTime.Minute + " PM";
-                    //} else {
-                    //    chooseTimeString = chooseTime.Hour + ":" + chooseTime.Minute + " AM";
-                    //}
-                    btnTimelbl.Text = chooseTimeString;
-                    dialog.Close ();
-                };
+                //var bottomView = new FrameLayout () {
+                //    Y = chooseTime.Bottom,
+                //    Height = Application.GetRealHeight (90) + 1,
+                //    BackgroundColor = 0xFFD7D7D7,
+                //};
+                //chooseTimeBodyView.AddChidren (bottomView);
+
+                //var btnCloseTime = new Button () {
+                //    Y = 1,
+                //    Width = Application.GetRealWidth (320),
+                //    BackgroundColor = SkinStyle.Current.ViewColor,
+                //    TextID = R.MyInternationalizationString.Close,
+                //    TextAlignment = TextAlignment.Center,
+                //    TextColor = SkinStyle.Current.TextColor1,
+                //};
+                //bottomView.AddChidren (btnCloseTime);
+                //btnCloseTime.MouseUpEventHandler += (ddf, dddf) => {
+                //    chooseTimeBodyView.RemoveAll ();
+                //    chooseTimeBodyView.RemoveFromParent ();
+                //    dialog.Close ();
+                //};
+
+                //var btnSaveTime = new Button () {
+                //    X = btnCloseTime.Right + 1,
+                //    Y = 1,
+                //    Width = Application.GetRealWidth (320),
+                //    TextID = R.MyInternationalizationString.SAVE,
+                //    BackgroundColor = SkinStyle.Current.ViewColor,
+                //    TextAlignment = TextAlignment.Center,
+                //    TextColor = SkinStyle.Current.TextColor1,
+                //};
+                //bottomView.AddChidren (btnSaveTime);
+                //btnSaveTime.MouseUpEventHandler += (sender3, e3) => {
+                //    // var chooseHour = chooseTime.Hour - timerTemp.TimeZone;
+                //    var chooseTimeString = chooseTime.Hour.ToString ().PadLeft (2, '0') + ":" + chooseTime.Minute.ToString ().PadLeft (2, '0');
+                //    //if (chooseTime.Hour > 12) {
+                //    //    chooseTimeString = (chooseTime.Hour -12) + ":" + chooseTime.Minute + " PM";
+                //    //} else {
+                //    //    chooseTimeString = chooseTime.Hour + ":" + chooseTime.Minute + " AM";
+                //    //}
+                //    btnTimelbl.Text = chooseTimeString;
+                //    dialog.Close ();
+                //};
 
 
-                dialog.Show ();
+                //dialog.Show ();
             };
             #endregion
 
@@ -729,6 +733,122 @@
             };
 
         }
+
+        /// <summary>
+        /// 鑷畾涔塗imePickerView
+        /// 2021-03-24
+        /// </summary>
+        void ShowTimePickerView (Button btnTimelbl)
+        {
+            var chooseTimeString = "00:00";
+            var dialog = new Dialog ();
+            var chooseTimeBodyView = new FrameLayout () {
+            };
+            dialog.AddChidren (chooseTimeBodyView);
+
+            var timeView = new FrameLayout () {
+                Y = Application.GetRealHeight (1136 - 420 - 90),
+                Height = Application.GetRealHeight (420),
+                BackgroundColor = SkinStyle.Current.ViewColor,
+            };
+            chooseTimeBodyView.AddChidren (timeView);
+
+            var chooseTime = new UIPickerView () {
+                Height = Application.GetRealHeight (400),
+                BackgroundColor = SkinStyle.Current.Transparent,
+                Gravity = Gravity.CenterVertical
+            };
+            timeView.AddChidren (chooseTime);
+
+            var bottomView = new FrameLayout () {
+                Y = timeView.Bottom,
+                Height = Application.GetRealHeight (90) + 1,
+                BackgroundColor = 0xFFD7D7D7,
+            };
+            chooseTimeBodyView.AddChidren (bottomView);
+
+            var btnCloseTime = new Button () {
+                Y = 1,
+                Width = Application.GetRealWidth (320),
+                BackgroundColor = SkinStyle.Current.ViewColor,
+                TextID = R.MyInternationalizationString.Close,
+                TextAlignment = TextAlignment.Center,
+                TextColor = SkinStyle.Current.TextColor1,
+            };
+            bottomView.AddChidren (btnCloseTime);
+            btnCloseTime.MouseUpEventHandler += (ddf, dddf) => {
+                chooseTimeBodyView.RemoveAll ();
+                chooseTimeBodyView.RemoveFromParent ();
+                dialog.Close ();
+            };
+
+            var btnSaveTime = new Button () {
+                X = btnCloseTime.Right + 1,
+                Y = 1,
+                Width = Application.GetRealWidth (320),
+                TextID = R.MyInternationalizationString.SAVE,
+                BackgroundColor = SkinStyle.Current.ViewColor,
+                TextAlignment = TextAlignment.Center,
+                TextColor = SkinStyle.Current.TextColor1,
+            };
+            bottomView.AddChidren (btnSaveTime);
+            btnSaveTime.MouseUpEventHandler += (sender3, e3) => {
+                btnTimelbl.Text = chooseTimeString;
+                dialog.Close ();
+            };
+
+            var nowDateTime = DateTime.Now;
+            var hour = nowDateTime.Hour;
+            //hourStr
+            var hourStr = hour.ToString();
+            if (hour < 10) {
+                hourStr = "0" + hour;
+            }
+
+            var minute = nowDateTime.Minute;
+            //minuteStr
+            var minuteStr = minute.ToString ();
+            if (minute < 10) {
+                minuteStr = "0" + minute;
+            }
+            var hourList = new List<string> ();
+            for (int i = 0; i < 24; i++) {
+                if (i < 10) {
+                    var a = "0" + i.ToString ();
+                    hourList.Add (a);
+                } else {
+                    hourList.Add (i.ToString ());
+                }
+
+            }
+
+            var minuteList = new List<string> ();
+            for (int i = 0; i < 60; i++) {
+                if (i < 10) {
+                    var a = "0" + i.ToString ();
+                    minuteList.Add (a);
+                } else {
+                    minuteList.Add (i.ToString ());
+                }
+
+            }
+
+            chooseTime.setNPicker (hourList, minuteList, null);
+            chooseTime.setCurrentItems (hour, minute, 0);
+            chooseTimeString = hourStr + ":" + minuteStr;
+
+            //string selectde = "";
+            chooseTime.OnSelectChangeEvent += (s1, s2, s3) => {
+                var hourV = hourList [s1];
+                var minuteV = minuteList [s2];
+                chooseTimeString = hourV + ":" + minuteV;
+
+            };
+
+            dialog.Show ();
+
+        }
+
         /// <summary>
         /// 鍔犺浇鎴块棿璁惧鍒楄〃鐣岄潰
         /// </summary>
@@ -1005,6 +1125,7 @@
                                             TextColor = SkinStyle.Current.TextColor1,
                                             SelectedTextColor = SkinStyle.Current.TextColor1,
                                             Text = "OFF",
+                                            //Text = "",
                                             TextAlignment = TextAlignment.CenterLeft,
                                         };
                                         deviceRowView.AddChidren (btnFanLevel);
@@ -1046,6 +1167,11 @@
                                                 btnChoose.IsSelected = true;
                                             }
                                             value = e.ToString ();
+                                            if (value == "0") {
+                                                btnFanLevel.Text = "OFF";
+                                            } else {
+                                                btnFanLevel.Text = value;
+                                            }
                                             DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected);
                                         };
 
@@ -1063,15 +1189,13 @@
                                                     for (int a = 0; a < dev.attributes.Count; a++) {
                                                         var fundev = dev.attributes [a];
                                                         if (fundev.key == "fan_speed_percent") {
-                                                           // if (fundev.value == "0") {
-                                                              //  btnLevel.Text = "OFF";
-                                                          //  } else {
-                                                                fanLevel.Progress = int.Parse (fundev.value);
-                                                           // }
+                                                            fanLevel.Progress = int.Parse (fundev.value);
+                                                            if (fundev.value == "0") {
+                                                                btnFanLevel.Text = "OFF";
+                                                            } else {
+                                                                btnFanLevel.Text = fundev.value;
+                                                            }
                                                         }
-
-                                                       
-
                                                     }
                                                 }
                                             } catch { }

--
Gitblit v1.8.0