From eb3799496f3419e347849073e23e5105b74000e5 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 26 三月 2021 17:41:18 +0800
Subject: [PATCH] 2021-3-26-4
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs | 268 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 202 insertions(+), 66 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
index 6c0c602..fd52b68 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
@@ -1,5 +1,6 @@
锘縰sing System;
using System.Collections.Generic;
+using Newtonsoft.Json.Linq;
using Shared.SimpleControl.Phone.Music;
namespace Shared.SimpleControl.Phone
@@ -176,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
@@ -446,7 +451,7 @@
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.CenterLeft,
TextColor = SkinStyle.Current.TextColor1,
- Text = "ALL",
+ Text = timerTemp.RoomName,
};
roomContenView.AddChidren (btnRoomChoose);
@@ -480,7 +485,7 @@
MainPage.Loading.Start ("Please wait...");
SmartHome.Method mMthod = new SmartHome.Method ();
- var devList = mMthod.GetRoomDeviceList ("ALL");
+ var devList = mMthod.GetRoomDeviceList (timerTemp.RoomName);
InitDeviceListView (devList);
#region -----Room 鐐瑰嚮浜嬩欢
btnRoomChoose.MouseUpEventHandler += (sender, e) => {
@@ -535,6 +540,8 @@
roomListView.AddChidren (btnLine);
btnRoomNameChoose.MouseUpEventHandler += (sd, ds) => {
+ //鍒囨崲鎴块棿娓呯┖涔嬪墠閫夋嫨鏁版嵁;
+ selectedDeviceList.Clear ();
btnRoomChoose.Text = (sd as Button).Text;
//鑾峰彇璁惧鍒楄〃
var deviceList = mMthod.GetRoomDeviceList (btnRoomChoose.Text);
@@ -666,9 +673,9 @@
timerTemp.whichDay.Add (5);
}
}
- if (string.IsNullOrEmpty (timerTemp.id)) {
- timerTemp.id = Guid.NewGuid ().ToString ();
- }
+ //if (string.IsNullOrEmpty (timerTemp.id)) {
+ // timerTemp.id = Guid.NewGuid ().ToString ();
+ //}
DeviceDate deviceDate = new DeviceDate ();
deviceDate.gatewayId = SmartHome.Send.GatewayId;
@@ -698,8 +705,17 @@
if (revertObj == null) {
new Alert ("", "Unable to save data, please check the network.", "Close").Show ();
} else if (revertObj.Code == StateCode.SUCCESS) {
+ string id = "";
+ if (!isEdit) {
+ var jObject = JObject.Parse (revertObj.Data.ToString ());
+ id = jObject ["id"].ToString ();
+ timerTemp.id = id;
+ }
this.RemoveFromParent ();
action (timerTemp);
+
+
+
} else {
//鎻愮ず閿欒
SmartHome.Method method = new SmartHome.Method ();
@@ -719,6 +735,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>
@@ -995,6 +1127,7 @@
TextColor = SkinStyle.Current.TextColor1,
SelectedTextColor = SkinStyle.Current.TextColor1,
Text = "OFF",
+ //Text = "",
TextAlignment = TextAlignment.CenterLeft,
};
deviceRowView.AddChidren (btnFanLevel);
@@ -1036,6 +1169,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);
};
@@ -1053,15 +1191,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