WIn_RustTools/RustTools/WindowUI/ModulePage.xaml.cs

127 lines
3.9 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.muqing;
using Newtonsoft.Json;
using RustTools.DataList;
2024-07-29 01:10:42 +00:00
using RustTools.Helpers;
using System.Collections.ObjectModel;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
2024-07-28 13:33:21 +00:00
namespace RustTools.WindowUI;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ModulePage : WindowEx
{
public static List<ModulePage> ModulePageList = new();
public ObservableCollection<string> ScreenshotsList =new();
public ModInfo.Data Mod { get; set; } = new();
public ModulePage(string v)
{
2024-07-28 13:33:21 +00:00
gj.SetBackTheme(this);
InitializeComponent();
ExtendsContentIntoTitleBar = true;
init(v);
}
private async void init(string v)
{
var json = await ApiFox.mod.getInfo("", v);
var a = JsonConvert.DeserializeObject<ModInfo>(json);
if (a != null)
{
Mod = a.data;
2024-07-31 03:24:52 +00:00
Mod.IconUrl = Mod.IconUrl.Equals("") ? "/Assets/image/image_106.svg" : Mod.IconUrl.Replace("..", wl.api);
Mod.Link = Mod.Link.Replace("..", wl.api);
Title = Mod.Name;
var l = " | ";
title_b.Text = "<22><>λ<EFBFBD><CEBB>" + Mod.UnitNumber + l + Mod.DownloadNumber + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + l + "<22><EFBFBD><E6B1BE><EFBFBD><EFBFBD>" + Mod.VersionName;
title_c.Text = "<22><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:" + Mod.CreationTime + " <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:" + Mod.UpdateTime;
var ScrList = Mod.Screenshots.Split(",");
foreach (var s in ScrList)
{
gj.sc(s);
if (string.IsNullOrEmpty(s))
{
continue;
}
ScreenshotsList.Add(s.Replace("..", wl.api));
}
if (ScreenshotsList.Count > 0)
{
fliptext.Visibility = Visibility.Visible;
flipview.Visibility = Visibility.Visible;
}
else
{
fliptext.Visibility = Visibility.Collapsed;
flipview.Visibility = Visibility.Collapsed;
}
grid.DataContext = this; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
private void WindowEx_SizeChanged(object sender, WindowSizeChangedEventArgs args)
{
DescriptionText.Width = Width-50;
}
private void WindowEx_Closed(object sender, WindowEventArgs args)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>ڹر<DAB9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>Ƴ<EFBFBD>
ModulePageList.Remove(this);
}
2024-07-31 03:24:52 +00:00
private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
var label = ((AppBarButton)sender).Name;
gj.sc(label);
switch (label)
{
case "ReportButton":
gj.sc("<22>ٱ<EFBFBD><D9B1><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>鳭Ϯ");
//if (Toast.IsOpen) Toast.IsOpen = false;
Toast.Title = "<22>ٱ<EFBFBD><D9B1><EFBFBD>ģ<EFBFBD><C4A3>";
Toast.Subtitle = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٱ<EFBFBD><D9B1><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD>Ծٱ<D4BE><D9B1><EFBFBD>";
Toast.IsOpen = true;
break;
case "LikeButton":
gj.sc("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>Ͷ<EFBFBD><CDB6>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>");
//if (Toast.IsOpen) Toast.IsOpen = false;
Toast.Title = <>ִ<EFBFBD>ģ<EFBFBD><C4A3>";
Toast.Subtitle = <>ֺ<EFBFBD><D6BA>Զ<EFBFBD><D4B6>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ӳ<EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>ʧ<EFBFBD><CAA7>";
Toast.IsOpen = true;
break;
case "DownLoadButton":
gj.sc("<22><><EFBFBD>ش<EFBFBD>ģ<EFBFBD><C4A3>:"+Mod.Link);
break;
}
}
private void Toast_ActionButtonClick(TeachingTip sender, object args)
{
}
}