| | |
| | | /// </summary>
|
| | | private Common.Room lookRoom = null;
|
| | | /// <summary>
|
| | | /// 当前选择的分支,1:场景 2:功能
|
| | | /// </summary>
|
| | | private int nowSelectIndex = 1;
|
| | | /// <summary>
|
| | | /// 桌布控件
|
| | | /// </summary>
|
| | | private FrameLayout frameTable = null;
|
| | |
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //初始化分支控件
|
| | | this.InitSwitchControl();
|
| | |
|
| | | //初始化桌布控件
|
| | | this.frameTable = new FrameLayout();
|
| | | frameTable.Y = Application.GetRealHeight(187);
|
| | | frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
|
| | | bodyFrameLayout.AddChidren(frameTable);
|
| | |
|
| | | //显示场景列表
|
| | | this.ShowSceneList();
|
| | | //初始化分支控件
|
| | | this.InitSwitchControl();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | private void InitSwitchControl()
|
| | | {
|
| | | var btnTemp = new NormalViewControl(10, 10, false);
|
| | | btnTemp.TextID = R.MyInternationalizationString.uScence;
|
| | |
|
| | | //场景框(点击范围有点小,需要扩大它的点击范围)
|
| | | var frameScene = new FrameLayoutControl();
|
| | | frameScene.UseClickStatu = false;
|
| | | frameScene.Height = Application.GetRealHeight(90);
|
| | | frameScene.Width = btnTemp.GetRealWidthByText(16);
|
| | | frameScene.X = ControlCommonResourse.XXLeft;
|
| | | frameScene.Y = Application.GetRealHeight(40);
|
| | | bodyFrameLayout.AddChidren(frameScene);
|
| | | //场景
|
| | | var btnScene = new NormalViewControl(frameScene.Width, Application.GetRealHeight(63), false);
|
| | | btnScene.Text = btnTemp.Text;
|
| | | btnScene.TextSize = 16;
|
| | | btnScene.TextColor = UserCenterColor.Current.TextColor2;
|
| | | frameScene.AddChidren(btnScene, ChidrenBindMode.BindEventOnly);
|
| | | //底线
|
| | | var btnSceneLine = new NormalViewControl(40, 10, true);
|
| | | btnSceneLine.Y = btnScene.Bottom + Application.GetRealHeight(14);
|
| | | btnSceneLine.X = btnScene.X + btnScene.Width / 2 - Application.GetRealWidth(40) / 2;
|
| | | btnSceneLine.Radius = (uint)Application.GetRealHeight(10) / 2;
|
| | | btnSceneLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | frameScene.AddChidren(btnSceneLine, ChidrenBindMode.BindEventOnly);
|
| | |
|
| | | btnTemp.TextID = R.MyInternationalizationString.uFunction;
|
| | | //功能框(点击范围有点小,需要扩大它的点击范围)
|
| | | var frameFunc = new FrameLayoutControl();
|
| | | frameFunc.UseClickStatu = false;
|
| | | frameFunc.Height = Application.GetRealHeight(90);
|
| | | frameFunc.Width = btnTemp.GetRealWidthByText(16);
|
| | | frameFunc.X = frameScene.Right + Application.GetRealWidth(58);
|
| | | frameFunc.Y = Application.GetRealHeight(40);
|
| | | bodyFrameLayout.AddChidren(frameFunc);
|
| | | //功能
|
| | | var btnFunc = new NormalViewControl(frameFunc.Width, Application.GetRealHeight(63), false);
|
| | | btnFunc.Text = btnTemp.Text;
|
| | | btnFunc.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | frameFunc.AddChidren(btnFunc, ChidrenBindMode.BindEventOnly);
|
| | | //底线
|
| | | var btnFuncLine = new NormalViewControl(40, 10, true);
|
| | | btnFuncLine.Y = btnFunc.Bottom + Application.GetRealHeight(14);
|
| | | btnFuncLine.X = btnFunc.X + btnFunc.Width / 2 - Application.GetRealWidth(40) / 2;
|
| | | btnFuncLine.Radius = (uint)Application.GetRealHeight(10) / 2;
|
| | | btnFuncLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | frameFunc.AddChidren(btnFuncLine, ChidrenBindMode.BindEventOnly);
|
| | | btnFuncLine.Visible = false;
|
| | |
|
| | | frameScene.ButtonClickEvent += (sender, e) =>
|
| | | var tabControl = new SceneFunctionSwitchControl();
|
| | | tabControl.Y = Application.GetRealHeight(40);
|
| | | bodyFrameLayout.AddChidren(tabControl);
|
| | | tabControl.SelectTabEvent += (tabIndex) =>
|
| | | {
|
| | | //场景分支选择
|
| | | if (this.nowSelectIndex == 1)
|
| | | if (tabIndex == 0)
|
| | | {
|
| | | return;
|
| | | //显示场景列表
|
| | | this.ShowSceneList();
|
| | | }
|
| | | this.nowSelectIndex = 1;
|
| | |
|
| | | btnScene.TextSize = 16;
|
| | | btnScene.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnFunc.TextSize = 14;
|
| | | btnFunc.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnSceneLine.Visible = true;
|
| | | btnFuncLine.Visible = false;
|
| | |
|
| | | //显示场景列表
|
| | | this.ShowSceneList();
|
| | | };
|
| | |
|
| | | frameFunc.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //功能分支选择
|
| | | if (this.nowSelectIndex == 2)
|
| | | else
|
| | | {
|
| | | return;
|
| | | //显示功能列表
|
| | | this.ShowFunctionList();
|
| | | }
|
| | | this.nowSelectIndex = 2;
|
| | |
|
| | | btnScene.TextSize = 14;
|
| | | btnScene.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnFunc.TextSize = 16;
|
| | | btnFunc.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnFuncLine.Visible = true;
|
| | | btnSceneLine.Visible = false;
|
| | |
|
| | | //显示功能列表
|
| | | this.ShowFunctionList();
|
| | | };
|
| | | var listTitle = new List<string>();
|
| | | //场景,功能
|
| | | listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
|
| | | listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
|
| | | tabControl.InitControl(listTitle);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | //清空桌布
|
| | | this.frameTable.RemoveAll();
|
| | |
|
| | | var listView = new VerticalFrameControl(29);
|
| | | listView.Height = frameTable.Height;
|
| | | frameTable.AddChidren(listView);
|
| | |
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | if (this.frameTable == null)
|
| | | if (lookRoom.ListSceneId.Count == 0)
|
| | | {
|
| | | //还没有添加场景哦
|
| | | this.ShowNotDataImage(frameTable, Language.StringByID(R.MyInternationalizationString.uDoNotHadAddScenceMsg));
|
| | | return;
|
| | | }
|
| | | foreach (var data in lookRoom.SceneUIList)
|
| | | var listView = new VerticalFrameControl(3);
|
| | | listView.Height = frameTable.Height;
|
| | | frameTable.AddChidren(listView);
|
| | |
|
| | | foreach (var dataId in lookRoom.ListSceneId)
|
| | | {
|
| | | var frameContr = new FrameLayout();
|
| | | frameContr.Height = Application.GetRealHeight(470);
|
| | | listView.AddChidrenFrame(frameContr);
|
| | | //场景图片
|
| | | var btnPic = new PicViewControl(878, 470, true);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | btnPic.UnSelectedImagePath = data.IconPath;
|
| | | frameContr.AddChidren(btnPic);
|
| | | var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId);
|
| | | if (data == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | //场景控件
|
| | | var frameContr = new ScenePictrueControl();
|
| | | listView.AddChidren(frameContr);
|
| | | frameContr.InitControl(data);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | //清空桌布
|
| | | this.frameTable.RemoveAll();
|
| | |
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.X = ControlCommonResourse.XXLeft;
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.Width = bodyFrameLayout.Width;
|
| | | frameBack.Height = Application.GetRealHeight(1650);
|
| | | frameBack.Radius = (uint)Application.GetMinRealAverage(20);
|
| | | frameTable.AddChidren(frameBack);
|
| | |
|
| | | var listView = new VerticalListControl(23);
|
| | | listView.Y = Application.GetRealHeight(23);
|
| | | listView.Height = Application.GetRealHeight(1549 - 23);
|
| | | frameBack.AddChidren(listView);
|
| | |
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | if (listView == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //获取分组后的设备列表
|
| | | var dicGroupDevice = this.GetAllGroupDevice();
|
| | | if (dicGroupDevice.Count == 0)
|
| | | {
|
| | | //还没有添加设备哦
|
| | | this.ShowNotDataImage(frameTable, Language.StringByID(R.MyInternationalizationString.uDoNotHadAddDeviceMsg));
|
| | | return;
|
| | | }
|
| | |
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.X = ControlCommonResourse.XXLeft;
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.Width = bodyFrameLayout.Width;
|
| | | frameBack.Height = Application.GetRealHeight(1650);
|
| | | frameBack.Radius = (uint)Application.GetRealHeight(58);
|
| | | frameTable.AddChidren(frameBack);
|
| | |
|
| | | var listView = new VerticalListControl(23);
|
| | | listView.Y = Application.GetRealHeight(23);
|
| | | listView.Height = Application.GetRealHeight(1549 - 23);
|
| | | frameBack.AddChidren(listView);
|
| | |
|
| | | var dicData = new Dictionary<string, DeviceRowInfo>();
|
| | | var listGwId = new List<string>();
|
| | | foreach (var textId in dicGroupDevice.Keys)
|
| | |
| | | }
|
| | | }
|
| | | listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | | //开启设备在线监测
|
| | | this.StartCheckDeviceOnline(listView, listGwId, dicData);
|
| | | //如果不是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == false)
|
| | | {
|
| | | //开启设备在线监测
|
| | | this.StartCheckDeviceOnline(listView, listGwId, dicData);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | private Dictionary<int, DeviceRowInfo> GetAllGroupDevice()
|
| | | {
|
| | | //全部的设备
|
| | | var listDevice = lookRoom.GetRoomListDevice();
|
| | | var listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom);
|
| | | var dic = new Dictionary<int, DeviceRowInfo>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | var typeInfo = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<ZigBee.Device.CommonDevice>() { device });
|
| | | if (device.Type == DeviceType.IASZone)
|
| | | var typeInfo = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device);
|
| | | //按所属ID分组
|
| | | if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
|
| | | {
|
| | | //这个强制为传感器
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uDeviceBelongId1200;
|
| | | typeInfo.ConcreteType = Common.DeviceConcreteType.Sensor;
|
| | | }
|
| | | if (device.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | string iconPath = string.Empty;
|
| | | //继电器的时候,需要特殊处理
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uSwitch;
|
| | | iconPath = "Device/Switch.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uSocket1;
|
| | | iconPath = "Device/Socket1.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uLight;
|
| | | iconPath = "Device/Light.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | //继电器
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uDeviceBelongId2300;
|
| | | iconPath = "Device/Relay.png";
|
| | | }
|
| | | if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
|
| | | {
|
| | | dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
|
| | | dic[typeInfo.BeloneTextId].IconPath = iconPath;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
|
| | | {
|
| | | dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
|
| | | string path1 = string.Empty;
|
| | | string path2 = string.Empty;
|
| | | Common.LocalDevice.Current.GetDeviceBeloneIcon(typeInfo.ConcreteType, ref path1, ref path2);
|
| | | dic[typeInfo.BeloneTextId].IconPath = path1;
|
| | | }
|
| | | dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
|
| | | string path1 = string.Empty;
|
| | | string path2 = string.Empty;
|
| | | //获取图片
|
| | | Common.LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo.ConcreteType, ref path1, ref path2);
|
| | | dic[typeInfo.BeloneTextId].IconPath = path1;
|
| | | }
|
| | | dic[typeInfo.BeloneTextId].listDeviceKeys.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device));
|
| | | }
|
| | |
| | | /// <param name="dicData">以回路作为索引去指定对象</param>
|
| | | private void StartCheckDeviceOnline(VerticalListControl listView, List<string> listGwId, Dictionary<string, DeviceRowInfo> dicData)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | var listCheck = new HashSet<string>();
|
| | | for (int i = 0; i < listGwId.Count; i++)
|
| | | {
|
| | | if (listView == null)
|
| | | if (listView.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //这里主要只是获取在线状态
|
| | | var zbway = HdlGatewayLogic.Current.GetLocalGateway(listGwId[i]);
|
| | | var result = await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, (device) =>
|
| | | {
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | if (listView.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (listView == null || dicData.ContainsKey(mainkeys) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (localDevice != null && localDevice.IsOnline != device.IsOnline)
|
| | | {
|
| | | //在线状态一样的话,不需要刷新
|
| | | localDevice.IsOnline = device.IsOnline;
|
| | | localDevice.ReSave();
|
| | | }
|
| | | if (device.IsOnline == 1)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | dicData[mainkeys].OnlineCount += 1;
|
| | | dicData[mainkeys].btnOnline.Text = dicData[mainkeys].OnlineCount + "/" + dicData[mainkeys].listDeviceKeys.Count;
|
| | | });
|
| | | }
|
| | | }, ShowErrorMode.NO);
|
| | | int statu = 0;
|
| | | var list = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
|
| | | if (statu != -1)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | for (int j = 0; j < list.Count; j++)
|
| | | {
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(list[j]);
|
| | | if (listView.Parent == null || dicData.ContainsKey(mainkeys) == false || listCheck.Contains(mainkeys) == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | listCheck.Add(mainkeys);
|
| | |
|
| | | var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (localDevice != null && localDevice.IsOnline != list[j].IsOnline)
|
| | | {
|
| | | //在线状态一样的话,不需要刷新
|
| | | localDevice.IsOnline = list[j].IsOnline;
|
| | | localDevice.ReSave();
|
| | | }
|
| | | if (Common.LocalDevice.Current.CheckDeviceIsOnline(list[j]) == true)
|
| | | {
|
| | | dicData[mainkeys].OnlineCount += 1;
|
| | | dicData[mainkeys].btnOnline.Text = dicData[mainkeys].OnlineCount + "/" + dicData[mainkeys].listDeviceKeys.Count;
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|