WIn_RustTools/RustTools/Views/HomePage.xaml.cs

89 lines
2.2 KiB
C#
Raw Normal View History

2024-07-14 11:24:10 +00:00
using System;
using System.Collections.Generic;
2024-07-19 07:36:44 +00:00
using System.Collections.ObjectModel;
2024-07-14 11:24:10 +00:00
using System.IO;
using System.Linq;
2024-07-19 14:29:49 +00:00
using System.Net.NetworkInformation;
2024-07-14 11:24:10 +00:00
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
2024-07-19 14:29:49 +00:00
using Newtonsoft.Json;
2024-07-14 11:24:10 +00:00
using RustTools.ViewModels;
2024-07-19 14:29:49 +00:00
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Microsoft.Extensions.Hosting;
2024-07-19 07:36:44 +00:00
namespace RustTools.Views;
2024-07-14 11:24:10 +00:00
public sealed partial class HomePage : Page
{
public HomePageViewModel ViewModel {
get;
}
2024-07-19 07:36:44 +00:00
public ObservableCollection<Contact> conns = new();
2024-07-14 11:24:10 +00:00
2024-07-19 07:36:44 +00:00
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
2024-07-14 11:24:10 +00:00
public HomePage()
{
2024-07-15 05:22:53 +00:00
ViewModel= App.GetService<HomePageViewModel>();
2024-07-19 14:29:49 +00:00
2024-07-19 07:36:44 +00:00
Pictures.Add("/Assets/image/a.jpeg");
Pictures.Add("/Assets/image/b.jpeg");
StartAsync();
2024-07-14 11:24:10 +00:00
InitializeComponent();
}
2024-07-19 07:36:44 +00:00
2024-07-19 14:29:49 +00:00
2024-07-19 07:36:44 +00:00
private void StartAsync()
{
2024-07-19 14:29:49 +00:00
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(ViewModel.str);
if (modListResponse == null)
{
return;
}
foreach (var item in modListResponse.Data)
{
//https://rust.coldmint.top
if (item.Icon.Equals(""))
{
item.Icon = "/Assets/tool.png";
}
var contact = new Contact(item.Name, item.Description, item.UpdateTime + " " + item.CoinNumber + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
};
conns.Add(contact);
}
2024-07-19 07:36:44 +00:00
}
public class Contact
{
2024-07-19 14:29:49 +00:00
public string Title
2024-07-19 07:36:44 +00:00
{
get; private set;
}
2024-07-19 14:29:49 +00:00
public string Message
2024-07-19 07:36:44 +00:00
{
get; private set;
}
2024-07-19 14:29:49 +00:00
public string Info
2024-07-19 07:36:44 +00:00
{
get; private set;
}
2024-07-19 14:29:49 +00:00
public string ImageUrl
{
get; set;
}
2024-07-19 07:36:44 +00:00
public Contact(string firstName, string lastName, string company)
{
2024-07-19 14:29:49 +00:00
Title = firstName;
Message = lastName;
Info = company;
2024-07-19 07:36:44 +00:00
}
}
2024-07-14 11:24:10 +00:00
}