using System.Collections.ObjectModel; using System.Diagnostics; using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Newtonsoft.Json; using RustTools.DataList; using RustTools.Services; using RustTools.ViewModels; using Windows.UI.WindowManagement; namespace RustTools.Views; public sealed partial class HomePage : Page { public HomePageViewModel ViewModel { get; } public ObservableCollection conns = new(); public ObservableCollection newlist = new(); public ObservableCollection Pictures { get; } = new ObservableCollection(); public HomePage() { ViewModel = App.GetService(); //轮播图 var lunbo = JsonConvert.DeserializeObject(ViewModel.lunbo); if (lunbo != null) { foreach (var item in lunbo.data) { Pictures.Add(item.picture); } } StartAsync(); InitializeComponent(); } private void StartAsync() { var modListResponse = JsonConvert.DeserializeObject(ViewModel.str); if (modListResponse == null) { return; } conns.Clear(); newlist.Clear(); foreach (var item in modListResponse.Data) { //https://rust.coldmint.top if (item.Icon.Equals("")) { item.Icon = "/Assets/image/image.svg"; } var contact = new Contact(item.Name, item.Description, item.UpdateTime + " " + item.CoinNumber + "次下载") { ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top") }; conns.Add(contact); newlist.Add(contact); } } public class Contact { public string Title { get; private set; } public string Message { get; private set; } public string Info { get; private set; } public string ImageUrl { get; set; } public Contact(string firstName, string lastName, string company) { Title = firstName; Message = lastName; Info = company; } } private void Page_SizeChanged(object sender, SizeChangedEventArgs e) { //var height = DisplayArea.Primary.WorkArea.Height; //double a = height / 5; //Debug.WriteLine(a); //// 设置FlipView的高度 //Banner.Height = a; } private void ListAClick(object sender, ItemClickEventArgs e) { // 获取被点击的项 // 创建一个新的Window实例 Window newWindow = new Window { // 将NewPage设置为新Window的内容 Content = new ListViewPage(), // 设置新Window的一些属性,如标题和大小 Title = "New Page", }; // 显示新Window newWindow.Show(); } }