2024-08-05 11:38:55 +00:00
|
|
|
|
|
2024-07-25 13:18:43 +00:00
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
using RustTools.muqing;
|
|
|
|
|
using Newtonsoft.Json;
|
2024-07-26 10:50:25 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2024-08-05 11:38:55 +00:00
|
|
|
|
using Windows.ApplicationModel.Core;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Windows.UI.ViewManagement;
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
|
|
|
|
using Microsoft.UI;
|
2024-08-06 06:34:25 +00:00
|
|
|
|
using static RustTools.muqing.wl;
|
|
|
|
|
using System.Threading;
|
2024-07-25 13:18:43 +00:00
|
|
|
|
// 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;
|
2024-07-25 13:18:43 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
2024-08-07 02:31:13 +00:00
|
|
|
|
public sealed partial class ModuleInfoWin : WindowEx
|
2024-07-25 13:18:43 +00:00
|
|
|
|
{
|
2024-08-07 02:31:13 +00:00
|
|
|
|
public static List<ModuleInfoWin> ModulePageList = new();
|
2024-08-05 11:38:55 +00:00
|
|
|
|
public ObservableCollection<string> ScreenshotsList = new();
|
2024-07-26 10:50:25 +00:00
|
|
|
|
public ModInfo.Data Mod { get; set; } = new();
|
2024-08-07 02:31:13 +00:00
|
|
|
|
public ModuleInfoWin(string v)
|
2024-07-25 13:18:43 +00:00
|
|
|
|
{
|
2024-08-05 11:38:55 +00:00
|
|
|
|
|
2024-07-25 13:18:43 +00:00
|
|
|
|
InitializeComponent();
|
2024-07-26 10:50:25 +00:00
|
|
|
|
ExtendsContentIntoTitleBar = true;
|
2024-08-05 11:38:55 +00:00
|
|
|
|
gj.SetBackTheme(this);
|
|
|
|
|
var frame = App.AppTitlebar as FrameworkElement;
|
|
|
|
|
if (frame != null)
|
|
|
|
|
{
|
|
|
|
|
gj.UpdateTitleBar(this, frame.ActualTheme);
|
2024-08-06 06:34:25 +00:00
|
|
|
|
grid.RequestedTheme = frame.ActualTheme;
|
2024-08-05 11:38:55 +00:00
|
|
|
|
}
|
2024-08-08 09:29:19 +00:00
|
|
|
|
if (v != string.Empty)
|
|
|
|
|
{
|
|
|
|
|
init(v);
|
|
|
|
|
}
|
2024-08-07 02:31:13 +00:00
|
|
|
|
// <20><><EFBFBD>ô<EFBFBD><C3B4>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>ɫ
|
2024-07-25 13:18:43 +00:00
|
|
|
|
}
|
|
|
|
|
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);
|
2024-07-26 10:50:25 +00:00
|
|
|
|
Title = Mod.Name;
|
2024-07-25 13:18:43 +00:00
|
|
|
|
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;
|
2024-07-26 10:50:25 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-07-25 13:18:43 +00:00
|
|
|
|
grid.DataContext = this; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-26 10:50:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void WindowEx_SizeChanged(object sender, WindowSizeChangedEventArgs args)
|
|
|
|
|
{
|
2024-08-05 11:38:55 +00:00
|
|
|
|
DescriptionText.Width = Width - 50;
|
2024-07-26 10:50:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-08-06 06:34:25 +00:00
|
|
|
|
private async void AppBarButton_Click(object sender, RoutedEventArgs e)
|
2024-07-31 03:24:52 +00:00
|
|
|
|
{
|
|
|
|
|
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":
|
2024-08-06 06:34:25 +00:00
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.Config);
|
|
|
|
|
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
|
|
|
|
if (v == string.Empty)
|
|
|
|
|
{
|
|
|
|
|
var dialog=new ContentDialog()
|
|
|
|
|
{
|
|
|
|
|
XamlRoot = grid.XamlRoot,
|
|
|
|
|
Title="<22><><EFBFBD><EFBFBD>",
|
|
|
|
|
Content="<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD>ģ<EFBFBD><C4A3>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
SecondaryButtonText="ȡ<><C8A1>"
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
await dialog.ShowAsync();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cancellationTokenSource = new CancellationTokenSource();
|
2024-08-05 11:38:55 +00:00
|
|
|
|
gj.sc("<22><><EFBFBD>ش<EFBFBD>ģ<EFBFBD><C4A3>:" + Mod.Link);
|
2024-08-06 06:34:25 +00:00
|
|
|
|
var downloader = new FileDownloader();
|
2024-08-07 02:31:13 +00:00
|
|
|
|
DownloadDialog.XamlRoot = grid.XamlRoot;
|
2024-08-06 06:34:25 +00:00
|
|
|
|
var asyncOperation = DownloadDialog.ShowAsync();
|
|
|
|
|
DownloadDialog.Closing += DownloadDialog_Closing;
|
|
|
|
|
DownloadDialog.SecondaryButtonClick += (a, b) =>
|
|
|
|
|
{
|
|
|
|
|
gj.sc("ɾ<><C9BE>");
|
|
|
|
|
cancellationTokenSource.Cancel();
|
|
|
|
|
downloader.Delete();
|
|
|
|
|
};
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-08-07 02:31:13 +00:00
|
|
|
|
var PathMod = Path.Combine(v, Mod.Name);
|
|
|
|
|
if (File.Exists(PathMod + ".rwmod"))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(PathMod + ".rwmod");
|
|
|
|
|
}
|
2024-08-06 06:34:25 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ı<EFBFBD><C4B1><EFBFBD>·<EFBFBD><C2B7>
|
2024-08-07 02:31:13 +00:00
|
|
|
|
await downloader.DownloadFileAsync(Mod.Link,PathMod, (totalBytesRead, totalBytes) =>
|
2024-08-06 06:34:25 +00:00
|
|
|
|
{
|
|
|
|
|
DownloadDialogText.Text = $"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.";
|
|
|
|
|
//Debug.WriteLine($"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.");
|
|
|
|
|
}, cancellationTokenSource.Token);
|
|
|
|
|
Debug.WriteLine("<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2024-08-07 02:31:13 +00:00
|
|
|
|
File.Move(PathMod, PathMod + ".rwmod");
|
2024-08-06 06:34:25 +00:00
|
|
|
|
DownloadDialog.Closing -= DownloadDialog_Closing;
|
|
|
|
|
// <20>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ضԻ<D8B6><D4BB><EFBFBD>
|
|
|
|
|
DownloadDialog.Hide();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine($"Error downloading file: {ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
DownloadDialog.Closing -= DownloadDialog_Closing;
|
|
|
|
|
DownloadDialog.Hide();
|
|
|
|
|
}
|
2024-07-31 03:24:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Toast_ActionButtonClick(TeachingTip sender, object args)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2024-08-06 06:34:25 +00:00
|
|
|
|
|
|
|
|
|
private void DownloadDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// Prevent the dialog from closing
|
|
|
|
|
if (args.Result != ContentDialogResult.Secondary)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 13:18:43 +00:00
|
|
|
|
}
|