From 4a5e9d0447aae9b264a98ea1f4c95417d0f4aa91 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 01 十二月 2020 17:20:01 +0800 Subject: [PATCH] Merge branch 'master' into WJC --- HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs | 499 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 499 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs new file mode 100644 index 0000000..602b8eb --- /dev/null +++ b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs @@ -0,0 +1,499 @@ +锘縰sing System; +using Shared; +using HDL_ON.UI.CSS; +using System.Collections.Generic; +using System.Threading; +using HDL_ON.DAL.Server; + +namespace HDL_ON.UI +{ + /// <summary> + /// 淇℃伅涓績椤甸潰 + /// </summary> + public class MessageCenterPage : FrameLayout + { + FrameLayout bodyView; + /// <summary> + /// 褰撳墠 + /// </summary> + VerticalScrolViewLayout bodyScrolView; + /// <summary> + /// 鍐呭涓虹┖鎻愮ずView + /// </summary> + EmptyTipView emptyTipView; + + /// <summary> + /// menuView + /// </summary> + FrameLayout menuView; + MenuButton allMenuButton; + MenuButton shareMenuButton; + MenuButton alarmMenuButton; + MenuButton systemMenuButton; + FrameLayout messageView; + + /// <summary> + /// 鏄剧ず鐨勬秷鎭被鍨� + /// 1鍏ㄩ儴 2鍒嗕韩涓庡姛鑳� 3鎶ヨ绫� 4绯荤粺淇℃伅 + /// </summary> + int showMesType = 1; + /// <summary> + /// 鎺ㄩ�佹秷鎭垪琛� + /// </summary> + List<PushMessageInfo> PushMessageInfoList = new List<PushMessageInfo>(); + + + /// <summary> + /// + /// </summary> + public MessageCenterPage() + { + bodyView = this; + BackgroundColor = CSS_Color.BackgroundColor; + } + + /// <summary> + /// + /// </summary> + public void LoadPage() + { + new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(); + + AddTopMenuView(); + AddMessageView(); + MenuButtonSelect(1); + //TestLoad(); + GetPushMessageList(); + } + + /// <summary> + /// 椤堕儴鑿滃崟閫夐」 + /// </summary> + void AddTopMenuView() + { + + menuView = new FrameLayout() + { + Y = Application.GetRealHeight(64), + Height = Application.GetRealWidth(117), + BackgroundColor = CSS_Color.MainBackgroundColor, + }; + bodyView.AddChidren(menuView); + + + #region 鍏ㄩ儴鎸夐挳 + allMenuButton = new MenuButton() + { + X = Application.GetRealWidth(15), + Y = Application.GetRealWidth(16), + }; + menuView.AddChidren(allMenuButton); + allMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/AllOn.png"; + allMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/All.png"; + allMenuButton.TextButton.TextID = StringId.All; + Action allAction = () => + { + MenuButtonSelect(1); + }; + allMenuButton.SelectAction = allAction; + #endregion + + #region 鍒嗕韩涓庡姛鑳� + shareMenuButton = new MenuButton() + { + X = allMenuButton.Right, + Y = Application.GetRealWidth(16), + }; + menuView.AddChidren(shareMenuButton); + shareMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/ShareOn.png"; + shareMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Share.png"; + shareMenuButton.TextButton.TextID = StringId.SharingAndFunctionality; + Action shateAction = () => + { + MenuButtonSelect(2); + }; + shareMenuButton.SelectAction = shateAction; + #endregion + + #region 鎶ヨ绫� + alarmMenuButton = new MenuButton() + { + X = shareMenuButton.Right, + Y = Application.GetRealWidth(16), + }; + menuView.AddChidren(alarmMenuButton); + alarmMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/AlarmOn.png"; + alarmMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Alarm.png"; + alarmMenuButton.TextButton.TextID = StringId.AlarmType; + Action alarmAction = () => + { + MenuButtonSelect(3); + }; + alarmMenuButton.SelectAction = alarmAction; + #endregion + + #region 绯荤粺淇℃伅 + systemMenuButton = new MenuButton() + { + X = alarmMenuButton.Right, + Y = Application.GetRealWidth(16), + }; + menuView.AddChidren(systemMenuButton); + systemMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/SystemOn.png"; + systemMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/System.png"; + systemMenuButton.TextButton.TextID = StringId.SystemMessage; + Action systemAction = () => + { + MenuButtonSelect(4); + }; + systemMenuButton.SelectAction = systemAction; + #endregion + + } + + /// <summary> + /// 涓棿淇℃伅鍐呭 + /// </summary> + void AddMessageView() + { + int messageViewY = menuView.Bottom + Application.GetRealWidth(8); + int messageViewHeight = bodyView.Height - messageViewY; + messageView = new FrameLayout() + { + Y = messageViewY, + Height = messageViewHeight, + BackgroundColor = CSS_Color.MainBackgroundColor, + }; + bodyView.AddChidren(messageView); + + bodyScrolView = new VerticalScrolViewLayout() + { + Height = messageViewHeight, + }; + messageView.AddChidren(bodyScrolView); + + } + + /// <summary> + /// + /// </summary> + /// <param name="selectId">1鍏ㄩ儴 2鍒嗕韩涓庡姛鑳� 3鎶ヨ绫� 4绯荤粺淇℃伅</param> + void MenuButtonSelect(int selectId) + { + showMesType = selectId; + + if (selectId == 1) + { + allMenuButton.IsSelected = true; + shareMenuButton.IsSelected = false; + alarmMenuButton.IsSelected = false; + systemMenuButton.IsSelected = false; + + } + else if (selectId == 2) + { + allMenuButton.IsSelected = false; + shareMenuButton.IsSelected = true; + alarmMenuButton.IsSelected = false; + systemMenuButton.IsSelected = false; + + } + else if (selectId == 3) + { + allMenuButton.IsSelected = false; + shareMenuButton.IsSelected = false; + alarmMenuButton.IsSelected = true; + systemMenuButton.IsSelected = false; + } + else if (selectId == 4) + { + allMenuButton.IsSelected = false; + shareMenuButton.IsSelected = false; + alarmMenuButton.IsSelected = false; + systemMenuButton.IsSelected = true; + + } + } + + + + /// <summary> + /// 娣诲姞鍐呭涓虹┖鎻愮ず椤甸潰 + /// </summary> + void AddEmptyTipView() + { + emptyTipView = new EmptyTipView() + { + Gravity = Gravity.Center + }; + messageView.AddChidren(emptyTipView); + } + + /// <summary> + /// 鍔犺浇鎶ヨ淇℃伅RowView + /// </summary> + /// <param name="VerticalScrolViewMiddle"></param> + /// <param name="pushMessageInfo"></param> + void AddRowView(VerticalScrolViewLayout VerticalScrolViewMiddle, PushMessageInfo pushMessageInfo) + { + var rowView = new RowLayout() + { + Height = Application.GetRealHeight(65), + LineColor = CSS_Color.MainBackgroundColor, + }; + VerticalScrolViewMiddle.AddChidren(rowView); + + //鏍囬 + var btnTilte = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealHeight(12), + Width = Application.GetRealWidth(320), + Height = Application.GetRealHeight(20), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + Text = pushMessageInfo.messageTitle + }; + rowView.AddChidren(btnTilte); + + //鍓爣棰� + var btnSubtitle = new Button() + { + X = Application.GetRealWidth(16), + Y = btnTilte.Bottom + Application.GetRealHeight(4), + Width = Application.GetRealWidth(240), + Height = Application.GetRealHeight(17), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + Text = pushMessageInfo.messageContent + }; + rowView.AddChidren(btnSubtitle); + + //鏃ユ湡 + var btnDatetime = new Button() + { + X = Application.GetRealWidth(259), + Y = btnTilte.Bottom + Application.GetRealHeight(4), + Width = Application.GetRealWidth(100), + Height = Application.GetRealHeight(17), + TextAlignment = TextAlignment.CenterRight, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + Text = pushMessageInfo.createTime + }; + rowView.AddChidren(btnDatetime); + + var lineView = new LineView(rowView.Height); + rowView.AddChidren(lineView); + + //鍒犻櫎鎸夐挳 + var deleteBtn = new Button() + { + TextID = StringId.Del, + BackgroundColor = CSS_Color.AuxiliaryColor2, + TextColor = CSS_Color.MainBackgroundColor, + TextSize = CSS_FontSize.TextFontSize, + }; + rowView.AddRightView(deleteBtn); + deleteBtn.MouseUpEventHandler = (sender, e) => + { + rowView.RemoveFromParent(); + }; + + //EventHandler<MouseEventArgs> eventHandler = (sender, e) => + //{ + //}; + + //btnTilte.MouseUpEventHandler = eventHandler; + //btnSubtitle.MouseUpEventHandler = eventHandler; + } + + /// <summary> + /// 鍔犺浇骞翠唤鏍囬 + /// </summary> + /// <param name="VerticalScrolViewMiddle"></param> + /// <param name="yearStr"></param> + void AddYearRowView(VerticalScrolViewLayout VerticalScrolViewMiddle, string yearStr) + { + var bgView = new FrameLayout() + { + Height = Application.GetRealHeight(57), + }; + VerticalScrolViewMiddle.AddChidren(bgView); + + var yearBtn = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealHeight(16), + Width = Application.GetRealWidth(320), + Height = Application.GetRealHeight(33), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel, + IsBold = true, + Text = yearStr + }; + bgView.AddChidren(yearBtn); + } + + /// <summary> + /// + /// </summary> + void GetPushMessageList() + { + var waitPage = new Loading(); + waitPage.Start(Language.StringByID(StringId.PleaseWait)); + bodyScrolView.RemoveAll(); + PushMessageInfoList.Clear(); + + new Thread(() => + { + try + { + var result = new HttpServerRequest().PushSerivceGetPushmessagelist(); + if (result.Code == StateCode.SUCCESS) + { + PushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString()); + Application.RunOnMainThread(() => + { + if (PushMessageInfoList != null && PushMessageInfoList.Count > 0) + { + + ParseAndDisplayPushList(); + } + else + { + AddEmptyTipView(); + } + }); + } + else + { + Application.RunOnMainThread(() => + { + AddEmptyTipView(); + }); + IMessageCommon.Current.ShowErrorInfoAlter(result.Code); + } + } + catch (Exception ex) + { + } + finally + { + Application.RunOnMainThread(() => + { + if (waitPage != null) + { + waitPage.RemoveFromParent(); + waitPage = null; + } + }); + } + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// 瑙f瀽鍜屾樉绀烘帹閫佹秷鎭� + /// </summary> + void ParseAndDisplayPushList() + { + // + if (showMesType == 1) + { + + } + } + + #region 娴嬭瘯 + /// <summary> + /// + /// </summary> + void TestLoad() + { + PushMessageInfoList.Add(new PushMessageInfo() + { + messageTitle = "鎶ヨ淇℃伅", + messageContent = "闂ㄩ攣琚墦寮�", + createTime = "11鏈�30 10:50", + }); + + PushMessageInfoList.Add(new PushMessageInfo() + { + messageTitle = "鎶ヨ淇℃伅1", + messageContent = "闂ㄩ攣琚墦寮�", + createTime = "11鏈�30 11:50", + }); + + PushMessageInfoList.Add(new PushMessageInfo() + { + messageTitle = "鎶ヨ淇℃伅2", + messageContent = "闂ㄩ攣琚墦寮�", + createTime = "11鏈�30 12:50", + }); + + AddYearRowView(bodyScrolView, "2020骞�"); + foreach (var info in PushMessageInfoList) + { + AddRowView(bodyScrolView, info); + } + + AddYearRowView(bodyScrolView, "2019骞�"); + foreach (var info in PushMessageInfoList) + { + AddRowView(bodyScrolView, info); + } + } + #endregion + } + + + /// <summary> + /// 鎺ㄩ�佹秷鎭被鍨� + /// </summary> + [System.Serializable] + public class PushMessageInfo + { + /// <summary> + /// 璁板綍Id + /// </summary> + public string id; + /// <summary> + /// 鏄惁宸茶 + /// </summary> + public bool isRead; + /// <summary> + /// 娑堟伅鍐呭 + /// </summary> + public string messageContent; + /// <summary> + /// 鎵╁睍鏁版嵁 + /// </summary> + public string messageExpand; + /// <summary> + /// 娑堟伅涓婚 + /// </summary> + public string messageTitle; + /// <summary> + /// 娑堟伅绫诲瀷锛�0锛氭彁绀猴紱1锛氭姤璀︼紱2锛氫赴鏋楀彲鏄璁插懠鍙紱3锛氬己鍒朵笅绾挎帹閫� + /// </summary> + public string messageType; + /// <summary> + /// 鎺ㄩ�乀oken璁板綍Id + /// </summary> + public string pushId; + /// <summary> + /// 鎺ㄩ�佺被鍨嬶紱0锛氶粯璁わ紱1锛氭姤璀︼紱2锛氭彁绀猴紱3锛氭柊闂伙紱4锛氭帹鑽愶紱 + /// </summary> + public string pushType; + /// <summary> + /// 鎺ㄩ�佹椂闂� + /// </summary> + public string createTime; + + } + +} -- Gitblit v1.8.0