黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs
@@ -17,17 +17,17 @@
        /// </summary>
        private Common.Room lookRoom = null;
        /// <summary>
        /// 成员的分享数据
        /// 成员ID
        /// </summary>
        private MemberShardInfoData memberShardInfo = null;
        private string ChildAccountId = string.Empty;
        /// <summary>
        /// 设备桌布控件
        /// </summary>
        private FrameLayout frameDeviceTable = null;
        private NormalFrameLayout frameDeviceTable = null;
        /// <summary>
        /// 设备桌布控件
        /// </summary>
        private FrameLayout frameSceneTable = null;
        private NormalFrameLayout frameSceneTable = null;
        /// <summary>
        /// 删除按钮
        /// </summary>
@@ -41,9 +41,9 @@
        /// </summary>
        private Dictionary<string, CommonDevice> dicSelectDevice = new Dictionary<string, CommonDevice>();
        /// <summary>
        /// 当前选择的分支 1:场景  2:功能
        /// 当前选择的分支 0:场景  1:功能
        /// </summary>
        private int nowSwitchIndex = 1;
        private int nowSwitchIndex = 0;
        /// <summary>
        /// 当前选择的设备索引
        /// </summary>
@@ -58,10 +58,10 @@
        /// </summary>
        /// <param name="i_room">查看的房间对象</param>
        /// <param name="i_memberShardInfo">成员的分享数据</param>
        public void ShowForm(Common.Room i_room, MemberShardInfoData i_memberShardInfo)
        public void ShowForm(Common.Room i_room, string i_ChildAccountId)
        {
            this.lookRoom = i_room;
            this.memberShardInfo = i_memberShardInfo;
            this.ChildAccountId = i_ChildAccountId;
            //设置头部信息
            base.SetTitleText(i_room.Name);
@@ -81,12 +81,12 @@
            this.dicSelectScene = new Dictionary<int, Common.SceneUI>();
            //初始化桌布控件
            this.frameSceneTable = new FrameLayout();
            this.frameSceneTable = new NormalFrameLayout();
            frameSceneTable.Y = Application.GetRealHeight(132);
            frameSceneTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(132);
            bodyFrameLayout.AddChidren(frameSceneTable);
            this.frameDeviceTable = new FrameLayout();
            this.frameDeviceTable = new NormalFrameLayout();
            frameDeviceTable.Y = frameSceneTable.Y;
            frameDeviceTable.Height = frameSceneTable.Height;
            bodyFrameLayout.AddChidren(frameDeviceTable);
@@ -126,7 +126,7 @@
            tabControl.SelectTabEvent += (tabIndex) =>
            {
                this.nowSwitchIndex = tabIndex;
                if (tabIndex == 1)
                if (tabIndex == 0)
                {
                    //显示场景列表
                    this.frameSceneTable.Visible = true;
@@ -139,7 +139,11 @@
                    this.frameDeviceTable.Visible = true;
                }
            };
            tabControl.InitControl();
            //开始初始化场景功能切换控件
            var listTitle = new List<string>();
            listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
            listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
            tabControl.InitControl(listTitle);
        }
        #endregion
@@ -155,11 +159,12 @@
            this.frameSceneTable.RemoveAll();
            var listScene = new List<Common.SceneUI>();
            for (int i = 0; i < lookRoom.SceneUIList.Count; i++)
            foreach (var sceneId in lookRoom.ListSceneId)
            {
                if (HdlShardLogic.Current.IsFileExists(lookRoom.SceneUIList[i].FileName) == true)
                var scene = HdlShardLogic.Current.GetShardSceneFromMemory(sceneId);
                if (scene != null)
                {
                    listScene.Add(lookRoom.SceneUIList[i]);
                    listScene.Add(scene);
                }
            }
            if (listScene.Count == 0)
@@ -171,28 +176,24 @@
            HdlThreadLogic.Current.RunMainInThread(() =>
            {
                var listView = new VerticalFrameControl(29);
                var listView = new VerticalFrameControl(3);
                listView.Y = Application.GetRealHeight(53);
                listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
                frameSceneTable.AddChidren(listView);
                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);
                    //场景控件
                    var frameContr = new ScenePictrueControl();
                    listView.AddChidren(frameContr);
                    frameContr.InitControl(data);
                    var btnSelect = new IconViewControl(58);
                    btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
                    btnSelect.SelectedImagePath = "Item/ItemSelected.png";
                    btnSelect.X = Application.GetRealWidth(786);
                    btnSelect.X = Application.GetRealWidth(887);
                    btnSelect.Y = Application.GetRealHeight(35);
                    frameContr.AddChidren(btnSelect, ChidrenBindMode.BindEventOnly);
                    frameContr.AddChidren(btnSelect, ChidrenBindMode.BindEvent);
                    if (dicSelectScene.ContainsKey(data.Id) == true)
                    {
                        btnSelect.IsSelected = true;
@@ -219,6 +220,8 @@
                        }
                    };
                }
                //调整一下高度
                listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(185));
            });
        }
@@ -245,13 +248,13 @@
                }
                else
                {
                    var frameBack = new FrameLayoutControl(false);
                    frameBack.X = ControlCommonResourse.XXLeft;
                    var frameBack = new FrameLayout();
                    frameBack.X = HdlControlResourse.XXLeft;
                    frameBack.Y = Application.GetRealHeight(178);
                    frameBack.BackgroundColor = UserCenterColor.Current.White;
                    frameBack.Width = bodyFrameLayout.Width;
                    frameBack.Height = Application.GetRealHeight(1650);
                    frameBack.RadiusEx = 20;
                    frameBack.Radius = (uint)Application.GetRealHeight(58);
                    frameDeviceTable.AddChidren(frameBack);
                    var listView = new VerticalListControl(23);
@@ -273,7 +276,7 @@
        /// </summary>
        /// <param name="dicData"></param>
        /// <param name="listView"></param>
        private void InitDeviceObjectRow(Dictionary<int, List<CommonDevice>> dicData, VerticalListControl listView)
        private void InitDeviceObjectRow(Dictionary<string, List<CommonDevice>> dicData, VerticalListControl listView)
        {
            var scrolContr = new RoomDeviceGroupMenuControl(dicData);
            this.frameDeviceTable.AddChidren(scrolContr);
@@ -300,19 +303,21 @@
        private void AddDeviceRow(List<CommonDevice> listDevice, VerticalListControl listView)
        {
            listView.RemoveAll();
            //还原高度
            listView.RecoverHeight();
            foreach (var device in listDevice)
            {
                var frameRow = new FrameRowControl(listView.rowSpace / 2);
                frameRow.LeftOffset = Application.GetRealWidth(46) - ControlCommonResourse.XXLeft;
                frameRow.RightOffset = -ControlCommonResourse.XXLeft;
                frameRow.LeftOffset = Application.GetRealWidth(46) - HdlControlResourse.XXLeft;
                frameRow.RightOffset = -HdlControlResourse.XXLeft;
                listView.AddChidren(frameRow);
                //图标
                var btnIcon = frameRow.AddLeftIcon(81);
                Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
                HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnIcon, device);
                //名称
                var btnView = frameRow.AddLeftCaption(string.Empty, 600);
                btnView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
                btnView.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                btnView.TextSize = 15;
                //底线
                frameRow.AddBottomLine();
@@ -321,7 +326,7 @@
                btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
                btnSelect.SelectedImagePath = "Item/ItemSelected.png";
                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
                string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
                if (dicSelectDevice.ContainsKey(mainKeys) == true)
                {
                    btnSelect.IsSelected = true;
@@ -348,6 +353,8 @@
                    }
                };
            }
            //列表自己有个23的Y轴坐标
            listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23), Application.GetRealHeight(300 - 23));
        }
        #endregion
@@ -358,53 +365,19 @@
        /// 获取分组后的设备
        /// </summary>
        /// <returns></returns>
        private Dictionary<int, List<CommonDevice>> GetAllGroupDevice()
        private Dictionary<string, List<CommonDevice>> GetAllGroupDevice()
        {
            //全部的设备
            var listDevice = this.GetShardListDevice();
            var dic = new Dictionary<int, List<CommonDevice>>();
            var dic = new Dictionary<string, List<CommonDevice>>();
            foreach (var device in listDevice)
            {
                var typeInfo = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<ZigBee.Device.CommonDevice>() { device });
                if (device.Type == DeviceType.IASZone)
                var typeInfo = HdlDeviceCommonLogic.Current.GetDeviceBelongEnumInfo(device);
                if (dic.ContainsKey(typeInfo.BeloneText) == false)
                {
                    //这个强制为传感器
                    typeInfo.BeloneTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                    typeInfo.ConcreteType = Common.DeviceConcreteType.Sensor;
                    dic[typeInfo.BeloneText] = new List<CommonDevice>();
                }
                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);
                dic[typeInfo.BeloneText].Add(device);
            }
            return dic;
        }
@@ -434,10 +407,10 @@
            //确认删除选择的共享场景和功能?
            this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteShardContentMsg), () =>
            {
                HdlThreadLogic.Current.RunThread(async () =>
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //上传文件
                    var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.lookRoom, listDevice, listScene);
                    var result = HdlShardLogic.Current.DeleteSharedContent(this.ChildAccountId, this.lookRoom, listDevice, listScene);
                    if (result == true)
                    {
                        HdlThreadLogic.Current.RunMain(() =>
@@ -462,22 +435,12 @@
        {
            //获取这个房间里面的分享设备
            var listDevice = new List<CommonDevice>();
            foreach (var deviceFile in this.lookRoom.DeviceUIFilePathList)
            foreach (var deviceKey in this.lookRoom.ListDevice)
            {
                if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceFile) == true)
                var device = HdlShardLogic.Current.GetShardDeviceFromMemory(deviceKey);
                if (device != null)
                {
                    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);
                    }
                    listDevice.Add(device);
                }
            }
            return listDevice;