| | |
| | | public void LoadPage() |
| | | { |
| | | |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView_AddIcon("CombinedDimming", |
| | | (s,c)=>{ |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl)).LoadTopView_AddIcon("CombinedDimming", |
| | | (s, c) => |
| | | { |
| | | try |
| | | { |
| | | var page = new AddGroupControlPage(null, |
| | | (newGC)=> { |
| | | (newGC) => |
| | | { |
| | | ReadGroupControlList(); |
| | | },()=> { }); |
| | | }, () => { }); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.LoadPage(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | |
| | | #region |
| | | contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) }); |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | |
| | | private void ReadGroupControlList() |
| | | { |
| | | |
| | | new System.Threading.Thread(() => { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var pack = ApiUtlis.Ins.HttpRequest.GetGroupControlList(); |
| | | if (pack != null) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | var groupControlList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString()); |
| | | FunctionList.List.groupControls.Clear(); |
| | | FunctionList.List.groupControls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString()); |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | LoadGroupControlView(groupControlList); |
| | | LoadGroupControlView(); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | |
| | | |
| | | private void LoadGroupControlView(List<GroupControl> list) |
| | | private void LoadGroupControlView() |
| | | { |
| | | #if DEBUG |
| | | if (list.Count == 0) |
| | | contentView.RemoveAll(); |
| | | |
| | | foreach (var groupControl in FunctionList.List.groupControls) |
| | | { |
| | | list.Add(new GroupControl() |
| | | var functionRow = new RowLayout() |
| | | { |
| | | name = "组合调光1", |
| | | roomIds = new List<string> {}, |
| | | sid = "00000000000000001", |
| | | type = "light", |
| | | }); |
| | | Height = Application.GetRealHeight(65), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | LineColor = 0x00000000 |
| | | }; |
| | | contentView.AddChidren(functionRow); |
| | | |
| | | list.Add(new GroupControl() |
| | | var btnRight = new Button() |
| | | { |
| | | name = "组合调光2", |
| | | roomIds = new List<string> { },//Room.CurrentSpatial.RoomList[0].roomId |
| | | sid = "00000000000000002", |
| | | type = "light", |
| | | }); |
| | | } |
| | | X = Application.GetRealWidth(339), |
| | | Gravity = Gravity.CenterVertical, |
| | | Width = Application.GetMinRealAverage(16), |
| | | Height = Application.GetMinRealAverage(16), |
| | | UnSelectedImagePath = "Public/Right.png", |
| | | }; |
| | | functionRow.AddChidren(btnRight); |
| | | |
| | | #endif |
| | | |
| | | if (list.Count == 0) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | contentView.RemoveAll(); |
| | | |
| | | foreach (var groupControl in list) |
| | | var btnFunctionName = new Button() |
| | | { |
| | | var functionRow = new RowLayout() |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(10), |
| | | Width = Application.GetRealWidth(308), |
| | | Height = Application.GetRealHeight(24), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | Text = groupControl.name, |
| | | }; |
| | | functionRow.AddChidren(btnFunctionName); |
| | | |
| | | var btnFunctionLocationInfo = new Button() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = btnFunctionName.Bottom, |
| | | Width = Application.GetRealWidth(308), |
| | | Height = Application.GetRealHeight(21), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | Text = groupControl.GetRoomListName(), |
| | | }; |
| | | functionRow.AddChidren(btnFunctionLocationInfo); |
| | | |
| | | |
| | | |
| | | functionRow.AddChidren( |
| | | new Button() |
| | | { |
| | | Height = Application.GetRealHeight(65), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | LineColor = 0x00000000 |
| | | }; |
| | | contentView.AddChidren(functionRow); |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(64), |
| | | Height = Application.GetRealHeight(1), |
| | | Width = Application.GetRealWidth(343), |
| | | BackgroundColor = CSS_Color.DividingLineColor, |
| | | }); |
| | | |
| | | var btnRight = new Button() |
| | | { |
| | | X = Application.GetRealWidth(339), |
| | | Gravity = Gravity.CenterVertical, |
| | | Width = Application.GetMinRealAverage(16), |
| | | Height = Application.GetMinRealAverage(16), |
| | | UnSelectedImagePath = "Public/Right.png", |
| | | }; |
| | | functionRow.AddChidren(btnRight); |
| | | |
| | | var btnFunctionName = new Button() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(10), |
| | | Width = Application.GetRealWidth(308), |
| | | Height = Application.GetRealHeight(24), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | Text = groupControl.name, |
| | | }; |
| | | functionRow.AddChidren(btnFunctionName); |
| | | |
| | | var btnFunctionLocationInfo = new Button() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = btnFunctionName.Bottom, |
| | | Width = Application.GetRealWidth(308), |
| | | Height = Application.GetRealHeight(21), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | Text = groupControl.GetRoomListName(), |
| | | }; |
| | | functionRow.AddChidren(btnFunctionLocationInfo); |
| | | |
| | | |
| | | |
| | | functionRow.AddChidren( |
| | | new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(64), |
| | | Height = Application.GetRealHeight(1), |
| | | Width = Application.GetRealWidth(343), |
| | | BackgroundColor = CSS_Color.DividingLineColor, |
| | | }); |
| | | |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => { |
| | | var page = new AddGroupControlPage(groupControl, |
| | | (newGC) => { |
| | | try |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | var page = new AddGroupControlPage(groupControl, |
| | | (newGC) => |
| | | { |
| | | try |
| | | { |
| | | if (newGC != null) |
| | | { |
| | | if (newGC != null) |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | groupControl.roomIds = newGC.uids; |
| | | btnFunctionLocationInfo.Text = newGC.GetUidListName(); |
| | | }); |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"刷新群控房间信息异常:{ex.Message}"); |
| | | } |
| | | },()=> { |
| | | LoadGroupControlView(FunctionList.List.groupControls); |
| | | }); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.LoadPage(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | functionRow.MouseUpEventHandler = eventHandler; |
| | | btnRight.MouseUpEventHandler = eventHandler; |
| | | btnFunctionName.MouseUpEventHandler = eventHandler; |
| | | btnFunctionLocationInfo.MouseUpEventHandler = eventHandler; |
| | | //groupControl.roomIds = newGC.roomIds; |
| | | //groupControl.uids = newGC.uids; |
| | | var localTemp = FunctionList.List.groupControls.Find((obj) => obj.deviceId == newGC.deviceId); |
| | | localTemp.roomIds = newGC.roomIds; |
| | | localTemp.uids = newGC.uids; |
| | | localTemp.sids = newGC.sids; |
| | | |
| | | var btnDelGroupControl = new Button() |
| | | btnFunctionLocationInfo.Text = newGC.GetUidListName(); |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"刷新群控房间信息异常:{ex.Message}"); |
| | | } |
| | | }, () => |
| | | { |
| | | LoadGroupControlView(); |
| | | }); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.LoadPage(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | functionRow.MouseUpEventHandler = eventHandler; |
| | | btnRight.MouseUpEventHandler = eventHandler; |
| | | btnFunctionName.MouseUpEventHandler = eventHandler; |
| | | btnFunctionLocationInfo.MouseUpEventHandler = eventHandler; |
| | | |
| | | var btnDelGroupControl = new Button() |
| | | { |
| | | TextColor = CSS_Color.MainBackgroundColor, |
| | | BackgroundColor = CSS_Color.WarningColor, |
| | | TextID = StringId.Del, |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | functionRow.AddRightView(btnDelGroupControl); |
| | | btnDelGroupControl.MouseUpEventHandler = (sender1, e1) => |
| | | { |
| | | var waitPage = new Loading(); |
| | | this.AddChidren(waitPage); |
| | | waitPage.Start(""); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | TextColor = CSS_Color.MainBackgroundColor, |
| | | BackgroundColor = CSS_Color.WarningColor, |
| | | TextID = StringId.Del, |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | functionRow.AddRightView(btnDelGroupControl); |
| | | btnDelGroupControl.MouseUpEventHandler = (sender1, e1) => { |
| | | var waitPage = new Loading(); |
| | | this.AddChidren(waitPage); |
| | | waitPage.Start(""); |
| | | new System.Threading.Thread(() => |
| | | try |
| | | { |
| | | try |
| | | var pack = ApiUtlis.Ins.HttpRequest.DelGroupControl(groupControl.userDeviceGroupControlId); |
| | | if (pack != null) |
| | | { |
| | | var pack = ApiUtlis.Ins.HttpRequest.DelGroupControl(groupControl.userDeviceGroupControlId); |
| | | if (pack != null) |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | try |
| | | { |
| | | try |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | list.Remove(groupControl); |
| | | LoadGroupControlView(list); |
| | | } |
| | | else |
| | | { |
| | | IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"刷新组控数据异常:{ex.Message}"); |
| | | var delTemp = FunctionList.List.groupControls.Find((obj) => groupControl.sid == obj.sid); |
| | | FunctionList.List.groupControls.Remove(delTemp); |
| | | LoadGroupControlView(); |
| | | } |
| | | }); |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"删除组控异常:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | if (waitPage != null) |
| | | else |
| | | { |
| | | IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | MainPage.Log($"刷新组控数据异常:{ex.Message}"); |
| | | } |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"删除组控异常:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (waitPage != null) |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | } |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |