| | |
| | | using System.Collections.Generic; |
| | | using System.Threading; |
| | | using HDL_ON.DAL.Server; |
| | | |
| | | #if DEBUG |
| | | using Xamarin.Essentials; |
| | | #endif |
| | | namespace HDL_ON.UI |
| | | { |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | List<PushMessageInfo> PushMessageInfoList = new List<PushMessageInfo>(); |
| | | |
| | | /// <summary> |
| | | /// 页面关闭时间 |
| | | /// </summary> |
| | | Action backAction; |
| | | |
| | | public override void RemoveFromParent() |
| | | { |
| | | UnregisterGetPushMessageAction(); |
| | | base.RemoveFromParent(); |
| | | backAction?.Invoke(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | /// <param name="backAction"></param> |
| | | public void LoadPage(Action backAction) |
| | | { |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(backAction); |
| | | this.backAction = backAction; |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(); |
| | | |
| | | AddTopMenuView(); |
| | | AddMessageView(); |
| | | MenuButtonSelect(showMesType); |
| | | |
| | | RegisterGetPushMessageAction(); |
| | | //测试代码 |
| | | //AddEmptyTipView(); |
| | | //TestLoad(); |
| | |
| | | MenuButtonSelect(0); |
| | | }; |
| | | allMenuButton.SelectAction = allAction; |
| | | #endregion |
| | | //测试提前当前推送ID |
| | | allMenuButton.ImageButton.MouseLongEventHandler = (sender, e) => |
| | | { |
| | | #if DEBUG |
| | | |
| | | #region 分享与功能 |
| | | CopyToClipboard("推送ID:" + OnAppConfig.Instance.PushId); |
| | | #else |
| | | //检测是否获取推送ID成功,提示推送注册是否正常 |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) |
| | | { |
| | | Utlis.ShowTip(Language.StringByID(StringId.PushException)); |
| | | } |
| | | else |
| | | { |
| | | Utlis.ShowTip(Language.StringByID(StringId.PushNormal)); |
| | | } |
| | | #endif |
| | | |
| | | }; |
| | | #endregion |
| | | |
| | | #region 分享与功能 |
| | | shareMenuButton = new MenuButton() |
| | | { |
| | | X = allMenuButton.Right, |
| | |
| | | shareMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/ShareOn.png"; |
| | | shareMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Share.png"; |
| | | shareMenuButton.TextButton.TextID = StringId.SharingAndFunctionality; |
| | | shareMenuButton.TextButton.IsMoreLines = true; |
| | | Action shateAction = () => |
| | | { |
| | | MenuButtonSelect(1); |
| | | }; |
| | | shareMenuButton.SelectAction = shateAction; |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 报警类 |
| | | #region 报警类 |
| | | alarmMenuButton = new MenuButton() |
| | | { |
| | | X = shareMenuButton.Right, |
| | |
| | | MenuButtonSelect(2); |
| | | }; |
| | | alarmMenuButton.SelectAction = alarmAction; |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 系统信息 |
| | | #region 系统信息 |
| | | systemMenuButton = new MenuButton() |
| | | { |
| | | X = alarmMenuButton.Right, |
| | |
| | | MenuButtonSelect(3); |
| | | }; |
| | | systemMenuButton.SelectAction = systemAction; |
| | | #endregion |
| | | #endregion |
| | | |
| | | } |
| | | |
| | |
| | | if (selectId == 0) |
| | | { |
| | | allMenuButton.IsSelected = true; |
| | | shareMenuButton.IsSelected = false; |
| | | alarmMenuButton.IsSelected = false; |
| | | systemMenuButton.IsSelected = false; |
| | | shareMenuButton.IsSelected = true; |
| | | alarmMenuButton.IsSelected = true; |
| | | systemMenuButton.IsSelected = true; |
| | | |
| | | } |
| | | else if (selectId == 1) |
| | |
| | | VerticalScrolViewMiddle.AddChidren(rowView); |
| | | |
| | | //标题 |
| | | var btnTilte = new Button() |
| | | var btnTilte = new TextButton() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(12), |
| | | Width = Application.GetRealWidth(320), |
| | | Height = Application.GetRealHeight(20), |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealWidth(20), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | Text = pushMessageInfo.messageTitle |
| | | Text = pushMessageInfo.messageContent, |
| | | //IsMoreLines = true, |
| | | }; |
| | | rowView.AddChidren(btnTilte); |
| | | // |
| | | var needHeight = btnTilte.GetMoreLineNeedHeight(); |
| | | btnTilte.IsMoreLines = true; |
| | | btnTilte.Height = needHeight; |
| | | rowView.Height = Application.GetRealHeight(45) + needHeight; |
| | | |
| | | //副标题 |
| | | var btnSubtitle = new Button() |
| | | var btnSubtitle = new TextButton() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = btnTilte.Bottom + Application.GetRealHeight(4), |
| | |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | | Text = pushMessageInfo.messageContent |
| | | Text = pushMessageInfo.messageTitle |
| | | }; |
| | | rowView.AddChidren(btnSubtitle); |
| | | |
| | |
| | | }; |
| | | rowView.AddChidren(btnDatetime); |
| | | |
| | | var lineView = new LineView(rowView.Height); |
| | | var lineView = new LineView(rowView.Height - Application.GetRealHeight(1)); |
| | | rowView.AddChidren(lineView); |
| | | |
| | | //删除按钮 |
| | |
| | | |
| | | |
| | | btnDatetime.Text = GetUnixToDateTime(pushMessageInfo.createTime); |
| | | //2020-12-23 去掉点击弹窗事件 |
| | | //EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | //{ |
| | | // new Alert(pushMessageInfo.messageTitle, pushMessageInfo.messageContent, Language.StringByID(StringId.Close)).Show(); |
| | | //}; |
| | | |
| | | //rowView.MouseUpEventHandler = eventHandler; |
| | | //btnTilte.MouseUpEventHandler = eventHandler; |
| | | //btnSubtitle.MouseUpEventHandler = eventHandler; |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | }; |
| | | VerticalScrolViewMiddle.AddChidren(bgView); |
| | | |
| | | var yearBtn = new Button() |
| | | var yearBtn = new TextButton() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(16), |
| | |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel, |
| | | IsBold = true, |
| | | Text = yearStr |
| | | }; |
| | | bgView.AddChidren(yearBtn); |
| | | yearBtn.Text = yearStr + Language.StringByID(StringId.Years); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | void GetPushMessageList(int queryType = 0) |
| | | { |
| | | bodyScrolView.RemoveAll(); |
| | | PushMessageInfoList.Clear(); |
| | | if(PushMessageInfoList == null) |
| | | { |
| | | PushMessageInfoList = new List<PushMessageInfo>(); |
| | | } |
| | | else |
| | | { |
| | | PushMessageInfoList.Clear(); |
| | | } |
| | | |
| | | YearMark = "";//标记清空 |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) |
| | | { |
| | | AddEmptyTipView(); |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | #region 测试 |
| | | #region 测试 |
| | | #if DEBUG |
| | | /// <summary> |
| | | /// |
| | |
| | | |
| | | #endif |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 标记所有推送消息已读 |
| | | /// </summary> |
| | | void PushSerivceMarkAllMessageRead() { |
| | | void PushSerivceMarkAllMessageRead() |
| | | { |
| | | new Thread(() => |
| | | { |
| | | var result = new HttpServerRequest().PushSerivceMarkAllMessageRead(); |
| | |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 注册收到推送监听 |
| | | /// </summary> |
| | | void RegisterGetPushMessageAction() |
| | | { |
| | | HDLCommon.GetPushMessageAction = () => |
| | | { |
| | | if (bodyView != null) |
| | | { |
| | | //Utlis.WriteLine("GetPushMessageAction M收到推送"); |
| | | GetPushMessageList(showMesType); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 取消收到推送监听 |
| | | /// </summary> |
| | | void UnregisterGetPushMessageAction() |
| | | { |
| | | HDLCommon.GetPushMessageAction = null; |
| | | } |
| | | |
| | | #if DEBUG |
| | | |
| | | /// <summary> |
| | | /// 复制到剪切板 |
| | | /// </summary> |
| | | /// <param name="text"></param> |
| | | void CopyToClipboard(string text) |
| | | { |
| | | Clipboard.SetTextAsync(text); |
| | | Utlis.ShowTip(text + "\n" + Language.StringByID(StringId.CopySuccess)); |
| | | } |
| | | #endif |
| | | |
| | | } |
| | | |