You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Microsoft.Maui.Controls.Shapes;
|
|
|
|
|
using SunlightAggregationTerminal.Models;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
|
|
|
|
namespace SunlightAggregationTerminal.NotificationView;
|
|
|
|
|
|
|
|
|
|
public partial class MessagePage : ContentPage
|
|
|
|
|
{
|
|
|
|
|
public ObservableCollection<NotificationItem> MessageItems { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public MessagePage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.BindingContext = this;
|
|
|
|
|
LoadData(); // 加载数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
var allData = DataService._NotificationData;
|
|
|
|
|
if (allData != null)
|
|
|
|
|
{
|
|
|
|
|
// 清空旧数据
|
|
|
|
|
MessageItems.Clear();
|
|
|
|
|
|
|
|
|
|
// 按时间倒序,并只取最新的 50 条
|
|
|
|
|
var itemsToShow = allData.OrderByDescending(x => x.Time).Take(50).Where(x => x.Type == MsgType.Message);
|
|
|
|
|
|
|
|
|
|
// 将数据添加到集合中,UI 会自动更新
|
|
|
|
|
foreach (var item in itemsToShow)
|
|
|
|
|
{
|
|
|
|
|
MessageItems.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CardCollectionView_RemainingItemsThresholdReached(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|