| | |
| | | }; |
| | | bottomView.AddChidren (btnSaveTime); |
| | | btnSaveTime.MouseUpEventHandler += (sender3, e3) => { |
| | | // var chooseHour = chooseTime.Hour - timerTemp.TimeZone; |
| | | // 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"; |
| | |
| | | roomContenView.AddChidren (btnRoomChoose); |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region Devices |
| | |
| | | }; |
| | | chooseRoomView.AddChidren (roomListView); |
| | | //获取房间列表 |
| | | var roomList= mMthod.GetRoomList (); |
| | | var roomList = mMthod.GetRoomList (); |
| | | for (int i = 0; i < roomList.Count; i++) { |
| | | var room = roomList [i]; |
| | | var btnRoomNameChoose = new Button () { |
| | |
| | | } |
| | | } |
| | | if (btnSaturday.IsSelected) { |
| | | if (!timerTemp.whichDay.Contains (6)) { |
| | | if (!timerTemp.whichDay.Contains (6)) { |
| | | timerTemp.whichDay.Add (6); |
| | | } |
| | | } |
| | |
| | | if (!timerTemp.whichDay.Contains (2)) { |
| | | timerTemp.whichDay.Add (2); |
| | | } |
| | | |
| | | |
| | | } |
| | | if (btnWednesday.IsSelected) { |
| | | if (!timerTemp.whichDay.Contains (3)) { |
| | |
| | | } |
| | | } |
| | | if (string.IsNullOrEmpty (timerTemp.id)) { |
| | | timerTemp.id =Guid.NewGuid().ToString (); |
| | | timerTemp.id = Guid.NewGuid ().ToString (); |
| | | } |
| | | |
| | | DeviceDate deviceDate = new DeviceDate (); |
| | | deviceDate.gatewayId = SmartHome.Send.GatewayId; |
| | | deviceDate.homeId = SmartHome.Send.HomeId; |
| | | |
| | | |
| | | deviceDate.actions.AddRange (selectedDeviceList); |
| | | timerTemp.controlData = deviceDate; |
| | | |
| | |
| | | revertObj = SmartHome.Send.UpdateTimer (timerTemp); |
| | | |
| | | } else { |
| | | |
| | | |
| | | revertObj = SmartHome.Send.AddTimer (timerTemp); |
| | | } |
| | | |
| | |
| | | } else { |
| | | //提示错误 |
| | | SmartHome.Method method = new SmartHome.Method (); |
| | | method.ShowGetTimerListErrorInfo (revertObj.Data.ToString ()); |
| | | if (revertObj.Data != null) { |
| | | method.ShowGetTimerListErrorInfo (revertObj.Data.ToString ()); |
| | | } |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | |
| | | /// 加载房间设备列表界面 |
| | | /// </summary> |
| | | /// <param name="deviceList">房间设备列表</param> |
| | | private void InitDeviceListView (List<Function> deviceList) |
| | | private void InitDeviceListView (List<Function> deviceList) |
| | | { |
| | | devicesListView.RemoveAll (); |
| | | //房间设备列表 |
| | | devicesListView.Height = Application.GetRealHeight (130 * deviceList.Count); |
| | | devicesListView.Height = Application.GetRealHeight (130 * deviceList.Count); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | Application.RunOnMainThread (() => { |
| | | try { |
| | | string value = ""; |
| | | for (int i = 0; i < deviceList.Count; i++) { |
| | | var device = deviceList [i]; |
| | | var deviceRowView = new RowLayout () { |
| | | Y = Application.GetRealHeight (130 * i), |
| | | Radius = 1, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | | BorderWidth = (uint)Application.GetMinRealAverage (5), |
| | | Height = Application.GetRealHeight (110), |
| | | Tag = device, |
| | | }; |
| | | devicesListView.AddChidren (deviceRowView); |
| | | Application.RunOnMainThread (() => { |
| | | try { |
| | | string value = ""; |
| | | for (int i = 0; i < deviceList.Count; i++) { |
| | | var device = deviceList [i]; |
| | | var deviceRowView = new RowLayout () { |
| | | Y = Application.GetRealHeight (130 * i), |
| | | Radius = 1, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | | BorderWidth = (uint)Application.GetMinRealAverage (5), |
| | | Height = Application.GetRealHeight (110), |
| | | Tag = device, |
| | | }; |
| | | devicesListView.AddChidren (deviceRowView); |
| | | |
| | | var btnChoose = new Button () { |
| | | Width = Application.GetRealWidth (60), |
| | | Height = Application.GetRealWidth (60), |
| | | X = Application.GetRealWidth (40), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "CrabtreeAdd/Choose.png", |
| | | SelectedImagePath = "CrabtreeAdd/ChooseOn.png", |
| | | Tag = device, |
| | | }; |
| | | deviceRowView.AddChidren (btnChoose); |
| | | var btnChoose = new Button () { |
| | | Width = Application.GetRealWidth (60), |
| | | Height = Application.GetRealWidth (60), |
| | | X = Application.GetRealWidth (40), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "CrabtreeAdd/Choose.png", |
| | | SelectedImagePath = "CrabtreeAdd/ChooseOn.png", |
| | | Tag = device, |
| | | }; |
| | | deviceRowView.AddChidren (btnChoose); |
| | | |
| | | Button btnDeviceName = new Button () { |
| | | Width = Application.GetRealWidth (342), |
| | | Height = Application.GetRealHeight (70), |
| | | Text = device.name, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = btnChoose.Right + Application.GetRealWidth (10), |
| | | Y = Application.GetRealHeight (20), |
| | | SelectedTextColor = SkinStyle.Current.TextColor1, |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | }; |
| | | deviceRowView.AddChidren (btnDeviceName); |
| | | Button tempSwitch = new Button { |
| | | Width = Application.GetRealWidth (90), |
| | | Height = Application.GetRealWidth (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/SwitchClose.png", |
| | | SelectedImagePath = "Item/SwitchOpen.png", |
| | | Tag = device, |
| | | }; |
| | | deviceRowView.AddChidren (tempSwitch); |
| | | Button btnDeviceName = new Button () { |
| | | Width = Application.GetRealWidth (342), |
| | | Height = Application.GetRealHeight (70), |
| | | Text = device.name, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = btnChoose.Right + Application.GetRealWidth (10), |
| | | Y = Application.GetRealHeight (20), |
| | | SelectedTextColor = SkinStyle.Current.TextColor1, |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | }; |
| | | deviceRowView.AddChidren (btnDeviceName); |
| | | Button tempSwitch = new Button { |
| | | Width = Application.GetRealWidth (90), |
| | | Height = Application.GetRealWidth (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/SwitchClose.png", |
| | | SelectedImagePath = "Item/SwitchOpen.png", |
| | | Tag = device, |
| | | }; |
| | | deviceRowView.AddChidren (tempSwitch); |
| | | |
| | | switch (device.spk) { |
| | | //DeviceType.LightDALI |
| | | case SPK.LightDimming: { |
| | | #region 调光器A |
| | | tempSwitch.RemoveFromParent (); |
| | | switch (device.spk) { |
| | | //DeviceType.LightDALI |
| | | case SPK.LightDimming: { |
| | | #region 调光器A |
| | | tempSwitch.RemoveFromParent (); |
| | | |
| | | deviceRowView.Height = Application.GetRealHeight (130); |
| | | btnChoose.Y = Application.GetRealHeight (20); |
| | | btnDeviceName.Y = Application.GetRealHeight (15); |
| | | deviceRowView.Height = Application.GetRealHeight (130); |
| | | btnChoose.Y = Application.GetRealHeight (20); |
| | | btnDeviceName.Y = Application.GetRealHeight (15); |
| | | |
| | | var btnLevel = new Button () { |
| | | X = btnChoose.X + Application.GetRealWidth (10), |
| | | Y = btnChoose.Bottom, |
| | | Width = Application.GetRealWidth (75), |
| | | Height = Application.GetRealHeight (45), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | SelectedTextColor = SkinStyle.Current.TextColor1, |
| | | Text = "OFF", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | deviceRowView.AddChidren (btnLevel); |
| | | var btnLevel = new Button () { |
| | | X = btnChoose.X + Application.GetRealWidth (10), |
| | | Y = btnChoose.Bottom, |
| | | Width = Application.GetRealWidth (75), |
| | | Height = Application.GetRealHeight (45), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | SelectedTextColor = SkinStyle.Current.TextColor1, |
| | | Text = "OFF", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | deviceRowView.AddChidren (btnLevel); |
| | | |
| | | var levelBar = new HorizontalSeekBar () { |
| | | X = btnLevel.Right, |
| | | Y = btnLevel.Y, |
| | | Width = Application.GetRealWidth (460), |
| | | Height = Application.GetRealHeight (45), |
| | | ThumbColor = SkinStyle.Current.ThumbColor, |
| | | ProgressColor = SkinStyle.Current.SelectedColor, |
| | | ThumbRadius = 6, |
| | | Max = 100, |
| | | }; |
| | | deviceRowView.AddChidren (levelBar); |
| | | var levelBar = new HorizontalSeekBar () { |
| | | X = btnLevel.Right, |
| | | Y = btnLevel.Y, |
| | | Width = Application.GetRealWidth (460), |
| | | Height = Application.GetRealHeight (45), |
| | | ThumbColor = SkinStyle.Current.ThumbColor, |
| | | ProgressColor = SkinStyle.Current.SelectedColor, |
| | | ThumbRadius = 6, |
| | | Max = 100, |
| | | }; |
| | | deviceRowView.AddChidren (levelBar); |
| | | |
| | | levelBar.ProgressChanged += (sender, e) => { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | if (e == 0) { |
| | | btnLevel.Text = "OFF"; |
| | | } else { |
| | | btnLevel.Text = e.ToString () + "%"; |
| | | } |
| | | value = e.ToString (); |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | levelBar.ProgressChanged += (sender, e) => { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | if (e == 0) { |
| | | btnLevel.Text = "OFF"; |
| | | } else { |
| | | btnLevel.Text = e.ToString () + "%"; |
| | | } |
| | | value = e.ToString (); |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | DeviceDateFun (btnChoose.Tag as Function, "0", btnChoose.IsSelected); |
| | | }; |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | DeviceDateFun (btnChoose.Tag as Function, "0", btnChoose.IsSelected); |
| | | }; |
| | | |
| | | if (IsEdit) { |
| | | try { |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | |
| | | } |
| | | for (int a = 0; a < dev.attributes.Count; a++) { |
| | | var fundev = dev.attributes [a]; |
| | | if (fundev.value == "0") { |
| | | btnLevel.Text = "OFF"; |
| | | } else { |
| | | btnLevel.Text = fundev.value + "%"; |
| | | } |
| | | levelBar.Progress = int.Parse (fundev.value); |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | break; |
| | | //DeviceType.LightEnergySwitch |
| | | //DeviceType.LightEnergySocket |
| | | //DeviceType.LightSwitchSocket |
| | | case SPK.LightSwitch: { |
| | | #region 继电器 |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | |
| | | if (tempSwitch.IsSelected) { |
| | | value = "on"; |
| | | } else { |
| | | value = "off"; |
| | | } |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | if (btnChoose.IsSelected) { |
| | | value = "on"; |
| | | } else { |
| | | value = "off"; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | |
| | | }; |
| | | |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | for (int a = 0; a < dev.attributes.Count; a++) { |
| | | var fundev = dev.attributes [a]; |
| | | if (fundev.value == "on") { |
| | | tempSwitch.IsSelected = true; |
| | | } else { |
| | | tempSwitch.IsSelected = false; |
| | | } |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | break; |
| | | case SPK.CurtainRoller: |
| | | case SPK.CurtainTrietex: |
| | | case SPK.CurtainSwitch: |
| | | { |
| | | #region 窗帘 |
| | | tempSwitch.RemoveFromParent (); |
| | | var tempSwitch1 = new Button () { |
| | | Width = Application.GetRealWidth (90), |
| | | Height = Application.GetRealWidth (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | | BorderWidth = 1, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.Center, |
| | | BackgroundColor = SkinStyle.Current.ButtonColor, |
| | | SelectedBackgroundColor = SkinStyle.Current.SelectedColor, |
| | | Text = "CLOSE", |
| | | Tag = device, |
| | | }; |
| | | deviceRowView.AddChidren (tempSwitch1); |
| | | |
| | | tempSwitch1.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch1.IsSelected = !tempSwitch1.IsSelected; |
| | | if (tempSwitch1.IsSelected) { |
| | | value = "on"; |
| | | tempSwitch1.Text = "OPEN"; |
| | | tempSwitch1.BackgroundColor = SkinStyle.Current.SelectedColor; |
| | | } else { |
| | | value = "off"; |
| | | tempSwitch1.Text = "CLOSE"; |
| | | tempSwitch1.BackgroundColor = SkinStyle.Current.ButtonColor; |
| | | } |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | |
| | | |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | if (tempSwitch1.IsSelected) { |
| | | value = "on"; |
| | | } else { |
| | | value = "off"; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | for (int a = 0; a < dev.attributes.Count; a++) { |
| | | var fundev = dev.attributes [a]; |
| | | if (fundev.value == "on") { |
| | | tempSwitch1.IsSelected = true; |
| | | tempSwitch1.Text = "OPEN"; |
| | | } else { |
| | | tempSwitch1.IsSelected = false; |
| | | tempSwitch1.Text = "CLOSE"; |
| | | } |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | break; |
| | | case "electrical.socket": { |
| | | |
| | | } |
| | | break; |
| | | case SPK.ElectricFan: { |
| | | #region 风扇 |
| | | tempSwitch.RemoveFromParent (); |
| | | deviceRowView.Height = Application.GetRealHeight (130); |
| | | btnChoose.Y = Application.GetRealHeight (5); |
| | | btnDeviceName.Y = Application.GetRealHeight (0); |
| | | |
| | | var btnFanLevel = new Button () { |
| | | X = btnChoose.X + Application.GetRealWidth (10), |
| | | Y = btnChoose.Bottom, |
| | | Width = Application.GetRealWidth (75), |
| | | Height = Application.GetRealHeight (45), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | SelectedTextColor = SkinStyle.Current.TextColor1, |
| | | Text = "OFF", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | deviceRowView.AddChidren (btnFanLevel); |
| | | |
| | | var wi = Application.GetRealWidth (480 / 8); |
| | | for (int a = 0; a < 9; a++) { |
| | | var btnFanLevelTip = new Button () { |
| | | X = btnFanLevel.Right + wi * a - Application.GetRealWidth (0), |
| | | Y = btnFanLevel.Y - Application.GetRealHeight (5), |
| | | Width = wi, |
| | | Height = Application.GetRealHeight (27), |
| | | TextAlignment = TextAlignment.TopLeft, |
| | | Text = a.ToString (), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | TextSize = 12, |
| | | }; |
| | | deviceRowView.AddChidren (btnFanLevelTip); |
| | | if (a == 0) { |
| | | btnFanLevelTip.Text = "OFF"; |
| | | btnFanLevelTip.TextSize = 11; |
| | | } |
| | | } |
| | | |
| | | var fanLevel = new HorizontalSeekBar () { |
| | | X = btnFanLevel.Right, |
| | | Y = btnFanLevel.Y + Application.GetRealHeight (10), |
| | | Width = Application.GetRealWidth (492), |
| | | Height = Application.GetRealHeight (45), |
| | | ThumbColor = SkinStyle.Current.ThumbColor, |
| | | ProgressColor = SkinStyle.Current.SelectedColor, |
| | | ThumbRadius = Application.GetRealWidth (3), |
| | | Max = 8, |
| | | Progress = 2, |
| | | |
| | | }; |
| | | deviceRowView.AddChidren (fanLevel); |
| | | fanLevel.ProgressChanged += (sender, e) => { |
| | | value = e.ToString (); |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | DeviceDateFun (btnChoose.Tag as Function, "0", btnChoose.IsSelected); |
| | | }; |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | for (int a = 0; a < dev.attributes.Count; a++) { |
| | | var fundev = dev.attributes [a]; |
| | | if (fundev.key == "brightness") { |
| | | if (fundev.value == "0") { |
| | | //btnLevel.Text = "OFF"; |
| | | btnLevel.Text = "OFF"; |
| | | } else { |
| | | fanLevel.Progress = int.Parse (fundev.value); |
| | | btnLevel.Text = fundev.value + "%"; |
| | | } |
| | | |
| | | levelBar.Progress = int.Parse (fundev.value); |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | } catch { } |
| | | } |
| | | break; |
| | | #endregion |
| | | } |
| | | break; |
| | | //DeviceType.LightEnergySwitch |
| | | //DeviceType.LightEnergySocket |
| | | //DeviceType.LightSwitchSocket |
| | | case SPK.ElectricSocket: |
| | | case SPK.LightSwitch: { |
| | | #region 继电器 |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | |
| | | |
| | | |
| | | |
| | | if (tempSwitch.IsSelected) { |
| | | value = "on"; |
| | | } else { |
| | | value = "off"; |
| | | } |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | if (tempSwitch.IsSelected) { |
| | | value = "on"; |
| | | } else { |
| | | value = "off"; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | |
| | | }; |
| | | |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | for (int a = 0; a < dev.attributes.Count; a++) { |
| | | var fundev = dev.attributes [a]; |
| | | if (fundev.value == "on") { |
| | | tempSwitch.IsSelected = true; |
| | | } else { |
| | | tempSwitch.IsSelected = false; |
| | | } |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | break; |
| | | case SPK.CurtainRoller: |
| | | case SPK.CurtainTrietex: |
| | | case SPK.CurtainSwitch: { |
| | | #region 窗帘 |
| | | tempSwitch.RemoveFromParent (); |
| | | var tempSwitch1 = new Button () { |
| | | Width = Application.GetRealWidth (90), |
| | | Height = Application.GetRealWidth (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | | BorderWidth = 1, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.Center, |
| | | BackgroundColor = SkinStyle.Current.ButtonColor, |
| | | SelectedBackgroundColor = SkinStyle.Current.SelectedColor, |
| | | Text = "CLOSE", |
| | | Tag = device, |
| | | }; |
| | | deviceRowView.AddChidren (tempSwitch1); |
| | | |
| | | tempSwitch1.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch1.IsSelected = !tempSwitch1.IsSelected; |
| | | if (tempSwitch1.IsSelected) { |
| | | value = "on"; |
| | | tempSwitch1.Text = "OPEN"; |
| | | tempSwitch1.BackgroundColor = SkinStyle.Current.SelectedColor; |
| | | } else { |
| | | value = "off"; |
| | | tempSwitch1.Text = "CLOSE"; |
| | | tempSwitch1.BackgroundColor = SkinStyle.Current.ButtonColor; |
| | | } |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | |
| | | |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | if (tempSwitch1.IsSelected) { |
| | | value = "on"; |
| | | } else { |
| | | value = "off"; |
| | | } |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | for (int a = 0; a < dev.attributes.Count; a++) { |
| | | var fundev = dev.attributes [a]; |
| | | if (fundev.value == "on") { |
| | | tempSwitch1.IsSelected = true; |
| | | tempSwitch1.Text = "OPEN"; |
| | | } else { |
| | | tempSwitch1.IsSelected = false; |
| | | tempSwitch1.Text = "CLOSE"; |
| | | } |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | break; |
| | | case SPK.ElectricFan: { |
| | | #region 风扇 |
| | | tempSwitch.RemoveFromParent (); |
| | | deviceRowView.Height = Application.GetRealHeight (130); |
| | | btnChoose.Y = Application.GetRealHeight (5); |
| | | btnDeviceName.Y = Application.GetRealHeight (0); |
| | | |
| | | var btnFanLevel = new Button () { |
| | | X = btnChoose.X + Application.GetRealWidth (10), |
| | | Y = btnChoose.Bottom, |
| | | Width = Application.GetRealWidth (75), |
| | | Height = Application.GetRealHeight (45), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | SelectedTextColor = SkinStyle.Current.TextColor1, |
| | | Text = "OFF", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | deviceRowView.AddChidren (btnFanLevel); |
| | | |
| | | var wi = Application.GetRealWidth (480 / 8); |
| | | for (int a = 0; a < 9; a++) { |
| | | var btnFanLevelTip = new Button () { |
| | | X = btnFanLevel.Right + wi * a - Application.GetRealWidth (0), |
| | | Y = btnFanLevel.Y - Application.GetRealHeight (5), |
| | | Width = wi, |
| | | Height = Application.GetRealHeight (27), |
| | | TextAlignment = TextAlignment.TopLeft, |
| | | Text = a.ToString (), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | TextSize = 12, |
| | | }; |
| | | deviceRowView.AddChidren (btnFanLevelTip); |
| | | if (a == 0) { |
| | | btnFanLevelTip.Text = "OFF"; |
| | | btnFanLevelTip.TextSize = 11; |
| | | } |
| | | } |
| | | var fanLevel = new HorizontalSeekBar () { |
| | | X = btnFanLevel.Right, |
| | | Y = btnFanLevel.Y + Application.GetRealHeight (10), |
| | | Width = Application.GetRealWidth (492), |
| | | Height = Application.GetRealHeight (45), |
| | | ThumbColor = SkinStyle.Current.ThumbColor, |
| | | ProgressColor = SkinStyle.Current.SelectedColor, |
| | | ThumbRadius = Application.GetRealWidth (3), |
| | | Max = 8, |
| | | Progress = 2, |
| | | |
| | | }; |
| | | deviceRowView.AddChidren (fanLevel); |
| | | value = "2"; |
| | | fanLevel.ProgressChanged += (sender, e) => { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | value = e.ToString (); |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | |
| | | btnChoose.MouseUpEventHandler += (dds, ddss) => { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected); |
| | | }; |
| | | if (IsEdit) { |
| | | try { |
| | | var dev = selectedDeviceList.Find ((c) => c.deviceId == Int64.Parse (device.deviceId)); |
| | | if (dev != null) { |
| | | if (!btnChoose.IsSelected) { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | | 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); |
| | | // } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } catch { } |
| | | } |
| | | #endregion |
| | | } |
| | | break; |
| | | } |
| | | } catch (Exception ex) { |
| | | Utlis.WriteLine ("AddSchedule error : " + ex.Message); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } catch (Exception ex) { |
| | | Utlis.WriteLine ("AddSchedule error : " + ex.Message); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } catch (Exception ex) { |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | |
| | | /// <param name="function"></param> |
| | | /// <param name="value">开关状态值</param> |
| | | /// <param name="isSelected">判断控件点击状态</param> |
| | | public void DeviceDateFun (Function function, string value, bool isSelected) |
| | | public void DeviceDateFun (Function function, string value, bool isSelected) |
| | | { |
| | | string keyValue = ""; |
| | | switch (function.spk) { |
| | | case "curtain.trietex": |
| | | case "curtain.roller": |
| | | case "light.switch": |
| | | case "curtain.switch": |
| | | case "electrical.socket": { |
| | | case SPK.CurtainTrietex: |
| | | case SPK.CurtainRoller: |
| | | case SPK.LightSwitch: |
| | | case SPK.CurtainSwitch: |
| | | case SPK.ElectricSocket: { |
| | | keyValue = "on_off"; |
| | | } |
| | | break; |
| | | case "light.dimming": { |
| | | case SPK.LightDimming: { |
| | | keyValue = "brightness"; |
| | | } |
| | | break; |
| | | case SPK.ElectricFan: { |
| | | keyValue = "fan_speed_percent"; |
| | | } |
| | | break; |
| | | |
| | |
| | | Fun fun = new Fun (); |
| | | fun.deviceId = Int64.Parse (function.deviceId); |
| | | fun.spk = function.spk; |
| | | fun.attributes.Add (new Attributes { key= keyValue, value = value }); |
| | | fun.attributes.Add (new Attributes { key = keyValue, value = value }); |
| | | fun.bus.addresses = function.bus.addresses; |
| | | fun.bus.loopId = function.bus.loopId; |
| | | AddDeviceList (fun, isSelected); |
| | |
| | | /// </summary> |
| | | /// <param name="fun"></param> |
| | | /// <param name="isSelected">判断控件点击状态</param> |
| | | public void AddDeviceList (Fun fun, bool isSelected) |
| | | public void AddDeviceList (Fun fun, bool isSelected) |
| | | { |
| | | |
| | | switch (fun.spk) { |
| | | case SPK.LightDimming: { |
| | | //调光做了一个特殊处理; |
| | | if (fun.attributes.Count == 1) { |
| | | var dic = fun.attributes [0]; |
| | | if (dic.key == "brightness") { |
| | | Attributes attributes = new Attributes (); |
| | | attributes.key = "on_off"; |
| | | if (dic.value == "0") { |
| | | attributes.value = "off"; |
| | | } else { |
| | | attributes.value = "on"; |
| | | } |
| | | fun.attributes.Add (attributes); |
| | | } |
| | | |
| | | } |
| | | break; |
| | | } |
| | | case SPK.ElectricFan: { |
| | | if (fun.attributes.Count == 1) { |
| | | var dic = fun.attributes [0]; |
| | | if (dic.key == "fan_speed_percent") { |
| | | Attributes attributes = new Attributes (); |
| | | attributes.key = "on_off"; |
| | | if (dic.value == "0") { |
| | | attributes.value = "off"; |
| | | } else { |
| | | attributes.value = "on"; |
| | | } |
| | | fun.attributes.Add (attributes); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | var device = selectedDeviceList.Find ((dev) => dev.deviceId == fun.deviceId); |
| | | if (device != null) { |
| | | selectedDeviceList.Remove (device); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |