| | |
| | | using System; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.Light |
| | |
| | | ///// </summary> |
| | | private CommonForm.TopFrameLayout top; |
| | | /// <summary> |
| | | /// 更多设置 |
| | | /// </summary> |
| | | private Button moreBtn; |
| | | /// <summary> |
| | | /// 传过来的设备 |
| | | /// </summary> |
| | | private DeviceUI device; |
| | |
| | | /// </summary> |
| | | private Shared.Common.Room room; |
| | | /// <summary> |
| | | /// The middle fl. |
| | | /// bodyFrameLayout |
| | | /// </summary> |
| | | private FrameLayout midFL; |
| | | private FrameLayout bodyFrameLayout; |
| | | /// <summary> |
| | | /// 收藏按钮 |
| | | /// </summary> |
| | | private Button collectionBtn; |
| | | /// <summary> |
| | | /// 设备是否在线标识--Online |
| | | /// </summary> |
| | | private readonly string DeviceStatus_Online = "Online"; |
| | | /// <summary> |
| | | /// 设备状态开关标识--Switch |
| | | /// </summary> |
| | | private readonly string DeviceStatus_OnOffStatus = "Switch"; |
| | | /// <summary> |
| | | /// The light image. |
| | | /// </summary> |
| | | private Button deviceIMG; |
| | | |
| | | /// <summary> |
| | | /// 开关 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 滑条 |
| | | /// </summary> |
| | | private HorizontalSeekBar levelSeekBar; |
| | | /// <summary> |
| | | /// 延时 300毫秒 |
| | | /// </summary> |
| | | private int sleepSpan = 300; |
| | | private WaveSeekBar levelSeekBar; |
| | | |
| | | |
| | | private Button StatuBtn; |
| | | /// <summary> |
| | | /// 房间 |
| | | /// </summary> |
| | | private Button roomBtn; |
| | | /// <summary> |
| | | /// 房间名 |
| | | /// </summary> |
| | | private Button roomName; |
| | | /// <summary> |
| | | /// MaxLevel |
| | | /// </summary> |
| | | private const int MaxLevel = 254; |
| | | #endregion |
| | | |
| | | #region ◆ 接口__________________________ |
| | |
| | | } |
| | | dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | switchBtn.IsSelected = dimmableLight.OnOffStatus == 1; |
| | | StatuBtn.Text = CommonFormResouce.GetSwitchStatu(switchBtn.IsSelected); |
| | | if (switchBtn.IsSelected == true) |
| | | { |
| | | levelSeekBar.IsClickable = true; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; |
| | | } |
| | | else |
| | | { |
| | | levelSeekBar.IsClickable = false; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; |
| | | } |
| | | //change color |
| | | dimmableLight.LastDateTime = DateTime.Now; |
| | | } |
| | | //亮度 |
| | |
| | | //此属性表明当前亮度程度 |
| | | dimmableLight.Level = attriButeList[0].AttriButeData; |
| | | dimmableLight.LastDateTime = DateTime.Now; |
| | | levelSeekBar.Progress = dimmableLight.Level; |
| | | levelSeekBar.Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100); |
| | | break; |
| | | } |
| | | } |
| | | //***新改***设备状态上报中,当CluterID=3,证明设备在线,直接标记 |
| | | else if ((common as DimmableLight).DeviceStatusReport.CluterID == 3) |
| | | { |
| | | dimmableLight = deviceUI.CommonDevice as DimmableLight; |
| | | dimmableLight.IsOnline = 1; |
| | | deviceIMG.IsSelected = dimmableLight.IsOnline == 1; |
| | | dimmableLight.LastDateTime = DateTime.Now; |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | else if (typeTag == "OnlineStatusChange") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | var deviceUI = device; |
| | | //设备为空 |
| | | if (deviceUI.CommonDevice == null) |
| | | { |
| | | return; |
| | | } |
| | | //是否为当前设备 |
| | | if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) |
| | | { |
| | | return; |
| | | } |
| | | if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight) |
| | | { |
| | | dimmableLight = deviceUI.CommonDevice as DimmableLight; |
| | | dimmableLight.IsOnline = (common as DimmableLight).IsOnline; |
| | | deviceIMG.IsSelected = dimmableLight.IsOnline == 1; |
| | | dimmableLight.LastDateTime = DateTime.Now; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"Error:{ex.Message}"); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | public DimmableLightControl() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | ZbGateway.StatusList.Add(this); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | /// <param name="room">Room.</param> |
| | | public void Show(DeviceUI device, Shared.Common.Room room) |
| | | { |
| | | ZbGateway.StatusList.Add(this); |
| | | this.device = device; |
| | | this.room = room; |
| | | this.dimmableLight = device.CommonDevice as ZigBee.Device.DimmableLight; |
| | |
| | | //添加topview |
| | | AddTopView(); |
| | | //添加midview |
| | | AddMidview(); |
| | | AddBodyView(this.device); |
| | | //绑定事件 |
| | | BindEvent(); |
| | | //收藏 |
| | |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | AddMoreview(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Adds the moreview. |
| | | /// </summary> |
| | | private void AddMoreview() |
| | | { |
| | | moreBtn = new CommonForm.SelectedStatuButton() |
| | | var sharedBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(CommonPage.AppRealWidth - 150), |
| | | Width = Application.GetMinReal(110), |
| | | Height = Application.GetMinReal(110), |
| | | X = Application.GetRealWidth(850), |
| | | Width = Application.GetMinReal(69), |
| | | Height = Application.GetMinReal(69), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/More.png", |
| | | SelectedImagePath = "Item/MoreSelected.png", |
| | | UnSelectedImagePath = "Item/Shared.png" |
| | | }; |
| | | top.topView.AddChidren(sharedBtn); |
| | | |
| | | var moreBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(953), |
| | | Width = Application.GetMinReal(69), |
| | | Height = Application.GetMinReal(69), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/More.png" |
| | | }; |
| | | top.topView.AddChidren(moreBtn); |
| | | |
| | | moreBtn.MouseUpEventHandler += MoreEvent; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更多设置 |
| | | /// </summary> |
| | |
| | | #region ◆ midview_______________________ |
| | | |
| | | /// <summary> |
| | | /// Adds the midview. |
| | | /// AddBodyView |
| | | /// </summary> |
| | | private void AddMidview() |
| | | public void AddBodyView(DeviceUI device) |
| | | { |
| | | midFL = new FrameLayout() |
| | | bodyFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), |
| | | Y = top.Bottom, |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | Y = Application.GetRealHeight(184), |
| | | Height = Application.GetRealHeight(1737), |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, |
| | | }; |
| | | AddChidren(midFL); |
| | | AddChidren(bodyFrameLayout); |
| | | |
| | | AddItemview(); |
| | | } |
| | |
| | | Y = Application.GetRealHeight(115), |
| | | Width = Application.GetRealWidth(965), |
| | | Height = Application.GetRealHeight(1316), |
| | | Radius = CommonPage.BigFormRadius, |
| | | Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | midFL.AddChidren(itemView); |
| | | var deviceView = new FrameLayout() |
| | | { |
| | | X = 2, |
| | | Y = 2, |
| | | Width = itemView.Width - 4, |
| | | Height = itemView.Height - Application.GetRealHeight(138), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | Tag = device |
| | | }; |
| | | itemView.AddChidren(deviceView); |
| | | bodyFrameLayout.AddChidren(itemView); |
| | | |
| | | collectionBtn = new Button() |
| | | { |
| | | X = deviceView.Width - Application.GetRealWidth(130), |
| | | Y = Application.GetRealHeight(20), |
| | | Width = Application.GetMinReal(110), |
| | | Height = Application.GetMinReal(110), |
| | | X = Application.GetRealWidth(850), |
| | | Y = Application.GetRealHeight(46), |
| | | Width = Application.GetMinReal(69), |
| | | Height = Application.GetMinReal(69), |
| | | UnSelectedImagePath = "Item/Collection.png", |
| | | SelectedImagePath = "Item/CollectionSelected.png" |
| | | }; |
| | | deviceView.AddChidren(collectionBtn); |
| | | itemView.AddChidren(collectionBtn); |
| | | |
| | | deviceIMG = new Button() |
| | | var deviceNameBtn = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(100), |
| | | Height = Application.GetMinRealAverage(240), |
| | | Width = Application.GetMinRealAverage(240), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = device.IconPath, |
| | | SelectedImagePath = device.OnlineIconPath, |
| | | IsSelected = dimmableLight.IsOnline == 1, |
| | | Tag = DeviceStatus_Online |
| | | }; |
| | | deviceView.AddChidren(deviceIMG); |
| | | |
| | | var lightName = new Button() |
| | | { |
| | | Y = deviceIMG.Bottom, |
| | | Height = Application.GetRealHeight(85), |
| | | Y = Application.GetRealHeight(46), |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Text = device.CommonDevice.DeviceEpointName, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 15 |
| | | }; |
| | | deviceView.AddChidren(lightName); |
| | | itemView.AddChidren(deviceNameBtn); |
| | | |
| | | levelSeekBar = new HorizontalSeekBar() |
| | | StatuBtn = new Button |
| | | { |
| | | Y = lightName.Bottom + Application.GetRealHeight(150), |
| | | Width = Application.GetRealWidth(800), |
| | | Height = Application.GetRealHeight(80), |
| | | Y = Application.GetRealHeight(118), |
| | | Width = Application.GetRealWidth(600), |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | BackgroundColor = ZigbeeColor.Current.GXCSliderUnSelectedColor, |
| | | ThumbColor = ZigbeeColor.Current.GXCButtonBlueColor, |
| | | BorderColor = ZigbeeColor.Current.GXCButtonBlueColor, |
| | | ProgressColor = ZigbeeColor.Current.GXCButtonBlueColor, |
| | | Max = 254, |
| | | Tag = "LevelSeekBar", |
| | | Progress = dimmableLight.Level, |
| | | SleepTime=sleepSpan, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | Text = CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline == 1) |
| | | }; |
| | | deviceView.AddChidren(levelSeekBar); |
| | | levelSeekBar.ProgressChanged += (send2, e2) => |
| | | itemView.AddChidren(StatuBtn); |
| | | |
| | | levelSeekBar = new WaveSeekBar() |
| | | { |
| | | dimmableLight.SetLevel(levelSeekBar.Progress); |
| | | Y = Application.GetRealHeight(377), |
| | | Width = Application.GetRealWidth(271), |
| | | Height = Application.GetRealHeight(533), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | WavePadding = 2, |
| | | MaxValue=100, |
| | | Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100), |
| | | WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor |
| | | }; |
| | | itemView.AddChidren(levelSeekBar); |
| | | |
| | | if (dimmableLight.OnOffStatus==1) |
| | | { |
| | | levelSeekBar.IsClickable = true; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; |
| | | } |
| | | else |
| | | { |
| | | levelSeekBar.IsClickable = false; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; |
| | | } |
| | | |
| | | levelSeekBar.OnProgressChangedEvent += (send2, e2) => |
| | | { |
| | | dimmableLight.SetLevel((int)(levelSeekBar.Progress*MaxLevel/100.0)); |
| | | }; |
| | | |
| | | switchBtn = new Button() |
| | | { |
| | | Y = levelSeekBar.Bottom + Application.GetRealHeight(150), |
| | | Y = Application.GetRealHeight(1005), |
| | | Width = Application.GetMinRealAverage(81), |
| | | Height = Application.GetMinRealAverage(81), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetMinRealAverage(180), |
| | | Height = Application.GetMinRealAverage(120), |
| | | UnSelectedImagePath = "Item/Switch.png", |
| | | SelectedImagePath = "Item/SwitchSelected.png", |
| | | Tag = DeviceStatus_OnOffStatus, |
| | | IsSelected = dimmableLight.OnOffStatus == 1 |
| | | IsSelected = (device.CommonDevice as DimmableLight).OnOffStatus == 1 |
| | | }; |
| | | deviceView.AddChidren(switchBtn); |
| | | itemView.AddChidren(switchBtn); |
| | | |
| | | var roomBtn = new Button() |
| | | var roomBG = new Button |
| | | { |
| | | X = Application.GetRealWidth(50), |
| | | Y = Application.GetRealHeight(25) + deviceView.Bottom, |
| | | Y = Application.GetRealHeight(1178 - 50), |
| | | Height = Application.GetRealHeight(138 + 50), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor, |
| | | Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius) |
| | | }; |
| | | itemView.AddChidren(roomBG); |
| | | |
| | | var roomBG2 = new Button |
| | | { |
| | | Y = Application.GetRealHeight(1178 - 50), |
| | | Height = Application.GetRealHeight(50), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, |
| | | }; |
| | | itemView.AddChidren(roomBG2); |
| | | |
| | | roomBtn = new Button() |
| | | { |
| | | X = Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | Y = Application.GetRealHeight(1207), |
| | | Width = Application.GetMinReal(80), |
| | | Height = Application.GetMinReal(80), |
| | | UnSelectedImagePath = "Item/Room.png", |
| | | SelectedImagePath = "Item/RoomSelected.png" |
| | | UnSelectedImagePath = "Item/Room.png" |
| | | }; |
| | | itemView.AddChidren(roomBtn); |
| | | |
| | | var roomName = new Button() |
| | | roomName = new Button() |
| | | { |
| | | X = roomBtn.Right + Application.GetRealWidth(20), |
| | | Y = roomBtn.Y, |
| | | X = Application.GetRealWidth(150), |
| | | Y = Application.GetRealHeight(1224), |
| | | Width = Application.GetRealWidth(400), |
| | | Height = Application.GetRealHeight(80), |
| | | Height = Application.GetRealHeight(50), |
| | | Text = room.Name, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | itemView.AddChidren(roomName); |
| | | } |
| | |
| | | { |
| | | switchBtn.MouseUpEventHandler += Switch_MouseUpEvent; |
| | | collectionBtn.MouseUpEventHandler += Collection; |
| | | moreBtn.MouseUpEventHandler += MoreEvent; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | private void Switch_MouseUpEvent(object sender, MouseEventArgs eventArgs) |
| | | { |
| | | switchBtn.IsSelected = !switchBtn.IsSelected; |
| | | StatuBtn.Text = CommonFormResouce.GetSwitchStatu(switchBtn.IsSelected); |
| | | if (switchBtn.IsSelected == true) |
| | | { |
| | | dimmableLight.SwitchControl(1); |
| | | levelSeekBar.IsClickable = true; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; |
| | | } |
| | | else |
| | | { |
| | | dimmableLight.SwitchControl(0); |
| | | levelSeekBar.IsClickable = false; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; |
| | | } |
| | | } |
| | | |
| | |
| | | private void Collection(object sender, MouseEventArgs e) |
| | | { |
| | | //collection |
| | | if (collectionBtn.IsSelected) |
| | | if ((sender as Button).IsSelected) |
| | | { |
| | | Shared.Common.Room.Lists[0].DeleteDevice(device.FileName); |
| | | collectionBtn.IsSelected = false; |
| | | Shared.Common.Room.GetLoveRoom().DeleteDevice(device.FileName); |
| | | (sender as Button).IsSelected = false; |
| | | } |
| | | else |
| | | { |
| | | Shared.Common.Room.Lists[0].AddDevice(device.FileName); |
| | | collectionBtn.IsSelected = true; |
| | | Shared.Common.Room.GetLoveRoom().AddDevice(device.FileName); |
| | | (sender as Button).IsSelected = true; |
| | | } |
| | | } |
| | | |