2024-07-19 07:36:44 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2024-07-23 12:23:55 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Microsoft.UI;
|
|
|
|
|
using Microsoft.UI.Windowing;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
2024-07-19 14:29:49 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2024-07-23 12:23:55 +00:00
|
|
|
|
using RustTools.DataList;
|
2024-07-24 02:53:16 +00:00
|
|
|
|
using RustTools.muqing;
|
2024-07-23 12:23:55 +00:00
|
|
|
|
using RustTools.Services;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
using RustTools.ViewModels;
|
2024-07-23 12:23:55 +00:00
|
|
|
|
using Windows.UI.WindowManagement;
|
2024-07-24 02:53:16 +00:00
|
|
|
|
using System.Threading;
|
2024-07-25 13:18:43 +00:00
|
|
|
|
using Microsoft.UI.Xaml.Media.Imaging;
|
|
|
|
|
using System.Text.RegularExpressions;
|
2024-07-23 12:23:55 +00:00
|
|
|
|
namespace RustTools.Views;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
public sealed partial class HomePage : Page
|
|
|
|
|
{
|
2024-07-23 12:23:55 +00:00
|
|
|
|
public HomePageViewModel ViewModel
|
|
|
|
|
{
|
2024-07-14 11:24:10 +00:00
|
|
|
|
get;
|
|
|
|
|
}
|
2024-07-25 13:18:43 +00:00
|
|
|
|
public ObservableCollection<HomeBanner.Data> Pictures = new();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
public HomePage()
|
|
|
|
|
{
|
2024-07-23 12:23:55 +00:00
|
|
|
|
ViewModel = App.GetService<HomePageViewModel>();
|
|
|
|
|
//<2F>ֲ<EFBFBD>ͼ
|
|
|
|
|
var lunbo = JsonConvert.DeserializeObject<HomeBanner>(ViewModel.lunbo);
|
|
|
|
|
if (lunbo != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in lunbo.data)
|
|
|
|
|
{
|
2024-07-25 13:18:43 +00:00
|
|
|
|
Pictures.Add(item);
|
2024-07-23 12:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-25 13:18:43 +00:00
|
|
|
|
ViewModel.random();
|
|
|
|
|
ViewModel.Latest();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2024-07-24 02:53:16 +00:00
|
|
|
|
|
2024-07-23 12:23:55 +00:00
|
|
|
|
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//var height = DisplayArea.Primary.WorkArea.Height;
|
|
|
|
|
//double a = height / 5;
|
|
|
|
|
//Debug.WriteLine(a);
|
|
|
|
|
//// <20><><EFBFBD><EFBFBD>FlipView<65>ĸ߶<C4B8>
|
|
|
|
|
//Banner.Height = a;
|
2024-07-19 07:36:44 +00:00
|
|
|
|
|
2024-07-23 12:23:55 +00:00
|
|
|
|
}
|
|
|
|
|
private void ListAClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
2024-07-25 13:18:43 +00:00
|
|
|
|
if (e.ClickedItem is not ModData item) { return; }
|
|
|
|
|
var newWindow = new ModulePage(item.Id);
|
|
|
|
|
newWindow.Activate();
|
|
|
|
|
//// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//// <20><><EFBFBD><EFBFBD> RandomItem <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD>Windowʵ<77><CAB5>
|
|
|
|
|
//var window = new Window
|
|
|
|
|
//{
|
|
|
|
|
// // <20><>NewPage<67><65><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>Window<6F><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// Content = new ModulePage(item?.Id),
|
|
|
|
|
|
|
|
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Window<6F><77>һЩ<D2BB><D0A9><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>С
|
|
|
|
|
// Title =item?.Name,
|
|
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
//window.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
|
|
|
|
////window.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/<2F><><EFBFBD><EFBFBD><E2B9A4>.svg"));
|
|
|
|
|
|
|
|
|
|
//// <20><>ʾ<EFBFBD><CABE>Window
|
|
|
|
|
//window.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshRandom(object sender,RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ViewModel.random();
|
|
|
|
|
}
|
|
|
|
|
private void RefreshLatest(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ViewModel.Latest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Image_PointerPressed(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Image <20>ؼ<EFBFBD>
|
|
|
|
|
var image = sender as Image;
|
|
|
|
|
if (image != null)
|
2024-07-23 12:23:55 +00:00
|
|
|
|
{
|
|
|
|
|
|
2024-07-25 13:18:43 +00:00
|
|
|
|
// <20><>ȡ Image <20>ؼ<EFBFBD><D8BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var item = image.DataContext as HomeBanner.Data;
|
|
|
|
|
var link1 = item?.link;
|
|
|
|
|
if (link1 != null)
|
|
|
|
|
{
|
|
|
|
|
// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽƥ<CABD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var match = MyRegex().Match(link1);
|
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
|
|
|
|
var link = match.Groups[1].Value;
|
|
|
|
|
Process.Start(new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = link,
|
|
|
|
|
UseShellExecute = true,
|
|
|
|
|
Verb = "open"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("No match found.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-23 12:23:55 +00:00
|
|
|
|
|
2024-07-25 13:18:43 +00:00
|
|
|
|
}
|
2024-07-23 12:23:55 +00:00
|
|
|
|
}
|
2024-07-25 13:18:43 +00:00
|
|
|
|
|
|
|
|
|
[GeneratedRegex("\\{(.+?)\\}")]
|
|
|
|
|
private static partial Regex MyRegex();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
}
|