| | |
| | | |
| | | VerticalScrolViewLayout functionListView; |
| | | |
| | | SecurityAlarm securityAlarm; |
| | | Action<SecurityAlarm> refreshAction; |
| | | List<SecurityOutput> outputList = new List<SecurityOutput>(); |
| | | /// <summary> |
| | | /// 本地功能转换的输出列表(灯光、场景) |
| | | /// </summary> |
| | | List<SecurityOutput> allocatedList = new List<SecurityOutput>(); |
| | | |
| | | List<Function> allocatedList = new List<Function>(); |
| | | SecurityAlarm alarm; |
| | | |
| | | public AddOutputPage(SecurityAlarm function, Action<SecurityAlarm> action) |
| | | public AddOutputPage(SecurityAlarm inOutput ,Action<SecurityAlarm> action) |
| | | { |
| | | bodyView = this; |
| | | securityAlarm = function; |
| | | refreshAction = action; |
| | | alarm = inOutput; |
| | | } |
| | | |
| | | |
| | |
| | | Text = DB_ResidenceData.Instance.CurFloor.roomName, |
| | | }; |
| | | showdFunctionTypeRow.AddChidren(btnFloor); |
| | | LoadDialog_ChangeFloor(); |
| | | |
| | | #endregion |
| | | |
| | |
| | | bodyView.AddChidren(functionListView); |
| | | |
| | | |
| | | SetData(); |
| | | |
| | | |
| | | |
| | | |
| | | foreach (var function in FunctionList.List.Functions) |
| | | { |
| | | if (!MainPage.SceneSupportFunctionList.Contains(function.spk)) |
| | | { |
| | | continue; |
| | | } |
| | | if (function == null) |
| | | { |
| | | continue; |
| | | } |
| | | function.roomIds.Remove(null); |
| | | allocatedList.Add(function); |
| | | } |
| | | |
| | | LoadFunctionListRow(null); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | LoadFunctionListRow(); |
| | | |
| | | var bottomView = new FrameLayout() |
| | | { |
| | |
| | | bottomView.AddChidren(btnConfrim); |
| | | btnConfrim.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | securityAlarm.output = new List<SecurityOutput>(); |
| | | foreach (var output in outputList) |
| | | { |
| | | if (output.addCondition) |
| | | { |
| | | securityAlarm.output.Add(output); |
| | | } |
| | | } |
| | | this.RemoveFromParent(); |
| | | refreshAction?.Invoke(securityAlarm); |
| | | refreshAction?.Invoke(alarm); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 配置数据 |
| | | /// </summary> |
| | | void SetData(string roomId="") |
| | | { |
| | | allocatedList.Clear(); |
| | | foreach (var function in FunctionList.List.GetLightList()) |
| | | { |
| | | if (function == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (!string.IsNullOrEmpty(roomId) && roomId == "ALLSELECT") |
| | | { |
| | | if (!function.roomIds.Contains(roomId)) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | function.roomIds.Remove(null); |
| | | var tempStatus = new List<SecurityOutputStatus>(); |
| | | tempStatus.Add(new SecurityOutputStatus() { key = FunctionAttributeKey.OnOff, value = "on" }); |
| | | allocatedList.Add(new SecurityOutput |
| | | { |
| | | target_type = "0", |
| | | sid = function.sid, |
| | | status = tempStatus, |
| | | name = function.name, |
| | | RoomName = function.GetRoomListName(), |
| | | }); |
| | | } |
| | | |
| | | |
| | | foreach (var scene in FunctionList.List.scenes) |
| | | { |
| | | if (scene == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (!string.IsNullOrEmpty(roomId)) |
| | | { |
| | | if (!scene.roomIds.Contains(roomId)) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | scene.roomIds.Remove(null); |
| | | var tempStatus = new List<SecurityOutputStatus>(); |
| | | tempStatus.Add(new SecurityOutputStatus() { key = "value", value = "0" }); |
| | | allocatedList.Add(new SecurityOutput |
| | | { |
| | | target_type = "1", |
| | | sid = scene.sid, |
| | | status = tempStatus, |
| | | name = scene.name, |
| | | RoomName = scene.GetRoomListName(), |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // <summary> |
| | | /// 显示功能Row |
| | | /// </summary> |
| | | void LoadFunctionListRow(List<Function> functions) |
| | | void LoadFunctionListRow() |
| | | { |
| | | functionListView.RemoveAll(); |
| | | if (functions == null) |
| | | foreach (var function in allocatedList) |
| | | { |
| | | functions = allocatedList; |
| | | } |
| | | foreach (var function in functions) |
| | | { |
| | | var output = securityAlarm.output.Find((obj) => obj.sid == function.sid); |
| | | var output = alarm.output.Find((obj) => obj.sid == function.sid); |
| | | if (output == null) |
| | | { |
| | | output = new SecurityOutput(); |
| | | output = new SecurityOutput() { status = new List<SecurityOutputStatus> { new SecurityOutputStatus { |
| | | key = FunctionAttributeKey.OnOff, |
| | | value = "on" |
| | | } } }; |
| | | |
| | | output.sid = function.sid; |
| | | } |
| | | else |
| | | { |
| | | output.addCondition = true; |
| | | } |
| | | outputList.Add(output); |
| | | //else |
| | | //{ |
| | | // output.addCondition = true; |
| | | //} |
| | | |
| | | FrameLayout functionRow = new FrameLayout() |
| | | { |
| | |
| | | Y = Application.GetRealHeight(24), |
| | | Width = Application.GetRealWidth(200), |
| | | Height = Application.GetRealHeight(41), |
| | | Text = function.GetRoomListName(), |
| | | Text = function.RoomName, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel, |
| | |
| | | |
| | | btnChooseIcon.MouseUpEventHandler = (sender, e) => { |
| | | btnChooseIcon.IsSelected = !btnChooseIcon.IsSelected; |
| | | var tempLocal = alarm.input.Find((obj) => |
| | | obj.sid == output.sid |
| | | ); |
| | | if (btnChooseIcon.IsSelected) |
| | | { |
| | | output.addCondition = true; |
| | | if (output.status.Count == 0) |
| | | { |
| | | ShowStateDialog(output, btnState,btnChooseIcon); |
| | | } |
| | | //input.addCondition = true; |
| | | if (tempLocal == null) |
| | | alarm.output.Add(output); |
| | | } |
| | | else |
| | | { |
| | | output.addCondition = false; |
| | | //input.addCondition = false; |
| | | if (tempLocal != null) |
| | | { |
| | | alarm.output.Remove(output); |
| | | } |
| | | } |
| | | }; |
| | | btnState.MouseUpEventHandler = (sender, e) => |
| | |
| | | ShowStateDialog(output, btnState, btnChooseIcon); |
| | | }; |
| | | |
| | | var localOutput = alarm.output.Find((obj) => obj.sid == output.sid); |
| | | |
| | | if (output.addCondition) |
| | | if (localOutput!=null) |
| | | { |
| | | btnChooseIcon.IsSelected = true; |
| | | btnState.Text = output.StateText(); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void ShowStateDialog(SecurityOutput output, Button btnState, Button btnChoose = null) |
| | |
| | | { |
| | | Height = Application.GetRealHeight(44), |
| | | TextAlignment = TextAlignment.Center, |
| | | TextColor = CSS_Color.MainColor, |
| | | SelectedTextColor = CSS_Color.MainColor, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | TextID = StringId.On |
| | | TextID = StringId.On, |
| | | }; |
| | | optinView.AddChidren(btnOpen); |
| | | |
| | | optinView.AddChidren(new Button() |
| | | { |
| | | Height = 1, |
| | |
| | | { |
| | | Height = Application.GetRealHeight(44), |
| | | TextAlignment = TextAlignment.Center, |
| | | SelectedTextColor = CSS_Color.MainColor, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextID = StringId.OFF, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | }; |
| | | optinView.AddChidren(btnClose); |
| | | if (output.status.Count > 0) |
| | | { |
| | | btnOpen.IsSelected = output.status[0].value.ToLower() == "on"; |
| | | btnClose.IsSelected = !btnOpen.IsSelected; |
| | | } |
| | | |
| | | |
| | | Button btnCancel = new Button() |
| | |
| | | value = "on", |
| | | } |
| | | }; |
| | | output.addCondition = true; |
| | | if (btnChoose != null) |
| | | var localInput = alarm.output.Find((obj) => |
| | | obj.sid == output.sid |
| | | ); |
| | | if (localInput == null) |
| | | { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | |
| | | value = "off", |
| | | } |
| | | }; |
| | | output.addCondition = true; |
| | | if (btnChoose != null) |
| | | var localInput = alarm.output.Find((obj) => |
| | | obj.sid == output.sid |
| | | ); |
| | | if (localInput == null) |
| | | { |
| | | btnChoose.IsSelected = true; |
| | | } |
| | |
| | | void LoadDialog_ChangeFloor() |
| | | { |
| | | string nowSelectId = null; |
| | | btnFloor.MouseUpEventHandler += (sender, e) => |
| | | btnFloor.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | var listAllFun = new List<Function>(); |
| | | listAllFun.AddRange(allocatedList); |
| | | //listAllFun.AddRange(allocatedList); |
| | | |
| | | //显示下拉界面 |
| | | var form = new FloorRoomSelectPopupView(); |
| | | form.ShowDeviceFunctionView(btnFloor, listAllFun, (selectId, listFun) => |
| | | { |
| | | nowSelectId = selectId; |
| | | SetData(selectId); |
| | | //重新刷新设备列表 |
| | | this.LoadFunctionListRow(listFun); |
| | | this.LoadFunctionListRow(); |
| | | }, nowSelectId); |
| | | }; |
| | | } |