WIn_RustTools/RustTools/Views/HomePage.xaml.cs

89 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Newtonsoft.Json;
using RustTools.ViewModels;
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;
namespace RustTools.Views;
public sealed partial class HomePage : Page
{
public HomePageViewModel ViewModel {
get;
}
public ObservableCollection<Contact> conns = new();
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
public HomePage()
{
ViewModel= App.GetService<HomePageViewModel>();
Pictures.Add("/Assets/image/a.jpeg");
Pictures.Add("/Assets/image/b.jpeg");
StartAsync();
InitializeComponent();
}
private void StartAsync()
{
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 + "´ÎÏÂÔØ")
{
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
};
conns.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;
}
}
}