| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 整个界面的上下滑动控件
|
| | | /// </summary>
|
| | | private VerticalFrameControl listBodyContr = null;
|
| | | /// <summary>
|
| | | /// 房间的滑动容器控件
|
| | | /// </summary>
|
| | | private HorizontalPages roomPageView = null;
|
| | |
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | //先初始化左滑房间列表界面
|
| | | if (ListRoomViewFrom.Instance == null)
|
| | | //先初始化左滑房间列表界面(在反射里面初始化)
|
| | | if (ListRoomViewFrom.Instance == null) { }
|
| | |
|
| | | //整个背景的上下滑动控件
|
| | | if (this.listBodyContr == null)
|
| | | {
|
| | | var roomList = new ListRoomViewFrom();
|
| | | CommonPage.Instance.AddLeftView(roomList);
|
| | | roomList.ShowForm();
|
| | | this.listBodyContr = new VerticalFrameControl();
|
| | | listBodyContr.Height = this.Height;
|
| | | listBodyContr.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
|
| | | this.AddChidren(listBodyContr);
|
| | | }
|
| | | this.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
|
| | | //清除全部
|
| | | this.RemoveAll();
|
| | | else
|
| | | {
|
| | | //清除全部
|
| | | this.listBodyContr.frameTable.RemoveAll();
|
| | | listBodyContr.RecoverTableHeight();
|
| | | }
|
| | |
|
| | | //初始化头部控件
|
| | | this.InitTopFrameLayoutControl();
|
| | |
| | | topFrameLayout.Y = Application.GetRealHeight(60);
|
| | | topFrameLayout.Height = Application.GetRealHeight(127);
|
| | | topFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
|
| | | this.AddChidren(topFrameLayout);
|
| | | listBodyContr.frameTable.AddChidren(topFrameLayout);
|
| | |
|
| | | //楼层图标
|
| | | var btnFloorIcon = new IconViewControl(69);
|
| | | btnFloorIcon.X = ControlCommonResourse.XXLeft;
|
| | | btnFloorIcon.Gravity = Gravity.CenterVertical;
|
| | | btnFloorIcon.UnSelectedImagePath = "Item/Floor.png";
|
| | | topFrameLayout.AddChidren(btnFloorIcon);
|
| | |
|
| | | //拥有楼层
|
| | | this.btnFloorName = null;
|
| | | if (Config.Instance.Home.FloorDics.Count > 0)
|
| | | {
|
| | | //楼层图标
|
| | | var btnFloorIcon = new IconViewControl(69);
|
| | | btnFloorIcon.X = ControlCommonResourse.XXLeft;
|
| | | btnFloorIcon.Gravity = Gravity.CenterVertical;
|
| | | btnFloorIcon.UnSelectedImagePath = "Item/Floor.png";
|
| | | topFrameLayout.AddChidren(btnFloorIcon);
|
| | | //拥有楼层的时候,点击才有效
|
| | | btnFloorIcon.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示选择楼层的界面
|
| | | this.ShowSelectFloorForm(btnFloorName);
|
| | | };
|
| | |
|
| | | //楼层名
|
| | | this.btnFloorName = new NormalViewControl(500, 100, true);
|
| | | btnFloorName.X = btnFloorIcon.Right;
|
| | |
| | | btnHouseName.IsBold = true;
|
| | | btnHouseName.Text = Config.Instance.Home.Name;
|
| | | btnHouseName.Width = btnHouseName.GetRealWidthByText();
|
| | | this.AddChidren(btnHouseName);
|
| | | this.listBodyContr.frameTable.AddChidren(btnHouseName);
|
| | |
|
| | | //切换住宅
|
| | | btnHouseName.MouseLongEventHandler += (sender, e) =>
|
| | |
| | | /// </summary>
|
| | | private void InitMidFrameLayoutControl()
|
| | | {
|
| | | //成员身份不允许添加网关
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 3)
|
| | | {
|
| | | //初始化场景,功能的切换控件
|
| | | this.InitSceneFunctionSwitchControl();
|
| | | //初始化房间滑动控件
|
| | | this.InitRoomHorizontalPagesControl();
|
| | | return;
|
| | | }
|
| | |
|
| | | //检测是否绑定有网关
|
| | | if (this.CheckHadBindGateway() == false)
|
| | | {
|
| | |
| | | {
|
| | | //初始化场景,功能的切换控件
|
| | | this.InitSceneFunctionSwitchControl();
|
| | |
|
| | | //初始化房间滑动控件
|
| | | this.InitRoomHorizontalPagesControl();
|
| | | }
|
| | |
| | | functionSceneView.Height = Application.GetRealHeight(167);
|
| | | functionSceneView.Gravity = Gravity.CenterHorizontal;
|
| | | functionSceneView.BackgroundImagePath = "Item/SceneFunctionBG.png";
|
| | | this.AddChidren(functionSceneView);
|
| | | this.listBodyContr.frameTable.AddChidren(functionSceneView);
|
| | |
|
| | | //场景
|
| | | var btnScene = new NormalViewControl(350, 100, true);
|
| | |
| | | if (UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex == 1)
|
| | | {
|
| | | btnScene.IsSelected = true;
|
| | | btnScene.TextSize = 16;
|
| | | btnScene.TextSize = 17;
|
| | | btnScene.IsBold = true;
|
| | | }
|
| | | else if (UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex == 2)
|
| | | {
|
| | | btnFunction.IsSelected = true;
|
| | | btnFunction.TextSize = 16;
|
| | | btnFunction.TextSize = 17;
|
| | | btnFunction.IsBold = true;
|
| | | }
|
| | |
|
| | |
| | | Gravity = Gravity.CenterHorizontal,
|
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
|
| | | };
|
| | | this.AddChidren(bodyFrameLayout);
|
| | | this.listBodyContr.frameTable.AddChidren(bodyFrameLayout);
|
| | |
|
| | | //选择功能分栏
|
| | | btnFunction.ButtonClickEvent += (sender, e) =>
|
| | |
| | | btnScene.IsBold = false;
|
| | |
|
| | | btnFunction.IsSelected = true;
|
| | | btnFunction.TextSize = 16;
|
| | | btnFunction.TextSize = 17;
|
| | | btnFunction.IsBold = true;
|
| | | //刷新设备桌布控件
|
| | | this.RefreshBodyView();
|
| | |
| | | UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex = 1;
|
| | |
|
| | | btnScene.IsSelected = true;
|
| | | btnScene.TextSize = 16;
|
| | | btnScene.TextSize = 17;
|
| | | btnScene.IsBold = true;
|
| | |
|
| | | btnFunction.IsSelected = false;
|
| | |
| | | bg.Y = Application.GetRealHeight(302);
|
| | | bg.Gravity = Gravity.CenterHorizontal;
|
| | | bg.UnSelectedImagePath = "Item/NoBindGW.png";
|
| | | this.AddChidren(bg);
|
| | | this.listBodyContr.frameTable.AddChidren(bg);
|
| | |
|
| | | var tip = new NormalViewControl(Application.GetMinRealAverage(717), Application.GetMinRealAverage(58), false);
|
| | | tip.Y = Application.GetRealHeight(815);
|
| | |
| | | tip.TextID = R.MyInternationalizationString.NewAccountNeedBingGW;
|
| | | tip.TextColor = ZigbeeColor.Current.GXCTextGrayColor;
|
| | | tip.TextAlignment = TextAlignment.Center;
|
| | | this.AddChidren(tip);
|
| | | this.listBodyContr.frameTable.AddChidren(tip);
|
| | |
|
| | | var addBG = new PicViewControl(971, 366);
|
| | | addBG.Y = Application.GetRealHeight(1048);
|
| | | addBG.UnSelectedImagePath = "Item/VirtualFrame.png";
|
| | | addBG.Gravity = Gravity.CenterHorizontal;
|
| | | this.AddChidren(addBG);
|
| | | this.listBodyContr.frameTable.AddChidren(addBG);
|
| | |
|
| | | var addGatewayBtn = new IconViewControl(89);
|
| | | addGatewayBtn.Y = Application.GetRealHeight(1143);
|
| | | addGatewayBtn.UnSelectedImagePath = "Item/Add_GW.png";
|
| | | addGatewayBtn.Gravity = Gravity.CenterHorizontal;
|
| | | this.AddChidren(addGatewayBtn);
|
| | | this.listBodyContr.frameTable.AddChidren(addGatewayBtn);
|
| | | addGatewayBtn.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm();
|
| | |
| | | addTip.TextID = R.MyInternationalizationString.AddSmartGW;
|
| | | addTip.TextColor = ZigbeeColor.Current.GXCTextBlackColor;
|
| | | addTip.TextAlignment = TextAlignment.Center;
|
| | | AddChidren(addTip);
|
| | | this.listBodyContr.frameTable.AddChidren(addTip);
|
| | |
|
| | | addTip.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | frameBack.Y = Application.GetRealHeight(302);
|
| | | frameBack.Width = Application.GetRealWidth(CommonPage.AppRealWidth);
|
| | | frameBack.Height = Application.GetRealHeight(478);
|
| | | this.AddChidren(frameBack);
|
| | | this.listBodyContr.frameTable.AddChidren(frameBack);
|
| | |
|
| | | this.roomPageView = new HorizontalPages();
|
| | | roomPageView.Width = frameBack.Width;
|
| | |
| | | btnRoomBottomShadow.Y = frameBack.Bottom;
|
| | | btnRoomBottomShadow.Gravity = Gravity.CenterHorizontal;
|
| | | btnRoomBottomShadow.UnSelectedImagePath = "Room/RoomCardShadow.png";
|
| | | this.AddChidren(btnRoomBottomShadow);
|
| | | this.listBodyContr.frameTable.AddChidren(btnRoomBottomShadow);
|
| | |
|
| | | //当前房间
|
| | | var listRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
|
| | |
| | | var roomView = new RoomView(0, 0);
|
| | | roomPageView.AddChidren(roomView);
|
| | | roomView.Init(listRoom[i]);
|
| | | |
| | |
|
| | | if (listRoom[i].Id == HdlRoomLogic.Current.CurrentRoom.Id)
|
| | | {
|
| | | //当前房间,则显示那些数据出来
|
| | |
| | | roomView.HideName(true);
|
| | | }
|
| | | }
|
| | | //设置房间的初始选择
|
| | | roomPageView.PageIndex = curIndex;
|
| | | //房间能够滑动的时候才显示
|
| | | FrameLayout btnRoomLeftShadow = null;
|
| | | FrameLayout btnRoomRightShadow = null;
|
| | |
| | | this.isRoomChanging = false;
|
| | | this.RefreshBodyView();
|
| | | };
|
| | | //设置房间的初始选择
|
| | | roomPageView.PageIndex = curIndex;
|
| | | #if iOS
|
| | | //Ios如果索引是第一个时,它触发不了事件,需要手动触发
|
| | | if (curIndex == 0)
|
| | | {
|
| | | roomPageView.EndScrollAction();
|
| | | }
|
| | | #endif
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="room"></param>
|
| | | public void SetRoomPageViewSelect(Room room)
|
| | | {
|
| | | if (roomPageView == null)
|
| | | {
|
| | | //当没有绑定有网关,左滑时,点击房间列表,则不鸟它
|
| | | return;
|
| | | }
|
| | | var listRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
|
| | | for (int i = 0; i < listRoom.Count; i++)
|
| | | {
|
| | |
| | | {
|
| | | //先清空缓存
|
| | | bodyFrameLayout.RemoveAll();
|
| | | bodyFrameLayout.Height = Application.GetRealHeight(750);
|
| | | this.listBodyContr.RecoverTableHeight();
|
| | | this.dicSceneCardControl.Clear();
|
| | | this.dicDeviceCardControl.Clear();
|
| | |
|
| | |
| | | foreach (var mainkeys in HdlRoomLogic.Current.CurrentRoom.ListDevice)
|
| | | {
|
| | | var device = LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (device == null
|
| | | || device.Type == DeviceType.OnOffSwitch)//干接点
|
| | | //判断该设备能否显示在主页
|
| | | if (LocalDevice.Current.CanShowInHomeHomeMainPage(device) == false)
|
| | | {
|
| | | //这个设备不见了
|
| | | continue;
|
| | | }
|
| | | listDevice.Add(device);
|
| | |
| | | ShowNoFunctionTip();
|
| | | return;
|
| | | }
|
| | | //列表控件
|
| | | var listView = new VerticalFrameControl();
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | | //设备列表容器控件
|
| | | var listDeviceBackContr = new FrameLayout();
|
| | | listDeviceBackContr.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listDeviceBackContr);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //初始化设备卡片列表控件
|
| | | this.InitDeviceListCardControl(listView, listDevice);
|
| | | this.InitDeviceListCardControl(listDeviceBackContr, listDevice);
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化设备卡片列表控件
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | private void InitDeviceListCardControl(VerticalFrameControl listView, List<CommonDevice> listDevice)
|
| | | /// <param name="listDeviceBackContr"></param>
|
| | | private void InitDeviceListCardControl(FrameLayout listDeviceBackContr, List<CommonDevice> listDevice)
|
| | | {
|
| | | //设备计数
|
| | | int contrCount = 0;
|
| | |
| | | var listContr = new List<Controls.DeviceCardCommon>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | if (this.isRoomChanging == true || listView.Parent == null)
|
| | | if (this.isRoomChanging == true || listDeviceBackContr.Parent == null)
|
| | | {
|
| | | //放弃初始化控件
|
| | | return;
|
| | |
| | | //初始化卡片
|
| | | cardContr.X = XX;
|
| | | cardContr.Y = YY;
|
| | | listView.frameTable.AddChidren(cardContr);
|
| | | listDeviceBackContr.AddChidren(cardContr);
|
| | | cardContr.InitControl(device);
|
| | | //卡片需要被移除的事件
|
| | | cardContr.CardNeedRemoveEvent += () =>
|
| | |
| | | if (contrCount == listDevice.Count)
|
| | | {
|
| | | //调整桌布大小
|
| | | listView.AdjustTableHeight();
|
| | | if (contrCount > 4)
|
| | | {
|
| | | bodyFrameLayout.Height = listDeviceBackContr.GetChildren(listDeviceBackContr.ChildrenCount - 1).Bottom;
|
| | | listDeviceBackContr.Height = bodyFrameLayout.Height;
|
| | | this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
|
| | | }
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | for (int i = 0; i < listContr.Count; i++)
|
| | | {
|
| | | if (listView.Parent == null)
|
| | | if (listDeviceBackContr.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | System.Threading.Thread.Sleep(20);
|
| | | System.Threading.Thread.Sleep(200);
|
| | | //发送获取状态的命令
|
| | | listContr[i].SendStatuComand();
|
| | | }
|
| | |
| | |
|
| | | //设备计数
|
| | | int contrCount = 0;
|
| | | |
| | |
|
| | | bool canMove = false;
|
| | | int YY = 0;
|
| | | foreach (var mainkey in this.dicDeviceCardControl.Keys)
|
| | |
| | | }
|
| | | }
|
| | | //去找一下这个控件的列表容器
|
| | | var listView = deleteContr.Parent.Parent as VerticalFrameControl;
|
| | | var listView = deleteContr.Parent as FrameLayout;
|
| | |
|
| | | //删除掉那张卡片的主键
|
| | | deleteContr.RemoveFromParent();
|
| | | this.dicDeviceCardControl.Remove(deleteKey);
|
| | |
|
| | | //调整桌布高度
|
| | | listView?.AdjustTableHeight();
|
| | | if (listView.ChildrenCount >= 4)
|
| | | {
|
| | | bodyFrameLayout.Height = listView.GetChildren(listView.ChildrenCount - 1).Bottom;
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | //先清空缓存
|
| | | bodyFrameLayout.RemoveAll();
|
| | | bodyFrameLayout.Height = Application.GetRealHeight(750);
|
| | | this.listBodyContr.RecoverTableHeight();
|
| | | this.dicSceneCardControl.Clear();
|
| | | this.dicDeviceCardControl.Clear();
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | | //列表控件
|
| | | var listView = new VerticalFrameControl();
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | | var listSceneBackContr = new FrameLayout();
|
| | | listSceneBackContr.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listSceneBackContr);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //初始化设备卡片列表控件
|
| | | this.InitSceneListCardControl(listView, listScene);
|
| | | this.InitSceneListCardControl(listSceneBackContr, listScene);
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化场景卡片列表控件
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | private void InitSceneListCardControl(VerticalFrameControl listView, List<SceneUI> listScene)
|
| | | /// <param name="listSceneBackContr"></param>
|
| | | private void InitSceneListCardControl(FrameLayout listSceneBackContr, List<SceneUI> listScene)
|
| | | {
|
| | | //场景计数
|
| | | int contrCount = 0;
|
| | |
| | | int YY = 0;
|
| | | foreach (var sceneUi in listScene)
|
| | | {
|
| | | if (this.isRoomChanging == true || listView.Parent == null)
|
| | | if (this.isRoomChanging == true || listSceneBackContr.Parent == null)
|
| | | {
|
| | | //放弃初始化控件
|
| | | return;
|
| | |
| | | var cardContr = new Controls.SceneCardControl();
|
| | | cardContr.X = XX;
|
| | | cardContr.Y = YY;
|
| | | listView.frameTable.AddChidren(cardContr);
|
| | | listSceneBackContr.AddChidren(cardContr);
|
| | | cardContr.InitControl(sceneUi);
|
| | | //卡片需要被移除的事件
|
| | | cardContr.CardNeedRemoveEvent += () =>
|
| | |
| | | }
|
| | | //控件记录到缓存中
|
| | | this.dicSceneCardControl[sceneUi.Id] = cardContr;
|
| | |
|
| | | if (contrCount == listScene.Count)
|
| | | {
|
| | | //调整桌布高度
|
| | | listView.AdjustTableHeight();
|
| | | if (contrCount > 4)
|
| | | {
|
| | | bodyFrameLayout.Height = listSceneBackContr.GetChildren(listSceneBackContr.ChildrenCount - 1).Bottom;
|
| | | listSceneBackContr.Height = bodyFrameLayout.Height;
|
| | | this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
|
| | | }
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //设置目前场景的延迟状态
|
| | | this.SetSceneDelayTime(listView);
|
| | | this.SetSceneDelayTime(listSceneBackContr);
|
| | | });
|
| | | }
|
| | | });
|
| | |
| | | /// <summary>
|
| | | /// 设置场景的延迟状态
|
| | | /// </summary>
|
| | | /// <param name="listView"></param>
|
| | | private async void SetSceneDelayTime(VerticalFrameControl listView)
|
| | | /// <param name="listSceneBackContr"></param>
|
| | | private async void SetSceneDelayTime(FrameLayout listSceneBackContr)
|
| | | {
|
| | | await System.Threading.Tasks.Task.Delay(1500);
|
| | | if (listView.Parent == null)
|
| | | if (listSceneBackContr.Parent == null)
|
| | | {
|
| | | //控件已经被移除
|
| | | return;
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | if (listView.Parent == null)
|
| | | if (listSceneBackContr.Parent == null)
|
| | | {
|
| | | //控件已经被移除
|
| | | return;
|
| | |
| | | }
|
| | | }
|
| | | //去找一下这个控件的列表容器
|
| | | var listView = deleteContr.Parent.Parent as VerticalFrameControl;
|
| | | var listView = deleteContr.Parent as FrameLayout;
|
| | |
|
| | | //删除掉那张卡片的主键
|
| | | deleteContr.RemoveFromParent();
|
| | | this.dicSceneCardControl.Remove(deleteId);
|
| | |
|
| | | //调整桌布高度
|
| | | listView?.AdjustTableHeight();
|
| | | if (listView.ChildrenCount >= 4)
|
| | | {
|
| | | bodyFrameLayout.Height = listView.GetChildren(listView.ChildrenCount - 1).Bottom;
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | this.listBodyContr.frameTable.Height = bodyFrameLayout.Bottom;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | //刷新卡片信息
|
| | | var locadevice = LocalDevice.Current.GetDevice(mainKeys);
|
| | | if (report.DeviceStatusReport.CluterID == 513 && report.DeviceStatusReport.AttriBute[0].AttributeId == 28)
|
| | | {
|
| | | //空调是特殊的,它的开关是属性上报来着.已经接收到网关的反馈
|
| | | this.dicDeviceCardControl[mainKeys].SetHadGetResponeResultStatu();
|
| | | }
|
| | | this.dicDeviceCardControl[mainKeys].RefreshControlInfo(locadevice);
|
| | | }
|
| | | }, ShowErrorMode.NO);
|