| | |
| | | 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;
|
| | |
|
| | | ///// <summary>
|
| | | ///// 房间对象
|
| | | ///// </summary>
|
| | | //private Common.Room room = null;
|
| | | ///// <summary>
|
| | | ///// Tab的选择。1:功能Tab 2:场景Tab
|
| | | ///// </summary>
|
| | | //private int TabSelectIndex = 1;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | ///// </summary>
|
| | | ///// <param name="i_room">房间对象</param>
|
| | | ///// <param name="i_memberResult">成员信息</param>
|
| | | ///// <param name="i_memberShardInfo">成员的分享数据</param>
|
| | | //public void ShowForm(Common.Room i_room, MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo)
|
| | | //{
|
| | | // this.memberResult = i_memberResult;
|
| | | // this.memberShardInfo = i_memberShardInfo;
|
| | | // this.room = i_room;
|
| | |
|
| | | // //设置头部信息
|
| | | // base.SetTitleText(this.room.Name);
|
| | |
|
| | | // //分享
|
| | | // //var btnShard = new TopLayoutFinshView();
|
| | | // //btnShard.TextID = R.MyInternationalizationString.uShared;
|
| | | // //topFrameLayout.AddChidren(btnShard);
|
| | | // //btnShard.MouseUpEventHandler += (sender, e) =>
|
| | | // //{
|
| | | // // HdlThreadLogic.Current.Run(() =>
|
| | | // // {
|
| | | // // //确认分享
|
| | | // // this.DoSaveSharedContent();
|
| | | // // });
|
| | | // //};
|
| | |
|
| | | // ////初始化中部信息
|
| | | // //this.InitMiddleFrame();
|
| | | //}
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化中部信息
|
| | | ///// </summary>
|
| | | //private void InitMiddleFrame()
|
| | | //{
|
| | | // //清空bodyFrame
|
| | | // this.ClearBodyFrame();
|
| | |
|
| | | // //初始化Tab控件
|
| | | // var frame = this.InitTabControl();
|
| | |
|
| | | // this.listDeviceView = new VerticalScrolViewLayout();
|
| | | // listDeviceView.Y = frame.Bottom;
|
| | | // listDeviceView.Height = bodyFrameLayout.Height - frame.Bottom;
|
| | | // listDeviceView.Visible = this.TabSelectIndex == 1;
|
| | | // bodyFrameLayout.AddChidren(listDeviceView);
|
| | |
|
| | | // this.listSceneView = new VerticalScrolViewLayout();
|
| | | // listSceneView.Y = frame.Bottom;
|
| | | // listSceneView.Height = bodyFrameLayout.Height - frame.Bottom;
|
| | | // listSceneView.Visible = this.TabSelectIndex == 2;
|
| | | // bodyFrameLayout.AddChidren(listSceneView);
|
| | |
|
| | | // HdlThreadLogic.Current.Run(() =>
|
| | | // {
|
| | | // //初始化功能Tab列表
|
| | | // this.InitFunctionTabList();
|
| | | // //初始化场景Tab列表
|
| | | // this.InitSceneTabList();
|
| | | // });
|
| | | //}
|
| | |
|
| | | #endregion
|
| | |
|
| | | //#region ■ 初始化Tab控件______________________
|
| | |
|
| | | ///// <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);
|
| | |
|
| | | // //功能
|
| | | // 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 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);
|
| | |
|
| | | // //线
|
| | | // var btnLine = new ProgressLine();
|
| | | // btnLine.Gravity = Gravity.BottomLeft;
|
| | | // frameSwich.AddChidren(btnLine);
|
| | | // btnLine.SetValue(50, true);
|
| | |
|
| | | // if (this.TabSelectIndex == 2)
|
| | | // {
|
| | | // btnScene.TextColor = UserCenterColor.Current.SelectTextColor;
|
| | | // btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor;
|
| | | // btnLine.SetValue(50, 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;
|
| | |
|
| | | // //隐藏场景列表控件,显示设备列表控件
|
| | | // this.listSceneView.Visible = false;
|
| | | // this.listDeviceView.Visible = true;
|
| | | // };
|
| | |
|
| | | // //场景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;
|
| | |
|
| | | // //隐藏设备列表控件,显示场景列表控件
|
| | | // this.listDeviceView.Visible = false;
|
| | | // this.listSceneView.Visible = true;
|
| | | // };
|
| | |
|
| | | // return frameSwich;
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | | //#region ■ 显示功能Tab列表____________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化功能Tab列表
|
| | | ///// </summary>
|
| | | //private void InitFunctionTabList()
|
| | | //{
|
| | | // if (memberShardInfo.dicAllMemberShard.ContainsKey(this.room.FileName) == false)
|
| | | // {
|
| | | // memberShardInfo.dicAllMemberShard[this.room.FileName] = new HashSet<string>();
|
| | | // }
|
| | | // var listCheck = memberShardInfo.dicAllMemberShard[this.room.FileName];
|
| | |
|
| | | // foreach (var deviceUi in this.room.DeviceUIList)
|
| | | // {
|
| | | // var device = deviceUi.CommonDevice;
|
| | | // if (device == null || listCheck.Contains(device.FilePath) == true)
|
| | | // {
|
| | | // //异常,或者已经分享了的,不再显示
|
| | | // continue;
|
| | | // }
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (this.listDeviceView != null)
|
| | | // {
|
| | | // //添加设备行
|
| | | // var deviceRow = new DeviceSelectControl(device);
|
| | | // this.listDeviceView.AddChidren(deviceRow);
|
| | | // deviceRow.InitControl();
|
| | | // //不需要房间控件
|
| | | // deviceRow.RemoveRoomControl();
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | | //#region ■ 显示场景Tab列表____________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化场景Tab列表
|
| | | ///// </summary>
|
| | | //private void InitSceneTabList()
|
| | | //{
|
| | | // if (memberShardInfo.dicAllMemberShard.ContainsKey(this.room.FileName) == false)
|
| | | // {
|
| | | // memberShardInfo.dicAllMemberShard[this.room.FileName] = new HashSet<string>();
|
| | | // }
|
| | | // var listCheck = memberShardInfo.dicAllMemberShard[this.room.FileName];
|
| | |
|
| | | // foreach (var sceneUi in this.room.SceneUIList)
|
| | | // {
|
| | | // if (sceneUi == null || listCheck.Contains(sceneUi.FileName) == true)
|
| | | // {
|
| | | // //异常,或者已经分享了的,不再显示
|
| | | // continue;
|
| | | // }
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (this.listSceneView != null)
|
| | | // {
|
| | | // //添加场景行
|
| | | // var sceneRow = new SceneSelectRow(this.listSceneView, sceneUi);
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | | //#region ■ 获取选择的设备_____________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 获取选择的设备
|
| | | ///// </summary>
|
| | | ///// <param name="listCheck">重复检测</param>
|
| | | ///// <returns></returns>
|
| | | //private List<CommonDevice> GetSelectedDevice(HashSet<string> listCheck)
|
| | | //{
|
| | | // var listDevice = new List<CommonDevice>();
|
| | | // for (int i = 0; i < listDeviceView.ChildrenCount; i++)
|
| | | // {
|
| | | // var myView = listDeviceView.GetChildren(i);
|
| | | // var selectRow = (DeviceSelectControl)myView;
|
| | | // if (selectRow.IsSelected == true && listCheck.Contains(selectRow.device.FilePath) == false)
|
| | | // {
|
| | | // listCheck.Add(selectRow.device.FilePath);
|
| | | // listDevice.Add(selectRow.device);
|
| | | // }
|
| | | // }
|
| | | // return listDevice;
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | | //#region ■ 获取选择的场景_____________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 获取选择的场景
|
| | | ///// </summary>
|
| | | ///// <param name="listCheck">重复检测</param>
|
| | | ///// <returns></returns>
|
| | | //private List<Common.SceneUI> GetSelectedSceneUI(HashSet<string> listCheck)
|
| | | //{
|
| | | // var listSceneUI = new List<Common.SceneUI>();
|
| | | // for (int i = 0; i < listSceneView.ChildrenCount; i++)
|
| | | // {
|
| | | // var myView = listSceneView.GetChildren(i);
|
| | | // var selectRow = (SceneSelectRow)myView;
|
| | | // if (selectRow.IsSelected == true && listCheck.Contains(selectRow.sceneUI.Id.ToString()) == false)
|
| | | // {
|
| | | // listCheck.Add(selectRow.sceneUI.Id.ToString());
|
| | | // listSceneUI.Add(selectRow.sceneUI);
|
| | | // }
|
| | | // }
|
| | | // return listSceneUI;
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | | //#region ■ 确认分享___________________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 确认分享
|
| | | ///// </summary>
|
| | | //private async void DoSaveSharedContent()
|
| | | //{
|
| | | // var listCheck = new HashSet<string>();
|
| | | // //选择的设备
|
| | | // var listSelectDevice = this.GetSelectedDevice(listCheck);
|
| | | // //选择的场景
|
| | | // var listSelectScene = this.GetSelectedSceneUI(listCheck);
|
| | | // if (listSelectDevice.Count == 0 && listSelectScene.Count == 0)
|
| | | // {
|
| | | // //请选择目标后再执行分享操作
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uNotSelectDeviceBeforeSave);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // return;
|
| | | // }
|
| | | // //执行上传分享内容
|
| | | // var result = await HdlShardLogic.Current.DoUploadSharedContent(memberShardInfo, this.room, listSelectDevice, listSelectScene);
|
| | | // if (result == true)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // //重新刷新界面
|
| | | // this.InitMiddleFrame();
|
| | | // //分享成功
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uShardSuccess);
|
| | | // this.ShowMassage(msg);
|
| | | // });
|
| | | // }
|
| | | //}
|
| | |
|
| | | //#endregion
|
| | |
|
| | |
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 查看的房间对象
|
| | | /// </summary>
|
| | | private Common.Room lookRoom = null;
|
| | | /// <summary>
|
| | | /// 成员的分享数据
|
| | | /// 成员ID
|
| | | /// </summary>
|
| | | private MemberShardInfoData memberShardInfo = null;
|
| | | /// <summary>
|
| | | /// 当前选择的分支,1:场景 2:功能
|
| | | /// </summary>
|
| | | private int nowSelectIndex = 1;
|
| | | 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>
|
| | | private BottomClickButton btnShard = 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>
|
| | | /// 当前选择的分支 0:场景 1:功能
|
| | | /// </summary>
|
| | | private int nowSwitchIndex = 0;
|
| | | /// <summary>
|
| | | /// 当前选择的设备索引
|
| | | /// </summary>
|
| | | private string nowDeviceIndex = string.Empty;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_room">查看的房间对象</param>
|
| | | public void ShowForm(Common.Room i_room, MemberShardInfoData i_memberShardInfo)
|
| | | /// <param name="i_ChildAccountId">成员ID</param>
|
| | | public void ShowForm(Common.Room i_room, string i_ChildAccountId)
|
| | | {
|
| | | this.lookRoom = i_room;
|
| | | this.memberShardInfo = i_memberShardInfo;
|
| | | this.ChildAccountId = i_ChildAccountId;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddShared));
|
| | |
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //初始化分支控件
|
| | | this.InitSwitchControl();
|
| | | this.dicSelectDevice = new Dictionary<string, CommonDevice>();
|
| | | 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);
|
| | | frameDeviceTable.Visible = false;
|
| | |
|
| | | //初始化分支控件
|
| | | this.InitSwitchControl();
|
| | |
|
| | | //房间
|
| | | var btnRoom = new NormalViewControl(400, 63, true);
|
| | |
| | | btnRoom.TextAlignment = TextAlignment.CenterRight;
|
| | | bodyFrameLayout.AddChidren(btnRoom);
|
| | |
|
| | | //分享按钮
|
| | | this.btnShard = new BottomClickButton();
|
| | | btnShard.TextID = R.MyInternationalizationString.uShared2;
|
| | | bodyFrameLayout.AddChidren(btnShard);
|
| | | btnShard.Visible = false;
|
| | | btnShard.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //保存分享
|
| | | this.SaveShardData();
|
| | | };
|
| | |
|
| | | //初始化场景列表
|
| | |
| | | /// </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.SetDefultIndex(nowSwitchIndex);
|
| | | tabControl.SelectTabEvent += (tabIndex) =>
|
| | | {
|
| | | //场景分支选择
|
| | | if (this.nowSelectIndex == 1)
|
| | | this.nowSwitchIndex = tabIndex;
|
| | | if (tabIndex == 0)
|
| | | {
|
| | | return;
|
| | | //显示场景列表
|
| | | this.frameSceneTable.Visible = true;
|
| | | this.frameDeviceTable.Visible = false;
|
| | | }
|
| | | 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.frameSceneTable.Visible = true;
|
| | | this.frameDeviceTable.Visible = false;
|
| | | };
|
| | |
|
| | | frameFunc.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //功能分支选择
|
| | | if (this.nowSelectIndex == 2)
|
| | | else
|
| | | {
|
| | | return;
|
| | | //显示功能列表
|
| | | this.frameSceneTable.Visible = false;
|
| | | this.frameDeviceTable.Visible = true;
|
| | | }
|
| | | 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.frameSceneTable.Visible = false;
|
| | | this.frameDeviceTable.Visible = true;
|
| | | };
|
| | | //开始初始化场景功能切换控件
|
| | | var listTitle = new List<string>();
|
| | | listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
|
| | | listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
|
| | | tabControl.InitControl(listTitle);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //清空桌布
|
| | | this.frameSceneTable.RemoveAll();
|
| | |
|
| | | var listView = new VerticalFrameControl(29);
|
| | | listView.Y = Application.GetRealHeight(53);
|
| | | listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
|
| | | frameSceneTable.AddChidren(listView);
|
| | | //场景有点特殊,如果同一个房间内,已经分享了,则不再显示 |
| | | //如果这个场景是由嵌套而分享的,这个时候,它可以显示出来
|
| | | var listScene = new List<int>();
|
| | | var shardRoom = HdlShardLogic.Current.GetShardRoomFromMemory(lookRoom.Id);
|
| | | if (shardRoom == null)
|
| | | {
|
| | | listScene.AddRange(lookRoom.ListSceneId);
|
| | | }
|
| | | else
|
| | | {
|
| | | foreach (var dataId in lookRoom.ListSceneId)
|
| | | {
|
| | | if (shardRoom.ListSceneId.Contains(dataId) == false)
|
| | | {
|
| | | listScene.Add(dataId);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (listScene.Count == 0)
|
| | | {
|
| | | //无可共享的场景
|
| | | this.ShowNotDataImage(frameSceneTable, Language.StringByID(R.MyInternationalizationString.uNotCanShardSceneMsg), "Item/NotShardPic.png", 383, 279);
|
| | | return;
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | foreach (var data in lookRoom.SceneUIList)
|
| | | var listView = new VerticalFrameControl(3);
|
| | | listView.Y = Application.GetRealHeight(53);
|
| | | listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
|
| | | frameSceneTable.AddChidren(listView);
|
| | |
|
| | | foreach (var dataId in listScene)
|
| | | {
|
| | | var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId);
|
| | | if (data == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | //场景图片
|
| | | 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;
|
| | | }
|
| | | frameContr.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //选择
|
| | | btnSelect.IsSelected = !btnSelect.IsSelected;
|
| | | if (btnSelect.IsSelected == true)
|
| | | {
|
| | | dicSelectScene[data.Id] = data;
|
| | | if (this.btnShard.Visible == false)
|
| | | {
|
| | | this.btnShard.Visible = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | dicSelectScene.Remove(data.Id);
|
| | | if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
|
| | | {
|
| | | this.btnShard.Visible = false;
|
| | | }
|
| | | }
|
| | | };
|
| | | }
|
| | | //调整一下高度
|
| | | listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(185));
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | //清空桌布
|
| | | this.frameDeviceTable.RemoveAll();
|
| | |
|
| | | 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);
|
| | |
|
| | | var listView = new VerticalListControl(23);
|
| | | listView.Y = Application.GetRealHeight(23);
|
| | | listView.Height = Application.GetRealHeight(1437 - 23);
|
| | | frameBack.AddChidren(listView);
|
| | |
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | //获取分组后的设备列表
|
| | | var dicGroupDevice = this.GetAllGroupDevice();
|
| | | //初始化设备类型行
|
| | | this.InitDeviceObjectRow(dicGroupDevice, listView);
|
| | | if (dicGroupDevice.Count == 0)
|
| | | {
|
| | | //无可共享的设备
|
| | | this.ShowNotDataImage(frameDeviceTable, Language.StringByID(R.MyInternationalizationString.uNotCanShardDeviceMsg), "Item/NotShardPic.png", 383, 279);
|
| | | }
|
| | | else
|
| | | {
|
| | | 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.Radius = (uint)Application.GetRealHeight(58);
|
| | | frameDeviceTable.AddChidren(frameBack);
|
| | |
|
| | | var listView = new VerticalListControl(23);
|
| | | listView.Y = Application.GetRealHeight(23);
|
| | | listView.Height = Application.GetRealHeight(1437 - 23);
|
| | | frameBack.AddChidren(listView);
|
| | | //初始化设备类型行
|
| | | this.InitDeviceObjectRow(dicGroupDevice, listView);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | /// </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 HorizontalScrolViewLayout();
|
| | | scrolContr.X = ControlCommonResourse.XXLeft / 2;
|
| | | scrolContr.Width = bodyFrameLayout.Width - ControlCommonResourse.XXLeft / 2;
|
| | | scrolContr.Height = Application.GetRealHeight(160);
|
| | | var scrolContr = new RoomDeviceGroupMenuControl(dicData);
|
| | | this.frameDeviceTable.AddChidren(scrolContr);
|
| | |
|
| | | int oldTextId = 0;
|
| | | FrameLayout oldFrameBack = null;
|
| | | NormalViewControl oldBtnText = null;
|
| | |
|
| | | foreach (int textId in dicData.Keys)
|
| | | //设置初始值
|
| | | scrolContr.SetDefultIndex(nowDeviceIndex);
|
| | | scrolContr.SelectDeviceEvent += (listdevice) =>
|
| | | {
|
| | | var frameMain = new FrameLayout();
|
| | | frameMain.Height = scrolContr.Height;
|
| | | frameMain.Width = Application.GetRealWidth(250) + ControlCommonResourse.XXLeft;
|
| | | scrolContr.AddChidren(frameMain);
|
| | | var frameBack = new FrameLayoutControl();
|
| | | frameBack.UseClickStatu = false;
|
| | | frameBack.Gravity = Gravity.CenterHorizontal;
|
| | | frameBack.Height = frameMain.Height;
|
| | | frameBack.Width = Application.GetRealWidth(187);
|
| | | if (scrolContr.ChildrenCount == 1)
|
| | | {
|
| | | oldTextId = textId;
|
| | | frameBack.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
|
| | | oldFrameBack = frameBack;
|
| | | }
|
| | | else
|
| | | {
|
| | | frameBack.BackgroundImagePath = "Item/RoomIconBackground.png";
|
| | | }
|
| | | frameMain.AddChidren(frameBack);
|
| | | var btnText = new NormalViewControl(frameBack.Width - frameBack.Height, frameBack.Height, false);
|
| | | btnText.Gravity = Gravity.CenterHorizontal;
|
| | | btnText.TextID = textId;
|
| | | btnText.TextSize = 12;
|
| | | btnText.TextAlignment = TextAlignment.Center;
|
| | | if (scrolContr.ChildrenCount == 1)
|
| | | {
|
| | | btnText.TextColor = UserCenterColor.Current.White;
|
| | | oldBtnText = btnText;
|
| | | }
|
| | | else
|
| | | {
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | }
|
| | | frameBack.AddChidren(btnText, ChidrenBindMode.BindEventOnly);
|
| | |
|
| | | frameBack.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (oldTextId == textId)
|
| | | {
|
| | | //同一个东西
|
| | | return;
|
| | | }
|
| | | oldTextId = textId;
|
| | |
|
| | | //状态变更
|
| | | frameBack.BackgroundImagePath = "Room/RoomIconBackgroundSelected.png";
|
| | | btnText.TextColor = UserCenterColor.Current.White;
|
| | |
|
| | | oldFrameBack.BackgroundImagePath = "Room/RoomIconBackground.png";
|
| | | oldBtnText.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | oldFrameBack = frameBack;
|
| | | oldBtnText = btnText;
|
| | | //添加设备行
|
| | | this.AddDeviceRow(dicData[textId], listView);
|
| | | };
|
| | | }
|
| | |
|
| | | //添加设备行
|
| | | foreach (int textId in dicData.Keys)
|
| | | {
|
| | | this.AddDeviceRow(dicData[textId], listView);
|
| | | break;
|
| | | }
|
| | | this.nowDeviceIndex = scrolContr.nowSelectKeys;
|
| | | //添加设备行
|
| | | this.AddDeviceRow(listdevice, listView);
|
| | | };
|
| | | scrolContr.InitControl();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | foreach (var device in listDevice)
|
| | | {
|
| | | var frameRow = new FrameRowControl(listView.rowSpace / 2);
|
| | | frameRow.UseClickStatu = false;
|
| | | 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();
|
| | |
| | | var btnSelect = frameRow.AddMostRightEmptyIcon(69, 69);
|
| | | btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
|
| | | btnSelect.SelectedImagePath = "Item/ItemSelected.png";
|
| | | frameRow.ChangedChidrenBindMode(btnSelect, ChidrenBindMode.NotBind);
|
| | | btnSelect.ButtonClickEvent += (sender, e) =>
|
| | |
|
| | | string mainKeys = HdlDeviceCommonLogic.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.btnShard.Visible == false)
|
| | | {
|
| | | this.btnShard.Visible = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | dicSelectDevice.Remove(mainKeys);
|
| | | if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
|
| | | {
|
| | | this.btnShard.Visible = false;
|
| | | }
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | //列表自己有个23的Y轴坐标
|
| | | listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23), Application.GetRealHeight(300 - 23));
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 获取分组后的设备
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private Dictionary<int, List<CommonDevice>> GetAllGroupDevice()
|
| | | private Dictionary<string, List<CommonDevice>> GetAllGroupDevice()
|
| | | {
|
| | | //全部的设备
|
| | | var listDevice = lookRoom.GetRoomListDevice();
|
| | | var dic = new Dictionary<int, List<CommonDevice>>();
|
| | | var listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom);
|
| | | var dic = new Dictionary<string, List<CommonDevice>>();
|
| | | var shardRoom = HdlShardLogic.Current.GetShardRoomFromMemory(lookRoom.Id);
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | var typeInfo = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<ZigBee.Device.CommonDevice>() { device });
|
| | | if (device.Type == DeviceType.IASZone)
|
| | | string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
|
| | | if (shardRoom.ListDevice.Contains(mainkey) == true)
|
| | | {
|
| | | //这个强制为传感器
|
| | | typeInfo.BeloneTextId = R.MyInternationalizationString.uDeviceBelongId1200;
|
| | | typeInfo.ConcreteType = Common.DeviceConcreteType.Sensor;
|
| | | //如果已经分享了,则不显示
|
| | | continue;
|
| | | }
|
| | | if (device.Type == DeviceType.OnOffOutput)
|
| | | var typeInfo = HdlDeviceCommonLogic.Current.GetDeviceBelongEnumInfo(device);
|
| | | if (dic.ContainsKey(typeInfo.BeloneText) == false)
|
| | | {
|
| | | //继电器的时候,需要特殊处理
|
| | | 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>();
|
| | | }
|
| | | dic[typeInfo.BeloneText] = 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;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 保存分享___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 保存分享
|
| | | /// </summary>
|
| | | private void SaveShardData()
|
| | | {
|
| | | //选择的设备
|
| | | 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);
|
| | | }
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //上传文件
|
| | | var result = HdlShardLogic.Current.UploadSharedContent(this.ChildAccountId, this.lookRoom, listDevice, listScene);
|
| | | if (result == true)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //重新初始化界面
|
| | | this.InitMiddleFrame();
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|