| | |
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalFrameControl listView = null;
|
| | | /// <summary>
|
| | | /// 全部的行
|
| | | /// </summary>
|
| | | private Dictionary<string, RowLayoutControl> dicAllRow = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// </summary>
|
| | | private async void InitMiddleData()
|
| | | {
|
| | | this.dicAllRow = new Dictionary<string, RowLayoutControl>();
|
| | |
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetPushMessageRecord", false, "");
|
| | |
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame(dicData);
|
| | |
| | | /// <param name="dicData"></param>
|
| | | private void InitMiddleFrame(Dictionary<string, List<MessageRecordInfo>> dicData)
|
| | | {
|
| | | int index = 0;
|
| | | foreach (var keys in dicData.Keys)
|
| | | {
|
| | | var listData = dicData[keys];
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | index++;
|
| | | //容器
|
| | | var framBack = new FrameListControl(23);
|
| | | framBack.Name = keys;
|
| | | framBack.Name = index.ToString();
|
| | | framBack.Height = Application.GetRealHeight(100);
|
| | | framBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | listView.AddChidrenFrame(framBack);
|
| | |
|
| | | //日期
|
| | | string strMonth = Language.StringByID(R.MyInternationalizationString.Month);
|
| | |
| | | {
|
| | | //添加信息行
|
| | | this.AddMsgRowControl(framBack, listData[i], i != listData.Count - 1);
|
| | | }
|
| | | //调整高度
|
| | | listView.AdjustChidrenFrameHeight(framBack, Application.GetRealHeight(23));
|
| | | if (index == dicData.Count)
|
| | | {
|
| | | listView.AdjustTableHeight();
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | //全部已读
|
| | | menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uAllRead), () =>
|
| | | {
|
| | | //设置全部为已读
|
| | | this.SetAllTickIsRead();
|
| | | });
|
| | | //全部删除
|
| | | menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uAllDelete), () =>
|
| | | {
|
| | | //删除全部的消息
|
| | | this.DeleteAllMsg();
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | var rowControl = new RowLayoutControl(frameList.rowSpace / 2);
|
| | | frameList.AddChidren(rowControl);
|
| | | |
| | | rowControl.Name = frameList.ChildrenCount.ToString();
|
| | | rowControl.MainKeys = recordInfo.RegId;
|
| | | this.dicAllRow[frameList.Name + "-" + rowControl.Name] = rowControl;
|
| | |
|
| | | //图标(现在测试)
|
| | | var btnIcon = rowControl.frameTable.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = "Item/Satety.png";
|
| | | btnIcon.UnSelectedImagePath = "Item/Safety.png";
|
| | |
|
| | | //消息类型
|
| | | var btnMsgObject = rowControl.frameTable.AddLeftCaption("测试:消息类型", 600);
|
| | |
| | | //消息
|
| | | var btnMsg = rowControl.frameTable.AddMostRightView(recordInfo.MsgContent, 600, 60);
|
| | | btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnMsg.Y = Application.GetRealHeight(6) + rowControl.frameTable.chidrenYaxis;
|
| | | btnMsg.Y = Application.GetRealHeight(5) + rowControl.frameTable.chidrenYaxis;
|
| | | rowControl.frameTable.AddChidren(btnMsg, ChidrenBindMode.BindEventOnly);
|
| | | //时间
|
| | | var btnTime = rowControl.frameTable.AddMostRightView(recordInfo.MsgContent, 200, 50);
|
| | |
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //确认删除消息?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg);
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteMessageMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
|
| | | {
|
| | | await this.DeleteMsg(recordInfo.RegId, frameList, rowControl);
|
| | |
| | | };
|
| | |
|
| | | //点击
|
| | | rowControl.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | rowControl.frameTable.ButtonClickEvent += async (sender, e) =>
|
| | | {
|
| | | if (recordInfo.IsRead == 1)
|
| | | {
|
| | |
| | | //消息
|
| | | btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnNewTip.RemoveFromParent();
|
| | | //标记已读(不管它成功不成功)
|
| | | this.SetTickIsRead(recordInfo.RegId);
|
| | | if (sender != null)
|
| | | {
|
| | | //标记已读(不管它成功不成功)
|
| | | await this.SetTickIsRead(recordInfo.RegId);
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | /// 标记已读
|
| | | /// </summary>
|
| | | /// <param name="strId"></param>
|
| | | private async void SetTickIsRead(string strId)
|
| | | private async System.Threading.Tasks.Task<bool> SetTickIsRead(string strId)
|
| | | {
|
| | | var pra = new { Id = strId };
|
| | | //await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/TickIsRead", true, pra);
|
| | | await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/TickIsRead", true, pra);
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置全部为已读
|
| | | /// </summary>
|
| | | private void SetAllTickIsRead()
|
| | | {
|
| | | if (dicAllRow.Count == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //确认标记全部消息为已读?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uUnTipAllMessageMsg), () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | foreach (var contr in this.dicAllRow.Values)
|
| | | {
|
| | | //标识全部为已读
|
| | | var result = await this.SetTickIsRead(contr.MainKeys);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //设置全部状态
|
| | | foreach (var contr in this.dicAllRow.Values)
|
| | | {
|
| | | contr.frameTable.ButtonClickEvent?.Invoke(null, null);
|
| | | }
|
| | | });
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | private async System.Threading.Tasks.Task<bool> DeleteMsg(string strId, FrameListControl frameList, RowLayoutControl rowContr)
|
| | | {
|
| | | var pra = new { Id = strId };
|
| | | //var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/DeletePushMessage", true, pra);
|
| | | //if (result == true && frameList != null)
|
| | | var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/DeletePushMessage", true, pra);
|
| | | if (result == true && frameList != null)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | rowContr.RemoveFromParent();
|
| | | //移除缓存
|
| | | this.dicAllRow.Remove(frameList.Name + "-" + rowContr.Name);
|
| | | //调整控件位置
|
| | | this.AdjustControlLocation(frameList);
|
| | | this.AdjustControlLocation(frameList, rowContr);
|
| | | });
|
| | | }
|
| | | //return result;
|
| | | return true;
|
| | | return result;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除全部的消息
|
| | | /// </summary>
|
| | | private void DeleteAllMsg()
|
| | | {
|
| | | if (dicAllRow.Count == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //确认删除全部消息?
|
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteAllMessageMsg), () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | foreach (var contr in this.dicAllRow.Values)
|
| | | {
|
| | | //删除全部消息
|
| | | var result = await this.DeleteMsg(contr.MainKeys, null, null);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | bodyFrameLayout.RemoveAll();
|
| | | listView = new VerticalFrameControl(35);
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //初始化中部信息
|
| | | this.InitMiddleData();
|
| | | });
|
| | | });
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 调整控件位置
|
| | | /// </summary>
|
| | | /// <param name="frameList"></param>
|
| | | private void AdjustControlLocation(FrameListControl frameList)
|
| | | private void AdjustControlLocation(FrameListControl frameList, RowLayoutControl removeRow)
|
| | | {
|
| | | int nowHeight = frameList.Height;
|
| | | int changedHeight = 0;
|
| | | if (frameList.ChildrenCount <= 1)
|
| | | int changedHeight = frameList.GetChildren(frameList.ChildrenCount - 1).Height;
|
| | | if (frameList.ChildrenCount <= 2)
|
| | | {
|
| | | //已经删完了,只剩下标题日期了
|
| | | frameList.RemoveFromParent();
|
| | | changedHeight = nowHeight;
|
| | | changedHeight = frameList.Height;
|
| | | }
|
| | | else
|
| | | {
|
| | | frameList.Height = frameList.GetChildren(frameList.ChildrenCount - 1).Bottom;
|
| | | changedHeight = nowHeight - frameList.Height;
|
| | | }
|
| | | //先调整各自容器的Y轴坐标
|
| | | bool canChangedLoaction = false;
|
| | | for (int i = 0; i < this.listView.ChildrenCount; i++)
|
| | | for (int i = 0; i < this.listView.frameTable.ChildrenCount; i++)
|
| | | {
|
| | | var myView = this.listView.GetChildren(i);
|
| | | var myView = this.listView.frameTable.GetChildren(i);
|
| | | if (myView.Name == frameList.Name)
|
| | | {
|
| | | //它之后的控件全部往上移动
|
| | |
| | | {
|
| | | myView.Y -= changedHeight;
|
| | | }
|
| | | }
|
| | | //调整父容器大小
|
| | | this.listView.AdjustTableHeight();
|
| | |
|
| | |
|
| | | if (frameList.ChildrenCount <= 2)
|
| | | {
|
| | | //已经删完了,只剩下标题日期了
|
| | | frameList.RemoveFromParent();
|
| | | }
|
| | | else
|
| | | {
|
| | | //这个容器里面被移除的行的下面的全部行,往上移动
|
| | | bool changedFlage = false;
|
| | | for (int i = 0; i < frameList.ChildrenCount; i++)
|
| | | {
|
| | | var myView = frameList.GetChildren(i);
|
| | | if (myView.Name == removeRow.Name)
|
| | | {
|
| | | //它之后的控件全部往上移动
|
| | | changedFlage = true;
|
| | | continue;
|
| | | }
|
| | | if (changedFlage == true)
|
| | | {
|
| | | myView.Y -= changedHeight;
|
| | | }
|
| | | }
|
| | | //移除指定的行
|
| | | removeRow.RemoveFromParent();
|
| | | //容器大小减少
|
| | | frameList.Height -= changedHeight;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | var listData = dicTemp[listSortKeys[i]];
|
| | | foreach (var data2 in listData)
|
| | | {
|
| | | string[] myArry = data2.MsgTime.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (dicData.ContainsKey(myArry[1]) == false)
|
| | | string[] myArry = data2.MsgTime.Split(new string[] { "T" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (myArry.Length != 2)
|
| | | {
|
| | | dicData[myArry[1]] = new List<MessageRecordInfo>();
|
| | | continue;
|
| | | }
|
| | | dicData[myArry[1]].Add(data2);
|
| | | if (dicData.ContainsKey(myArry[0]) == false)
|
| | | {
|
| | | dicData[myArry[0]] = new List<MessageRecordInfo>();
|
| | | }
|
| | | dicData[myArry[0]].Add(data2);
|
| | | }
|
| | | }
|
| | | return dicData;
|