130 lines
3.5 KiB
C#
130 lines
3.5 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.Diagnostics;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Newtonsoft.Json;
|
|
using RustTools.DataList;
|
|
using RustTools.muqing;
|
|
using RustTools.ViewModels;
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
namespace RustTools.Views;
|
|
|
|
/// <summary>
|
|
/// 动态界面
|
|
/// </summary>
|
|
public sealed partial class ConcernPage : Page
|
|
{
|
|
public ConcernViewModel ViewModels
|
|
{
|
|
get; set;
|
|
}
|
|
public ObservableCollection<CommunityList.Data> communitylist = new();
|
|
public ObservableCollection<MovingInfo.Data> MovingInfoList = new();
|
|
private bool IsLogin = false;
|
|
public ConcernPage()
|
|
{
|
|
ViewModels = App.GetService<ConcernViewModel>();
|
|
InitializeComponent();
|
|
//如果未登陆
|
|
|
|
Init();
|
|
if (IsLogin)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private async void Init()
|
|
{
|
|
try
|
|
{
|
|
|
|
var ini = new IniHelper();
|
|
ini.Load(IniHelper.FILE.User);
|
|
var account = ini.GetValue(IniHelper.CODE.User, IniHelper.KEY.account);
|
|
var value = await ApiFox.community.getList(account, true, 0);
|
|
//Debug.WriteLine(value);
|
|
if (value == string.Empty) return;
|
|
var response = JsonConvert.DeserializeObject<CommunityList>(value);
|
|
var a = new CommunityList.Data
|
|
{
|
|
UserName = "全部",
|
|
HeadIcon = "/Assets/tool.png"
|
|
};
|
|
communitylist.Add(a);
|
|
foreach (var item in response.data)
|
|
{
|
|
//item.UserName
|
|
item.HeadIcon = item.HeadIcon.Replace("..", wl.api);
|
|
communitylist.Add(item);
|
|
}
|
|
|
|
if (ListViewA.Items.Count > 0)
|
|
{
|
|
ListViewA.SelectedIndex = 0;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.WriteLine(e);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 每个关注的动态消息内容
|
|
/// </summary>
|
|
private void dongtaixiaoxi()
|
|
{
|
|
MovingInfoList.Clear();
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
MovingInfoList.Add(new MovingInfo.Data("已经在写了"));
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
|
|
var height = ActualHeight; // 确保使用页面的实际高度
|
|
|
|
// 检查是否为有效的数值
|
|
if (!double.IsNaN(height) && !double.IsInfinity(height) && height > 16)
|
|
{
|
|
ListViewA.Height = height - 36;
|
|
ListViewB.Height = height - 16;
|
|
}
|
|
else
|
|
{
|
|
ListViewA.Height = 500; // 或者其他适当的默认值
|
|
ListViewB.Height = 500; // 或者其他适当的默认值
|
|
}
|
|
}
|
|
|
|
private void ItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEventArgs args)
|
|
{
|
|
gj.sc("You invoked ");
|
|
}
|
|
private void ListViewA_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
// 获取当前选中的项目
|
|
var selectedItem = ListViewA.SelectedItem;
|
|
gj.sc(selectedItem);
|
|
dongtaixiaoxi();
|
|
}
|
|
}
|