73 lines
1.9 KiB
C#
73 lines
1.9 KiB
C#
|
|
|||
|
|
|||
|
using Microsoft.UI.Xaml;
|
|||
|
using Microsoft.UI.Xaml.Controls;
|
|||
|
|
|||
|
namespace RustTools.WindowUI;
|
|||
|
public sealed partial class ImportModule : WindowEx
|
|||
|
{
|
|||
|
public ImportModule(string file)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
ExtendsContentIntoTitleBar = true;
|
|||
|
if (file == string.Empty) {
|
|||
|
Close();
|
|||
|
return;
|
|||
|
}
|
|||
|
var fileInfo = new FileInfo(file);
|
|||
|
var iniHelper = new IniHelper();
|
|||
|
iniHelper.Load(IniHelper.FILE.Config);
|
|||
|
|
|||
|
if (file.EndsWith(".rwmod"))
|
|||
|
{
|
|||
|
var l = " | ";
|
|||
|
var formattedSize = FormatFileSize(fileInfo.Length);
|
|||
|
MessageText.Text="<22><><EFBFBD><EFBFBD>:ģ<><C4A3>"+ l+ "<22><>С"+ formattedSize;
|
|||
|
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
|||
|
if (v == string.Empty) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
InfoText.Text = string.Format("ԭλ<D4AD><CEBB> {0} --> {1} \n<>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>벻Ҫ<EBB2BB>رմ˴<D5B4><CBB4><EFBFBD> <20><><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ر<EFBFBD> ʧ<><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾȨ<CABE>ȴ<DEB5><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|||
|
file,v);
|
|||
|
}
|
|||
|
NameText.Text =
|
|||
|
fileInfo.Name;
|
|||
|
}
|
|||
|
private async void Dialog()
|
|||
|
{
|
|||
|
ContentDialog dialog = new ContentDialog
|
|||
|
{
|
|||
|
Title = "<22><><EFBFBD><EFBFBD>",
|
|||
|
Content = "<22><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|||
|
PrimaryButtonText = "ȷ<><C8B7>",
|
|||
|
SecondaryButtonText = "ȡ<><C8A1>",
|
|||
|
CloseButtonText = "<22>ر<EFBFBD>"
|
|||
|
};
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD> XamlRoot<6F><74>ȷ<EFBFBD><C8B7><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ȷ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
dialog.XamlRoot = Grid.XamlRoot;
|
|||
|
|
|||
|
// <20><>ʾ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
|
|||
|
await dialog.ShowAsync();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private static string FormatFileSize(long bytes)
|
|||
|
{
|
|||
|
return bytes switch
|
|||
|
{
|
|||
|
< 1024 => $"{bytes} B",
|
|||
|
< 1024 * 1024 => $"{bytes / 1024.0:F2} KB",
|
|||
|
< 1024 * 1024 * 1024 => $"{bytes / (1024.0 * 1024.0):F2} MB",
|
|||
|
_ => $"{bytes / (1024.0 * 1024.0 * 1024.0):F2} GB"
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
Dialog();
|
|||
|
|
|||
|
}
|
|||
|
}
|