diff --git a/RustTools/App.xaml.cs b/RustTools/App.xaml.cs index 5c06b34..243700f 100644 --- a/RustTools/App.xaml.cs +++ b/RustTools/App.xaml.cs @@ -1,10 +1,15 @@  +using System.Diagnostics; +using System.IO.Compression; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.UI.Xaml; using Microsoft.Windows.AppLifecycle; +using Newtonsoft.Json; using RustTools.Activation; using RustTools.Contracts.Services; +using RustTools.DataList; +using RustTools.Helpers; using RustTools.Models; using RustTools.muqing; using RustTools.Services; @@ -12,6 +17,7 @@ using RustTools.ViewModels; using RustTools.Views; using RustTools.WindowUI; using Windows.ApplicationModel.Activation; +using Windows.Storage; namespace RustTools; @@ -77,16 +83,19 @@ public partial class App : Microsoft.UI.Xaml.Application services.AddTransient(); services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); //模组碎片 services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); + + services.AddTransient(); + //services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -97,6 +106,63 @@ public partial class App : Microsoft.UI.Xaml.Application Build(); UnhandledException += App_UnhandledException; + var path = ApplicationData.Current.LocalFolder.Path; + var v = Path.Combine(path, "CodeTable"); + gj.sc(path); + if (Directory.Exists(v) == false) + { + Directory.CreateDirectory(v); + } + var RustCode = Path.Combine(v, "RustCode"); + if (Directory.Exists(RustCode) == false) + { + new Thread(() => + { + var zipFilePath = Path.Combine(AppContext.BaseDirectory, "Assets\\RustCode.zip"); + gj.sc(zipFilePath); + try + { + ZipFile.ExtractToDirectory(zipFilePath, RustCode); + var iniHelper = new IniHelper(IniHelper.FILE.Config); + iniHelper.SetValue("CodeTable", "Dir", RustCode); + iniHelper.Save(); + var vr = Path.Combine(RustCode, "DataBaseManifest.json"); + if (File.Exists(vr)) + { + var json = JsonConvert.DeserializeObject(File.ReadAllText(vr)); + json.Dir = RustCode; + CodeDataPage.codetable = json; + } + Debug.WriteLine("ZIP文件已成功解压缩并复制到目标目录。"); + } + catch (FileNotFoundException) + { + Debug.WriteLine("源文件未找到。"); + } + catch (IOException ex) + { + Debug.WriteLine("发生IO异常: " + ex.Message); + } + catch (Exception ex) + { + + Debug.WriteLine("发生未知错误: " + ex.Message); + } + }).Start(); + } + else + { + var iniHelper = new IniHelper(IniHelper.FILE.Config); + var v1 = iniHelper.GetValue("CodeTable", "Dir"); + if (string.IsNullOrEmpty(v1)) { v1 = RustCode; } + var vr = Path.Combine(v1, "DataBaseManifest.json"); + if (File.Exists(vr)) + { + var json = JsonConvert.DeserializeObject(File.ReadAllText(vr)); + json.Dir = v1; + CodeDataPage.codetable = json; + } + } } private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) diff --git a/RustTools/Assets/RustCode.zip b/RustTools/Assets/RustCode.zip new file mode 100644 index 0000000..ddfe4c4 Binary files /dev/null and b/RustTools/Assets/RustCode.zip differ diff --git a/RustTools/DataList/CodeTable.cs b/RustTools/DataList/CodeTable.cs new file mode 100644 index 0000000..b091708 --- /dev/null +++ b/RustTools/DataList/CodeTable.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RustTools.Helpers; + +namespace RustTools.DataList; +#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 +/// +/// 加载 节与表 +/// +public class CodeTable +{ + public string CnKey + { + get; set; + } + public string Key + { + get; set; + } + public List Vaule + { + get; set; + } +} + +/// +/// 加载代码表文件 +/// +public class CodeTable_Code +{ + public string name + { + get; set; + } + public List data + { + get; set; + } = new List(); +} + +public class CodeTable_Data +{ + //英文 + public string code + { + get; set; + } + //中文 + public string translate + { + get; set; + } + //简单的对代码进行解释 + public string description + { + get; set; + } + //声明这是个什么类型 例如 string 字符串 可自定义 + public string type + { + get; set; + } + //添加在哪一个版本 默认为最低版本 "1.12" + public string addVersion + { + get; set; + } + //存在与哪一个节 用,隔开 + public string section + { + get; set; + } + //更详的解释 和 例子 + public string demo + { + get; set; + } +} \ No newline at end of file diff --git a/RustTools/DataList/DataBaseManifest.cs b/RustTools/DataList/DataBaseManifest.cs new file mode 100644 index 0000000..c5fd7fb --- /dev/null +++ b/RustTools/DataList/DataBaseManifest.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RustTools.DataList; +/// +/// 数据集 +/// +#pragma warning disable IDE1006 // 命名样式 +#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 +public class DataBaseManifest +{ + public string id + { + get; set; + }//数据集标识 不能重复 + public string name + { + get; set; + }//代码表名称 + public string author + { + get; set; + }//作者 + public string describe + { + get; set; + } + public string versionName + { + get; set; + }//版本 规范 int.int.int + public List updateLog + { + get; set; + } + + public Data tables + { + get; set; + } + public string Dir + { + get; set; + } = string.Empty; + + public class Data + { + // 代码表配置文件 "/tables/code.json", 可自定义 + public string code + { + get; set; + } + public string chain_inspection + { + get; set; + } + public string section + { + get; set; + } + //节 翻译 对应 配置文件 "/tables/value_type.json",可自定义 + public string value_type + { + get; set; + } + //版本号对应配置文件 "/tables/game_version.json" 可自定义 + public string game_version + { + get; set; + } + } + public class GameVersion + { + + } + public class Section + { + public string name + { + get; set; + } + public List data + { + + get; set; + } + + public class SectionData + { + public string code + { + get; set; + } + public string translate + { + get; set; + } + } + + } +} diff --git a/RustTools/Helpers/NotOfficialConverter.cs b/RustTools/Helpers/NotOfficialConverter.cs new file mode 100644 index 0000000..4ddb464 --- /dev/null +++ b/RustTools/Helpers/NotOfficialConverter.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RustTools.muqing; + +namespace RustTools.Helpers; +public class NotOfficialConverter +{ + public object Convert(object value, Type targetType, object parameter, string language) + { + var id = value as string; + gj.sc(id); + return id=="aa"; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } +} diff --git a/RustTools/RustTools.csproj b/RustTools/RustTools.csproj index 0e04d26..85cb98b 100644 --- a/RustTools/RustTools.csproj +++ b/RustTools/RustTools.csproj @@ -30,13 +30,6 @@ Never D:\RustTools - - - - - - - @@ -76,5 +69,4 @@ - \ No newline at end of file diff --git a/RustTools/Services/PageService.cs b/RustTools/Services/PageService.cs index 34d37d5..1a7ca83 100644 --- a/RustTools/Services/PageService.cs +++ b/RustTools/Services/PageService.cs @@ -21,6 +21,8 @@ public class PageService : IPageService Configure(); Configure(); Configure(); + Configure(); + Configure(); Configure(); } diff --git a/RustTools/Strings/zh-cn/Resources.resw b/RustTools/Strings/zh-cn/Resources.resw index 8f606d6..49dfccb 100644 --- a/RustTools/Strings/zh-cn/Resources.resw +++ b/RustTools/Strings/zh-cn/Resources.resw @@ -145,7 +145,7 @@ 关于软件 - 开发中,铁锈助手的Win端助手,采用WinUI3开发构建,主要开发语言C#,仅支持win10+,如果你在测试中遇到BUG请在群里反馈 + 开发中,Windows端助手,采用WinUI3开发构建,主要开发语言C#,本项目只是作为铁锈助手PC端中的一个测试项目 隐私声明 @@ -177,4 +177,10 @@ 用户 + + 代码表 + + + 代码集 + \ No newline at end of file diff --git a/RustTools/ViewModels/CodeDataViewModel.cs b/RustTools/ViewModels/CodeDataViewModel.cs new file mode 100644 index 0000000..af7675a --- /dev/null +++ b/RustTools/ViewModels/CodeDataViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management; +using System.Text; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.ComponentModel; + +namespace RustTools.ViewModels; + +public class CodeDataViewModel :ObservableRecipient +{ +} diff --git a/RustTools/ViewModels/UserViewModel.cs b/RustTools/ViewModels/UserViewModel.cs index 7d69ff9..326b8be 100644 --- a/RustTools/ViewModels/UserViewModel.cs +++ b/RustTools/ViewModels/UserViewModel.cs @@ -1,6 +1,4 @@ using CommunityToolkit.Mvvm.ComponentModel; -using RustTools.DataList; - namespace RustTools.ViewModels; public partial class UserViewModel : ObservableRecipient diff --git a/RustTools/Views/CodeDataPage.xaml b/RustTools/Views/CodeDataPage.xaml new file mode 100644 index 0000000..97b6d54 --- /dev/null +++ b/RustTools/Views/CodeDataPage.xaml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RustTools/Views/CodeDataPage.xaml.cs b/RustTools/Views/CodeDataPage.xaml.cs new file mode 100644 index 0000000..7cedb22 --- /dev/null +++ b/RustTools/Views/CodeDataPage.xaml.cs @@ -0,0 +1,140 @@ + +using System.Collections.ObjectModel; + +using Microsoft.UI.Xaml.Controls; +using Newtonsoft.Json; +using RustTools.DataList; +using RustTools.Helpers; +using RustTools.muqing; +using RustTools.ViewModels; +using Windows.Storage; +using Windows.UI.Popups; +namespace RustTools.Views; + +/// +/// ݼƬ +/// +public sealed partial class CodeDataPage : Page +{ + public CodeDataViewModel ViewModel + { + get; set; + } + public ObservableCollection DataConfig { get; set; } = new(); + public static DataBaseManifest codetable = new(); + public CodeDataPage() + { + ViewModel = new CodeDataViewModel(); + InitializeComponent(); + + var filePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "CodeTable"); + if (!Directory.Exists(filePath)) { return; } + var directoryInfo = new DirectoryInfo(filePath); + var directoryInfos = directoryInfo.GetDirectories(); + foreach (var item in directoryInfos) + { + var v = Path.Combine(item.FullName, "DataBaseManifest.json"); + if (File.Exists(v)) + { + var json = JsonConvert.DeserializeObject(File.ReadAllText(v)); + json.Dir = item.FullName; + //gj.sc(json.Dir); + DataConfig.Add(json); + + } + } + var FirstOrDefault = DataConfig.FirstOrDefault(any => any.id == "official"); + if (FirstOrDefault != null) + { + DataConfig.Remove(FirstOrDefault); + DataConfig.Insert(0, FirstOrDefault); + } + var aa = DataConfig.FirstOrDefault(any => any.Dir == codetable.Dir); + if (aa?.Dir == codetable.Dir) + { + listview.SelectedItem = aa; + } + } + + private void listview_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems[0] is DataBaseManifest item) + { + var iniHelper = new IniHelper(IniHelper.FILE.Config); + iniHelper.SetValue("CodeTable", "Dir", item.Dir ?? string.Empty); + iniHelper.Save(); + gj.sc(item.Dir); + codetable = item; + } + + } + private async void MenuFlyoutItem_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) + { + if (sender is MenuFlyoutItem item) + { + if (item.DataContext is DataBaseManifest data) + { + var str = item.Text; + if (str == "༭") + { + //ϵͳļûԼѡJson + wj.OpenFileExplorer(data.Dir); + } + else if (str == "ɾ") + { + var contentDialog = new ContentDialog() + { + XamlRoot = Content.XamlRoot, + Title = "ʾ", + Content = $"Ƿɾ {data.name}\nλ {data.Dir}", + CloseButtonText = "ȡ" + }; + if (data.id == "official") + { + contentDialog.Title = ""; + contentDialog.Content = "޷ɾٷݼ"; + } + else + { + contentDialog.PrimaryButtonText = "ȷ"; + } + var contentDialogResult = await contentDialog.ShowAsync(); + if (contentDialogResult == ContentDialogResult.Primary) + { + gj.sc("ɾļ" + data.Dir); + } + } + } + } + + } + + private async void AppBarButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) + { + if (sender is AppBarButton item) + { + var v = item.Tag.ToString(); + if (v == "0") + { + //½ + } + else if (v == "1") + { + // + var v1 = Path.Combine(wj.LocalFolder, "CodeTable"); + if (Directory.Exists(v1)) + { + wj.OpenFileExplorer(v1); + } + else + { + await Dialog.DialogWarn("ļ", XamlRoot); + } + } + else if (v == "2") + { + + } + } + } +} diff --git a/RustTools/Views/CodeTablePage.xaml b/RustTools/Views/CodeTablePage.xaml index 6e48266..2506809 100644 --- a/RustTools/Views/CodeTablePage.xaml +++ b/RustTools/Views/CodeTablePage.xaml @@ -3,11 +3,125 @@ x:Class="RustTools.Views.CodeTablePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="using:CommunityToolkit.WinUI.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:datalist="using:RustTools.DataList" xmlns:local="using:RustTools.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" + xmlns:themes="using:RustTools.Themes" mc:Ignorable="d"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RustTools/Views/CodeTablePage.xaml.cs b/RustTools/Views/CodeTablePage.xaml.cs index 9370ed2..c50d97e 100644 --- a/RustTools/Views/CodeTablePage.xaml.cs +++ b/RustTools/Views/CodeTablePage.xaml.cs @@ -1,8 +1,14 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Diagnostics.Metrics; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Xml.Linq; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; @@ -10,8 +16,13 @@ using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Navigation; -using Windows.Foundation; -using Windows.Foundation.Collections; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using RustTools.DataList; +using RustTools.muqing; +using RustTools.ViewModels; +using static System.Collections.Specialized.BitVector32; +using static RustTools.DataList.DataBaseManifest; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -22,8 +33,178 @@ namespace RustTools.Views; /// public sealed partial class CodeTablePage : Page { + public ObservableCollection? codeList = new(); + public CodeTableViewModel ViewModel { get; set; } + public List section = new(); public CodeTablePage() { - this.InitializeComponent(); + ViewModel = App.GetService(); + InitializeComponent(); + try + { + var path = Path.Combine(CodeDataPage.codetable.Dir, CodeDataPage.codetable.tables.code); + + var codeTable_Code = JsonConvert.DeserializeObject(File.ReadAllText(path)); + + var v1 = File.ReadAllText(Path.Combine(CodeDataPage.codetable.Dir, CodeDataPage.codetable.tables.section)); + section = JsonConvert.DeserializeObject(v1).data; + //gj.sc(v1); + foreach (var item in codeTable_Code.data) + { +#pragma warning disable SYSLIB1045 // תΪGeneratedRegexAttribute + foreach (var parts in Regex.Split(item.section, ",")) + { + var FirstOrDefault = codeList.FirstOrDefault(any => any.Key == parts); + if (FirstOrDefault != null) + { + FirstOrDefault.Vaule.Add(item); + } + else + { + var sectionData = section.FirstOrDefault(any => any.code == parts); + var translate = "Null"; + if (sectionData != null) + { + translate = sectionData.translate; + } + sectionData = null; + var codeTable1 = new CodeTable + { + Key = parts, + CnKey = translate, + Vaule = new List() + }; + codeTable1.Vaule.Add(item); + codeList.Add(codeTable1); + } + } + } + if (codeList.Count > 0) + { + //var firstEntry = codeList.FirstOrDefault(); + keyListView.SelectedItem = codeList.FirstOrDefault(); // Ĭѡеһ + } + + } + catch (Exception ex) + { + Task.Run(async () => { await Dialog.DialogWarn(ex.Message, XamlRoot); }); + } + + //var textBlock = new TextBlock(); + //textBlock.IsTextSelectionEnabled + } + + + private void keyListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + // ȡѡе + var addedItems = e.AddedItems; + foreach (var item in addedItems) + { + Debug.WriteLine($"Selected item: {item}"); + if (item is CodeTable a) + { + gj.sc(a); + valueList = a.Vaule; + valueListView.ItemsSource = a.Vaule; + } + // 絼һҳ桢Ի + } + + //// ȡƳ + //var removedItems = e.RemovedItems; + //foreach (var item in removedItems) + //{ + // Debug.WriteLine($"Deselected item: {item}"); + //} + } + + /// + /// ˳ʱ ֹڴй© + /// + /// + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + base.OnNavigatedFrom(e); + codeList?.Clear(); + codeList = null; + } + + + private void List_ButtonIcon_Click(object sender, RoutedEventArgs e) + { + var button = sender as Button; + if (button != null) { + if (button.DataContext is not CodeTable_Data codeTable_Data) { return; } + if (ToggleThemeTeachingTip1.IsOpen==false) + { + ToggleThemeTeachingTip1.Target = button; + ToggleThemeTeachingTip1.IsOpen = true; + } + else + { + ToggleThemeTeachingTip1.IsOpen = false; + } + ToastTextBlock.Text =codeTable_Data.demo; + gj.sc(codeTable_Data); + } + } + + private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args) + { + var str = args.SelectedItem.ToString(); + search.Text = str; + if (str == null) { return; } + var a=str.Split(' '); + List itemsSource = new(); + + foreach (var item in valueList) + { + if (item.code.Contains(a[0]) || item.translate.Contains(a[1])) + { + itemsSource.Add(item); + gj.sc(item.code); + } + } + gj.sc(itemsSource.Count); + valueListView.ItemsSource=itemsSource; + //valueListView.ItemsSource=search.ItemsSource; + } + + private List valueList = new (); + private void search_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) + { + + if (string.IsNullOrEmpty(search.Text)) + { + valueListView.ItemsSource = valueList; return; } + // Since selecting an item will also change the text, + // only listen to changes caused by user entering text. + if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) + { + var suitableItems = new List(); + var splitText = sender.Text.ToLower().Split(" "); + if (valueListView.ItemsSource is not List itemsSource) { return; } + foreach (var cat in itemsSource) + { + var found = splitText.All((key) => + { + if (string.IsNullOrEmpty(key)) { return false; } + return cat.code.Contains(key)||cat.translate.Contains(key); + }); + if (found) + { + suitableItems.Add(cat.code+" "+cat.translate); + } + } + if (suitableItems.Count == 0) + { + suitableItems.Add("No results found"); + } + sender.ItemsSource = suitableItems; + } + } } diff --git a/RustTools/Views/ShellPage.xaml b/RustTools/Views/ShellPage.xaml index 77fc499..1b0b348 100644 --- a/RustTools/Views/ShellPage.xaml +++ b/RustTools/Views/ShellPage.xaml @@ -67,6 +67,22 @@ + + + + + + + + + + diff --git a/RustTools/Views/ShellPage.xaml.cs b/RustTools/Views/ShellPage.xaml.cs index 1bc454e..6a6c00e 100644 --- a/RustTools/Views/ShellPage.xaml.cs +++ b/RustTools/Views/ShellPage.xaml.cs @@ -1,7 +1,6 @@ -using System; + using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; using Microsoft.UI.Xaml.Input; using RustTools.Contracts.Services; @@ -38,7 +37,7 @@ public sealed partial class ShellPage : Page App.MainWindow.SetTitleBar(AppTitleBar); App.MainWindow.Activated += MainWindow_Activated; } - //AppTitleBarText.Text = "app_name".GetLocalized() + " " + "app_version".GetLocalized(); + AppTitleBarText.Text = "app_name".GetLocalized() + " " + "app_version".GetLocalized(); //NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems[0]; //NavigationViewControl.SelectionChanged += NavigationViewControl_SelectionChanged; //NavigateToPage("Home"); diff --git a/RustTools/muqing/Dialog.cs b/RustTools/muqing/Dialog.cs new file mode 100644 index 0000000..b75d383 --- /dev/null +++ b/RustTools/muqing/Dialog.cs @@ -0,0 +1,49 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Windows.UI.Popups; + +namespace RustTools.muqing; +public class Dialog +{ + //WinRT 信息: 此 API 必须由具有 CoreWindow 的线程或已进行显式设置的窗口来调用。 + public static async Task windowDialog(string title) + { + + var messageDialog = new MessageDialog("No internet connection has been found.","title"); + //messageDialog.set + //// Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers + //messageDialog.Commands.Add(new UICommand( + // "确定")); + //messageDialog.Commands.Add(new UICommand( + // "取消")); + + //// Set the command that will be invoked by default + //messageDialog.DefaultCommandIndex = 0; + + //// Set the command to be invoked when escape is pressed + //messageDialog.CancelCommandIndex = 1; + + // Show the message dialog + await messageDialog.ShowAsync(); + } + + public const string warning = "警告"; + public const string Close = "取消"; + public static async Task DialogWarn(string sub, XamlRoot xamlRoot) + { + var contentDialog = new ContentDialog() + { + XamlRoot = xamlRoot, + Title = warning, + Content = sub, + CloseButtonText = Close + }; + return await contentDialog.ShowAsync(); + } +} diff --git a/RustTools/muqing/IniHelper.cs b/RustTools/muqing/IniHelper.cs index fe0c761..49c2416 100644 --- a/RustTools/muqing/IniHelper.cs +++ b/RustTools/muqing/IniHelper.cs @@ -1,5 +1,6 @@ using Windows.Storage; +#pragma warning disable CA1050 // 在命名空间中声明类型 public class IniHelper { private readonly Dictionary> _sections = new(); @@ -74,7 +75,6 @@ public class IniHelper /// public void Load(string a) { - filePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, a); if (!File.Exists(filePath)) {// 使用 File.Create 创建文件并立即关闭 diff --git a/RustTools/muqing/wj.cs b/RustTools/muqing/wj.cs index 5b8ffd8..f8babad 100644 --- a/RustTools/muqing/wj.cs +++ b/RustTools/muqing/wj.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.IO.Compression; +using Windows.Storage; namespace RustTools.muqing; #pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。 @@ -11,6 +12,9 @@ public class wj //缓存路径 public const string Cache = ""; + public static string LocalFolder = ApplicationData.Current.LocalFolder.Path; + //ApplicationData.Current.LocalFolder.Path + //不知道为什么会保存到这里的路径 废弃了 , 找到了新的文件夹路径 //public const string CachePath= "C:/Users/19669/AppData/Local/VirtualStore/Windows/SysWOW64"; @@ -130,5 +134,22 @@ public class wj return string.Empty; } } - + public static void OpenFileExplorer(string path) + { + try + { + Process.Start("explorer.exe", path); + } + catch (System.ComponentModel.Win32Exception noBrowser) + { + if (noBrowser.ErrorCode == -2147467259) + throw new Exception("There is no default browser configured."); + else + throw; + } + catch (System.Exception other) + { + throw other; + } + } }