| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.SharedContent
|
| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备列表控件
|
| | | /// 查看的房间对象
|
| | | /// </summary>
|
| | | private VerticalScrolViewLayout listDeviceView = null;
|
| | | /// <summary>
|
| | | /// 场景列表控件
|
| | | /// </summary>
|
| | | private VerticalScrolViewLayout listSceneView = null;
|
| | | /// <summary>
|
| | | /// 成员信息
|
| | | /// </summary>
|
| | | private MemberInfoRes memberResult = null;
|
| | | private Common.Room lookRoom = null;
|
| | | /// <summary>
|
| | | /// 成员的分享数据
|
| | | /// </summary>
|
| | | private MemberShardInfoData memberShardInfo = null;
|
| | | /// <summary>
|
| | | /// 房间对象
|
| | | /// 设备桌布控件
|
| | | /// </summary>
|
| | | private Common.Room room = null;
|
| | | private FrameLayout frameDeviceTable = null;
|
| | | /// <summary>
|
| | | /// Tab的选择。1:功能Tab 2:场景Tab
|
| | | /// 设备桌布控件
|
| | | /// </summary>
|
| | | private int TabSelectIndex = 1;
|
| | | private FrameLayout frameSceneTable = null;
|
| | | /// <summary>
|
| | | /// 删除按钮
|
| | | /// </summary>
|
| | | private BottomClickButton btnDelete = null;
|
| | | /// <summary>
|
| | | /// 选择的场景
|
| | | /// </summary>
|
| | | private Dictionary<int, Common.SceneUI> dicSelectScene = new Dictionary<int, Common.SceneUI>();
|
| | | /// <summary>
|
| | | /// 选择的设备
|
| | | /// </summary>
|
| | | private Dictionary<string, CommonDevice> dicSelectDevice = new Dictionary<string, CommonDevice>();
|
| | | /// <summary>
|
| | | /// 当前选择的分支 1:场景 2:功能
|
| | | /// </summary>
|
| | | private int nowSwitchIndex = 1;
|
| | | /// <summary>
|
| | | /// 当前选择的设备索引
|
| | | /// </summary>
|
| | | private string nowDeviceIndex = string.Empty;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_room">房间信息</param>
|
| | | /// <param name="i_memberResult">成员信息</param>
|
| | | /// <param name="i_room">查看的房间对象</param>
|
| | | /// <param name="i_memberShardInfo">成员的分享数据</param>
|
| | | public void ShowForm(Common.Room i_room, MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo)
|
| | | public void ShowForm(Common.Room i_room, MemberShardInfoData i_memberShardInfo)
|
| | | {
|
| | | this.memberResult = i_memberResult;
|
| | | this.room = i_room;
|
| | | this.lookRoom = i_room;
|
| | | this.memberShardInfo = i_memberShardInfo;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(i_room.Name);
|
| | |
|
| | | //初始化中部信息
|
| | | //this.InitMiddleFrame();
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化中部信息
|
| | | ///// </summary>
|
| | | //private void InitMiddleFrame()
|
| | | //{
|
| | | // //清空bodyFrame
|
| | | // this.ClearBodyFrame();
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | | this.dicSelectDevice = new Dictionary<string, CommonDevice>();
|
| | | this.dicSelectScene = new Dictionary<int, Common.SceneUI>();
|
| | |
|
| | | // //初始化Tab控件
|
| | | // var frame = this.InitTabControl();
|
| | | //初始化桌布控件
|
| | | this.frameSceneTable = new FrameLayout();
|
| | | frameSceneTable.Y = Application.GetRealHeight(132);
|
| | | frameSceneTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(132);
|
| | | bodyFrameLayout.AddChidren(frameSceneTable);
|
| | |
|
| | | // this.listDeviceView = new VerticalScrolViewLayout();
|
| | | // listDeviceView.Y = frame.Bottom;
|
| | | // listDeviceView.Height = bodyFrameLayout.Height - frame.Bottom;
|
| | | // listDeviceView.Visible = this.TabSelectIndex == 1;
|
| | | // bodyFrameLayout.AddChidren(listDeviceView);
|
| | | this.frameDeviceTable = new FrameLayout();
|
| | | frameDeviceTable.Y = frameSceneTable.Y;
|
| | | frameDeviceTable.Height = frameSceneTable.Height;
|
| | | bodyFrameLayout.AddChidren(frameDeviceTable);
|
| | | frameDeviceTable.Visible = false;
|
| | |
|
| | | // this.listSceneView = new VerticalScrolViewLayout();
|
| | | // listSceneView.Y = frame.Bottom;
|
| | | // listSceneView.Height = bodyFrameLayout.Height - frame.Bottom;
|
| | | // listSceneView.Visible = this.TabSelectIndex == 2;
|
| | | // bodyFrameLayout.AddChidren(listSceneView);
|
| | | //初始化分支控件
|
| | | this.InitSwitchControl();
|
| | |
|
| | | // HdlThreadLogic.Current.Run(() =>
|
| | | // {
|
| | | // //初始化功能Tab列表
|
| | | // this.InitFunctionTabList();
|
| | | // //初始化场景Tab列表
|
| | | // this.InitSceneTabList();
|
| | | // });
|
| | | //}
|
| | | //删除按钮
|
| | | this.btnDelete = new BottomClickButton();
|
| | | btnDelete.BackgroundColor = 0xfff75858;
|
| | | btnDelete.TextID = R.MyInternationalizationString.uDelete;
|
| | | bodyFrameLayout.AddChidren(btnDelete);
|
| | | btnDelete.Visible = false;
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //删除分享
|
| | | this.DeleteShardData();
|
| | | };
|
| | |
|
| | | //初始化场景列表
|
| | | this.InitSceneList();
|
| | | //初始功能列表
|
| | | this.InitFunctionList();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化分支控件
|
| | | /// </summary>
|
| | | private void InitSwitchControl()
|
| | | {
|
| | | var tabControl = new SceneFunctionSwitchControl();
|
| | | tabControl.Y = Application.GetRealHeight(40);
|
| | | bodyFrameLayout.AddChidren(tabControl);
|
| | | //设置初始化值
|
| | | tabControl.SetDefultIndex(nowSwitchIndex);
|
| | | tabControl.SelectTabEvent += (tabIndex) =>
|
| | | {
|
| | | this.nowSwitchIndex = tabIndex;
|
| | | if (tabIndex == 1)
|
| | | {
|
| | | //显示场景列表
|
| | | this.frameSceneTable.Visible = true;
|
| | | this.frameDeviceTable.Visible = false;
|
| | | }
|
| | | else
|
| | | {
|
| | | //显示功能列表
|
| | | this.frameSceneTable.Visible = false;
|
| | | this.frameDeviceTable.Visible = true;
|
| | | }
|
| | | };
|
| | | tabControl.InitControl();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | //#region ■ 初始化Tab控件______________________
|
| | | #region ■ 场景显示___________________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化Tab控件
|
| | | ///// </summary>
|
| | | ///// <returns></returns>
|
| | | //private FrameLayout InitTabControl()
|
| | | //{
|
| | | // //Tab切换控件
|
| | | // var frameSwich = new FrameLayout();
|
| | | // frameSwich.Height = Application.GetRealHeight(150);
|
| | | // frameSwich.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
|
| | | // bodyFrameLayout.AddChidren(frameSwich);
|
| | | /// <summary>
|
| | | /// 初始化场景列表
|
| | | /// </summary>
|
| | | private void InitSceneList()
|
| | | {
|
| | | //清空桌布
|
| | | this.frameSceneTable.RemoveAll();
|
| | |
|
| | | // //功能
|
| | | // var btnFunction = new NormalViewControl(frameSwich.Width / 2, Application.GetRealHeight(100));
|
| | | // btnFunction.Gravity = Gravity.CenterVertical;
|
| | | // btnFunction.TextID = R.MyInternationalizationString.uFunction;
|
| | | // btnFunction.TextAlignment = TextAlignment.Center;
|
| | | // btnFunction.TextColor = UserCenterColor.Current.SelectTextColor;
|
| | | // btnFunction.TextAlignment = TextAlignment.Center;
|
| | | // frameSwich.AddChidren(btnFunction);
|
| | | var listScene = new List<Common.SceneUI>();
|
| | | for (int i = 0; i < lookRoom.SceneUIList.Count; i++)
|
| | | {
|
| | | if (HdlShardLogic.Current.IsFileExists(lookRoom.SceneUIList[i].FileName) == true)
|
| | | {
|
| | | listScene.Add(lookRoom.SceneUIList[i]);
|
| | | }
|
| | | }
|
| | | if (listScene.Count == 0)
|
| | | {
|
| | | //无可取消共享的场景
|
| | | this.ShowNotDataImage(frameSceneTable, Language.StringByID(R.MyInternationalizationString.uNotCanCancelShardSceneMsg), "Item/NotShardPic.png", 383, 279);
|
| | | return;
|
| | | }
|
| | |
|
| | | // //场景
|
| | | // var btnScene = new NormalViewControl(frameSwich.Width / 2, Application.GetRealHeight(100));
|
| | | // btnScene.Gravity = Gravity.CenterVertical;
|
| | | // btnScene.X = frameSwich.Width / 2;
|
| | | // btnScene.TextID = R.MyInternationalizationString.uScence;
|
| | | // btnScene.TextAlignment = TextAlignment.Center;
|
| | | // frameSwich.AddChidren(btnScene);
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | var listView = new VerticalFrameControl(29);
|
| | | listView.Y = Application.GetRealHeight(53);
|
| | | listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
|
| | | frameSceneTable.AddChidren(listView);
|
| | |
|
| | | // //线
|
| | | // var btnLine = new ProgressLine();
|
| | | // btnLine.Gravity = Gravity.BottomLeft;
|
| | | // frameSwich.AddChidren(btnLine);
|
| | | // btnLine.SetValue(50, true);
|
| | | foreach (var data in listScene)
|
| | | {
|
| | | //场景图片
|
| | | var frameContr = new FrameLayoutControl();
|
| | | frameContr.UseClickStatu = false;
|
| | | frameContr.Width = Application.GetRealWidth(878);
|
| | | frameContr.Height = Application.GetRealHeight(440);
|
| | | frameContr.Gravity = Gravity.CenterHorizontal;
|
| | | frameContr.BackgroundImagePath = data.IconPath;
|
| | | listView.AddChidrenFrame(frameContr);
|
| | |
|
| | | // if (this.TabSelectIndex == 2)
|
| | | // {
|
| | | // btnScene.TextColor = UserCenterColor.Current.SelectTextColor;
|
| | | // btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor;
|
| | | // btnLine.SetValue(50, false);
|
| | | // }
|
| | | var btnSelect = new IconViewControl(58);
|
| | | btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
|
| | | btnSelect.SelectedImagePath = "Item/ItemSelected.png";
|
| | | btnSelect.X = Application.GetRealWidth(786);
|
| | | btnSelect.Y = Application.GetRealHeight(35);
|
| | | frameContr.AddChidren(btnSelect, ChidrenBindMode.BindEventOnly);
|
| | | if (dicSelectScene.ContainsKey(data.Id) == true)
|
| | | {
|
| | | btnSelect.IsSelected = true;
|
| | | }
|
| | | frameContr.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //选择
|
| | | btnSelect.IsSelected = !btnSelect.IsSelected;
|
| | | if (btnSelect.IsSelected == true)
|
| | | {
|
| | | dicSelectScene[data.Id] = data;
|
| | | if (this.btnDelete.Visible == false)
|
| | | {
|
| | | this.btnDelete.Visible = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | dicSelectScene.Remove(data.Id);
|
| | | if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
|
| | | {
|
| | | this.btnDelete.Visible = false;
|
| | | }
|
| | | }
|
| | | };
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | // //功能Tab
|
| | | // btnFunction.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // if (this.TabSelectIndex == 1)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // btnScene.TextColor = Common.ZigbeeColor.Current.TextColor;
|
| | | // btnFunction.TextColor = UserCenterColor.Current.SelectTextColor;
|
| | | // btnLine.SetValue(50);
|
| | | // this.TabSelectIndex = 1;
|
| | | #endregion
|
| | |
|
| | | // //隐藏场景列表控件,显示设备列表控件
|
| | | // this.listSceneView.Visible = false;
|
| | | // this.listDeviceView.Visible = true;
|
| | | // };
|
| | | #region ■ 功能显示___________________________
|
| | |
|
| | | // //场景Tab
|
| | | // btnScene.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // if (this.TabSelectIndex == 2)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // btnScene.TextColor = UserCenterColor.Current.SelectTextColor;
|
| | | // btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor;
|
| | | // btnLine.SetValue(50, false);
|
| | | // this.TabSelectIndex = 2;
|
| | | /// <summary>
|
| | | /// 初始化功能列表
|
| | | /// </summary>
|
| | | private void InitFunctionList()
|
| | | {
|
| | | //清空桌布
|
| | | this.frameDeviceTable.RemoveAll();
|
| | |
|
| | | // //隐藏设备列表控件,显示场景列表控件
|
| | | // this.listDeviceView.Visible = false;
|
| | | // this.listSceneView.Visible = true;
|
| | | // };
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | //获取分组后的设备列表
|
| | | var dicGroupDevice = this.GetAllGroupDevice();
|
| | | if (dicGroupDevice.Count == 0)
|
| | | {
|
| | | //无可取消共享的设备
|
| | | this.ShowNotDataImage(frameDeviceTable, Language.StringByID(R.MyInternationalizationString.uNotCanCancelDeviceMsg), "Item/NotShardPic.png", 383, 279);
|
| | | }
|
| | | else
|
| | | {
|
| | | var frameBack = new FrameLayoutControl(false);
|
| | | frameBack.X = ControlCommonResourse.XXLeft;
|
| | | frameBack.Y = Application.GetRealHeight(178);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.Width = bodyFrameLayout.Width;
|
| | | frameBack.Height = Application.GetRealHeight(1650);
|
| | | frameBack.RadiusEx = 20;
|
| | | frameDeviceTable.AddChidren(frameBack);
|
| | |
|
| | | // return frameSwich;
|
| | | //}
|
| | | var listView = new VerticalListControl(23);
|
| | | listView.Y = Application.GetRealHeight(23);
|
| | | listView.Height = Application.GetRealHeight(1437 - 23);
|
| | | frameBack.AddChidren(listView);
|
| | | //初始化设备类型行
|
| | | this.InitDeviceObjectRow(dicGroupDevice, listView);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | //#endregion
|
| | | #endregion
|
| | |
|
| | | //#region ■ 显示功能Tab列表____________________
|
| | | #region ■ 初始化设备类型行___________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化功能Tab列表
|
| | | ///// </summary>
|
| | | //private void InitFunctionTabList()
|
| | | //{
|
| | | // //获取分享的设备
|
| | | // var listDevice = this.GetShardListDevice();
|
| | | /// <summary>
|
| | | /// 初始化设备类型行
|
| | | /// </summary>
|
| | | /// <param name="dicData"></param>
|
| | | /// <param name="listView"></param>
|
| | | private void InitDeviceObjectRow(Dictionary<int, List<CommonDevice>> dicData, VerticalListControl listView)
|
| | | {
|
| | | var scrolContr = new RoomDeviceGroupMenuControl(dicData);
|
| | | this.frameDeviceTable.AddChidren(scrolContr);
|
| | | //设置初始值
|
| | | scrolContr.SetDefultIndex(nowDeviceIndex);
|
| | | scrolContr.SelectDeviceEvent += (listdevice) =>
|
| | | {
|
| | | this.nowDeviceIndex = scrolContr.nowSelectKeys;
|
| | | //添加设备行
|
| | | this.AddDeviceRow(listdevice, listView);
|
| | | };
|
| | | scrolContr.InitControl();
|
| | | }
|
| | |
|
| | | // foreach (var device in listDevice)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (this.Parent != null)
|
| | | // {
|
| | | // //添加设备的明细行
|
| | | // this.AddDeviceDetailRow(device);
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | | #endregion
|
| | |
|
| | | ///// <summary>
|
| | | ///// 添加设备的明细行
|
| | | ///// </summary>
|
| | | ///// <param name="device">设备对象</param>
|
| | | //private void AddDeviceDetailRow(CommonDevice device)
|
| | | //{
|
| | | // var row = new StatuRowLayout(listDeviceView);
|
| | | #region ■ 添加设备行_________________________
|
| | |
|
| | | // //图片
|
| | | // var btnIcon = new RowLeftIconView();
|
| | | // Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
|
| | | // row.AddChidren(btnIcon, ChidrenBindMode.NotBind);
|
| | | /// <summary>
|
| | | /// 添加设备行
|
| | | /// </summary>
|
| | | /// <param name="listDevice"></param>
|
| | | /// <param name="listView"></param>
|
| | | private void AddDeviceRow(List<CommonDevice> listDevice, VerticalListControl listView)
|
| | | {
|
| | | listView.RemoveAll();
|
| | |
|
| | | // //设备类型的翻译名字
|
| | | // var btnName = new RowCenterView();
|
| | | // btnName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | // row.AddChidren(btnName, ChidrenBindMode.NotBind);
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | var frameRow = new FrameRowControl(listView.rowSpace / 2);
|
| | | frameRow.LeftOffset = Application.GetRealWidth(46) - ControlCommonResourse.XXLeft;
|
| | | frameRow.RightOffset = -ControlCommonResourse.XXLeft;
|
| | | listView.AddChidren(frameRow);
|
| | | //图标
|
| | | var btnIcon = frameRow.AddLeftIcon(81);
|
| | | Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
|
| | | //名称
|
| | | var btnView = frameRow.AddLeftCaption(string.Empty, 600);
|
| | | btnView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | btnView.TextSize = 15;
|
| | | //底线
|
| | | frameRow.AddBottomLine();
|
| | | //选择
|
| | | var btnSelect = frameRow.AddMostRightEmptyIcon(69, 69);
|
| | | btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
|
| | | btnSelect.SelectedImagePath = "Item/ItemSelected.png";
|
| | |
|
| | | // //移除
|
| | | // var btnDelete = new RowDeleteButton();
|
| | | // btnDelete.TextID = R.MyInternationalizationString.RemoveBotton;
|
| | | // row.AddRightView(btnDelete);
|
| | | // btnDelete.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // //确定移除选中的设备?
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uConfirmRemoveSelectDeviceMsg);
|
| | | // this.ShowConfirmMsg(msg, "DeleteShardDevice", row, device);
|
| | | // };
|
| | | //}
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | if (dicSelectDevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | btnSelect.IsSelected = true;
|
| | | }
|
| | | frameRow.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //选择
|
| | | btnSelect.IsSelected = !btnSelect.IsSelected;
|
| | | if (btnSelect.IsSelected == true)
|
| | | {
|
| | | dicSelectDevice[mainKeys] = device;
|
| | | if (this.btnDelete.Visible == false)
|
| | | {
|
| | | this.btnDelete.Visible = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | dicSelectDevice.Remove(mainKeys);
|
| | | if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
|
| | | {
|
| | | this.btnDelete.Visible = false;
|
| | | }
|
| | | }
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 删除共享设备
|
| | | ///// </summary>
|
| | | ///// <param name="row"></param>
|
| | | ///// <param name="device"></param>
|
| | | //public async void DeleteShardDevice(StatuRowLayout row, CommonDevice device)
|
| | | //{
|
| | | // var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.room, new List<CommonDevice>() { device }, new List<Common.SceneUI>());
|
| | | // if (result == true)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // row?.RemoveFromParent();
|
| | | // if (this.listDeviceView != null && this.listDeviceView.ChildrenCount == 0 && this.listSceneView.ChildrenCount == 0)
|
| | | // {
|
| | | // //什么都没有了,则关闭界面
|
| | | // this.CloseForm();
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | | #endregion
|
| | |
|
| | | //#endregion
|
| | | #region ■ 整合设备___________________________
|
| | |
|
| | | //#region ■ 显示场景Tab列表____________________
|
| | | /// <summary>
|
| | | /// 获取分组后的设备
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private Dictionary<int, List<CommonDevice>> GetAllGroupDevice()
|
| | | {
|
| | | //全部的设备
|
| | | var listDevice = this.GetShardListDevice();
|
| | | var dic = new Dictionary<int, List<CommonDevice>>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | var typeInfo = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<ZigBee.Device.CommonDevice>() { device });
|
| | | if (device.Type == DeviceType.IASZone)
|
| | | {
|
| | | //这个强制为传感器
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uDeviceBelongId1200;
|
| | | typeInfo.ConcreteType = Common.DeviceConcreteType.Sensor;
|
| | | }
|
| | | if (device.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //继电器的时候,需要特殊处理
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uSwitch;
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uSocket1;
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uLight;
|
| | | }
|
| | | else
|
| | | {
|
| | | //继电器
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uDeviceBelongId2300;
|
| | | }
|
| | | if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
|
| | | {
|
| | | dic[typeInfo.BeloneTextId] = new List<CommonDevice>();
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
|
| | | {
|
| | | dic[typeInfo.BeloneTextId] = new List<CommonDevice>();
|
| | | }
|
| | | }
|
| | | dic[typeInfo.BeloneTextId].Add(device);
|
| | | }
|
| | | return dic;
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化场景Tab列表
|
| | | ///// </summary>
|
| | | //private void InitSceneTabList()
|
| | | //{
|
| | | // foreach (var sceneUi in this.room.SceneUIList)
|
| | | // {
|
| | | // if (sceneUi == null || memberShardInfo.dicAllMemberShard[this.room.FileName].Contains(sceneUi.FileName) == false)
|
| | | // {
|
| | | // //异常,或者不存在,则不显示
|
| | | // continue;
|
| | | // }
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (this.Parent != null)
|
| | | // {
|
| | | // //添加场景行
|
| | | // this.AddSceneDetailRow(sceneUi);
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | | #endregion
|
| | |
|
| | | ///// <summary>
|
| | | ///// 添加场景的明细行
|
| | | ///// </summary>
|
| | | ///// <param name="sceneUI">场景对象</param>
|
| | | //private void AddSceneDetailRow(Common.SceneUI sceneUI)
|
| | | //{
|
| | | // var sceneRow = new SceneViewRow(this.listSceneView, sceneUI);
|
| | | #region ■ 删除分享___________________________
|
| | |
|
| | | // //移除
|
| | | // var btnDelete = new RowDeleteButton();
|
| | | // btnDelete.TextID = R.MyInternationalizationString.RemoveBotton;
|
| | | // sceneRow.AddRightView(btnDelete);
|
| | | // btnDelete.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // //确定移除选中的场景?
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uConfirmRemoveSelectSceneMsg);
|
| | | // this.ShowConfirmMsg(msg, "DeleteShardScene", sceneRow, sceneUI);
|
| | | // };
|
| | | //}
|
| | | /// <summary>
|
| | | /// 删除分享
|
| | | /// </summary>
|
| | | private void DeleteShardData()
|
| | | {
|
| | | //选择的设备
|
| | | var listDevice = new List<CommonDevice>();
|
| | | foreach (var device in dicSelectDevice.Values)
|
| | | {
|
| | | listDevice.Add(device);
|
| | | }
|
| | | //选择的场景
|
| | | var listScene = new List<Common.SceneUI>();
|
| | | foreach (var scene in dicSelectScene.Values)
|
| | | {
|
| | | listScene.Add(scene);
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 删除共享场景
|
| | | ///// </summary>
|
| | | ///// <param name="row"></param>
|
| | | ///// <param name="sceneUI"></param>
|
| | | //public async void DeleteShardScene(SceneViewRow row, Common.SceneUI sceneUI)
|
| | | //{
|
| | | // var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.room, new List<CommonDevice>(), new List<Common.SceneUI>() { sceneUI });
|
| | | // if (result == true)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // row?.RemoveFromParent();
|
| | | // if (this.listDeviceView != null && this.listDeviceView.ChildrenCount == 0 && this.listSceneView.ChildrenCount == 0)
|
| | | // {
|
| | | // //什么都没有了,则关闭界面
|
| | | // this.CloseForm();
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | | //确认删除选择的共享场景和功能?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteShardContentMsg), () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //上传文件
|
| | | var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.lookRoom, listDevice, listScene);
|
| | | if (result == true)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //重新初始化界面
|
| | | this.InitMiddleFrame();
|
| | | });
|
| | | }
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | //#endregion
|
| | | #endregion
|
| | |
|
| | | //#region ■ 获取可以分享的设备_________________
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 获取分享的设备
|
| | | ///// </summary>
|
| | | ///// <returns></returns>
|
| | | //private List<CommonDevice> GetShardListDevice()
|
| | | //{
|
| | | // //获取这个房间里面的分享设备的路径
|
| | | // var listDeviceFile = new List<string>();
|
| | | // foreach (var ui in this.room.DeviceUIList)
|
| | | // {
|
| | | // if (ui.CommonDevice != null && memberShardInfo.dicAllMemberShard[this.room.FileName].Contains(ui.CommonDevice.FilePath) == true)
|
| | | // {
|
| | | // listDeviceFile.Add(ui.CommonDevice.FilePath);
|
| | | // }
|
| | | // }
|
| | | /// <summary>
|
| | | /// 获取分享的设备
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private List<CommonDevice> GetShardListDevice()
|
| | | {
|
| | | //获取这个房间里面的分享设备
|
| | | var listDevice = new List<CommonDevice>();
|
| | | foreach (var deviceFile in this.lookRoom.DeviceUIFilePathList)
|
| | | {
|
| | | if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceFile) == true)
|
| | | {
|
| | | var strArry = deviceFile.Split('_');
|
| | | if (strArry.Length < 3)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | //从分享文件中序列化回来
|
| | | var deviceData = HdlShardLogic.Current.GetShardFileContent(deviceFile);
|
| | | var device = ZigBee.Device.CommonDevice.CommonDeviceByByteString(strArry[1], System.Text.Encoding.UTF8.GetString(deviceData));
|
| | | if (device != null)
|
| | | {
|
| | | listDevice.Add(device);
|
| | | }
|
| | | }
|
| | | }
|
| | | return listDevice;
|
| | | }
|
| | |
|
| | | // var listFile = HdlShardLogic.Current.GetLocalAllShardFile();
|
| | | // var listDevice = new List<CommonDevice>();
|
| | | // foreach (string file in listFile)
|
| | | // {
|
| | | // //如果不是设备文件,或者这个房间里面没有这个设备
|
| | | // if (file.StartsWith(Common.LocalDevice.deviceFirstName) == false || listDeviceFile.Contains(file) == false)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // var strArry = file.Split('_');
|
| | | // if (strArry.Length < 3)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // //从分享文件中序列化回来
|
| | | // var deviceData = HdlShardLogic.Current.GetShardFileContent(file);
|
| | | // var device = ZigBee.Device.CommonDevice.CommonDeviceByByteString(strArry[1], System.Text.Encoding.UTF8.GetString(deviceData));
|
| | | // if (device != null)
|
| | | // {
|
| | | // listDevice.Add(device);
|
| | | // }
|
| | | // }
|
| | | // return listDevice;
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | | //#region ■ 一般方法___________________________
|
| | |
|
| | | //#endregion
|
| | | #endregion
|
| | | }
|
| | | }
|