| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.DriverLayer; |
| | | using HDL_ON.Entity; |
| | | using Shared; |
| | |
| | | /// <param name="button"></param> |
| | | void LoadEvent_ControlTV(TV tV,Button button) |
| | | { |
| | | button.MouseUpEventHandler = (sender, e) => { |
| | | button.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | tV.ControlTV(InfraredCode_TV.Power); |
| | | }; |
| | | } |
| | |
| | | { |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | |
| | | //房间删除事件 |
| | | Action backAction = () => { |
| | | GetUnreadPushMessages(); |
| | | }; |
| | | |
| | | var skipPage = new MessageCenterPage(); |
| | | MainPage.BasePageView.AddChidren(skipPage); |
| | | skipPage.LoadPage(); |
| | | skipPage.LoadPage(backAction); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | btnMsgBg.MouseUpEventHandler = eventHandler; |
| | |
| | | btnMsgIcon.MouseUpEventHandler = eventHandler; |
| | | } |
| | | |
| | | |
| | | #region 查询未读读消息列表 |
| | | /// <summary> |
| | | /// 是否正在读取 |
| | | /// </summary> |
| | | bool isGetting; |
| | | /// <summary> |
| | | /// 查询未读消息并显示 |
| | | /// </summary> |
| | | void GetUnreadPushMessages() |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | if (isGetting) return; |
| | | |
| | | isGetting = true; |
| | | |
| | | var result = new HttpServerRequest().PushSerivceGetPushmessagelist(); |
| | | if (result.Code == StateCode.SUCCESS) |
| | | { |
| | | //未读的消息列表 |
| | | var unreadList = new List<PushMessageInfo>(); |
| | | |
| | | var pushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString()); |
| | | |
| | | if (pushMessageInfoList != null && pushMessageInfoList.Count > 0) |
| | | { |
| | | foreach (var info in pushMessageInfoList) |
| | | { |
| | | if (!info.isRead) |
| | | { |
| | | unreadList.Add(info); |
| | | break; // 跳出循环 |
| | | } |
| | | } |
| | | |
| | | if (unreadList != null && unreadList.Count > 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | ShowMesBtnState(unreadList[0], false); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | ShowMesBtnState(pushMessageInfoList[0], true); |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | finally |
| | | { |
| | | isGetting = false; |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示未读读消息 |
| | | /// </summary> |
| | | /// <param name="pushMessageInfo"></param> |
| | | /// <param name="allRead">所有都已读</param> |
| | | void ShowMesBtnState(PushMessageInfo pushMessageInfo, bool allRead) |
| | | { |
| | | if (bodyView == null) return; |
| | | btnMsg.Text = pushMessageInfo.messageTitle + ": " + pushMessageInfo.messageContent; |
| | | btnMsgTime.Text = GetUnixToDateTime(pushMessageInfo.createTime); |
| | | btnMsgIcon.IsSelected = !allRead; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重置未读消息控件 |
| | | /// </summary> |
| | | void ResetMesBtnRead() |
| | | { |
| | | if (bodyView == null) return; |
| | | btnMsg.Text = "..."; |
| | | btnMsgTime.Text = "00:00"; |
| | | btnMsgIcon.IsSelected = false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 时间格式转换处理 |
| | | /// </summary> |
| | | /// <param name="time">毫秒时间戳</param> |
| | | /// <returns></returns> |
| | | string GetUnixToDateTime(long time) |
| | | { |
| | | try |
| | | { |
| | | return Utlis.UnixToDateTimeWithFormatMS(time, "HH:mm"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |