优化和修复BUG
This commit is contained in:
parent
1424fb2de9
commit
b860f5fcc0
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="RustTools.Assets.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
<section name="RustTools.Assets.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<RustTools.Assets.Settings>
|
||||
<setting name="设置" serializeAs="String">
|
||||
<value>1</value>
|
||||
</setting>
|
||||
</RustTools.Assets.Settings>
|
||||
<RustTools.Assets.Settings1>
|
||||
<setting name="主题颜色" serializeAs="String">
|
||||
<value>1</value>
|
||||
</setting>
|
||||
<setting name="Mod" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</RustTools.Assets.Settings1>
|
||||
</userSettings>
|
||||
</configuration>
|
|
@ -106,6 +106,8 @@ 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);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<Platforms>x86;x64;arm64</Platforms>
|
||||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
||||
|
||||
<!--<WindowsPackageType>None</WindowsPackageType>-->
|
||||
<!--<WindowsPackageType>None</WindowsPackageType>-->
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -51,6 +51,7 @@
|
|||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||
<PackageReference Include="RestClient" Version="3.1024.23771" />
|
||||
<PackageReference Include="RestSharp" Version="111.4.0" />
|
||||
<PackageReference Include="squirrel.windows" Version="2.0.1" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="WinUIEx" Version="2.3.2" />
|
||||
|
||||
|
|
26
RustTools/Services/BooleanToVisibilityConverter.cs
Normal file
26
RustTools/Services/BooleanToVisibilityConverter.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
|
||||
namespace RustTools.Services;
|
||||
|
||||
public class BooleanToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
|
||||
return string.IsNullOrEmpty(value.ToString()) ? Visibility.Collapsed: Visibility.Visible;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is Visibility visibility)
|
||||
{
|
||||
return visibility == Visibility.Visible;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
global using WinUIEx;
|
||||
global using WinUIEx;
|
|
@ -3,6 +3,7 @@
|
|||
x:Class="RustTools.Views.CodeTablePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Services="using:RustTools.Services"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:datalist="using:RustTools.DataList"
|
||||
|
@ -11,6 +12,9 @@
|
|||
xmlns:themes="using:RustTools.Themes"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<Services:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
</Page.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
@ -122,7 +126,8 @@
|
|||
Grid.Column="1"
|
||||
VerticalAlignment="Top"
|
||||
Click="List_ButtonIcon_Click"
|
||||
Glyph="" />
|
||||
Glyph=""
|
||||
Visibility="{Binding demo, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=''}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
|
|
@ -13,14 +13,11 @@
|
|||
<Page.Resources>
|
||||
<!-- 模组 -->
|
||||
<DataTemplate x:Key="RwmodItem">
|
||||
<Button
|
||||
Background="{ThemeResource SystemColorWindowColor}"
|
||||
Click="Button_Click_RwmodItem"
|
||||
CornerRadius="9">
|
||||
<Grid Background="{ThemeResource SystemColorWindowColor}" CornerRadius="9">
|
||||
<Grid
|
||||
Width="130"
|
||||
Height="160"
|
||||
Padding="9">
|
||||
Padding="9,0,9,9">
|
||||
<Image
|
||||
Width="50"
|
||||
Height="50"
|
||||
|
@ -45,22 +42,25 @@
|
|||
TextWrapping="NoWrap" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<!-- 文件夹 -->
|
||||
<DataTemplate x:Key="FolderItem">
|
||||
<Button
|
||||
<Grid
|
||||
Background="{ThemeResource SystemColorWindowColor}"
|
||||
CornerRadius="9"
|
||||
ToolTipService.ToolTip="{Binding Info}">
|
||||
<Button.Flyout>
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Text="打开" />
|
||||
<MenuFlyoutItem
|
||||
IsEnabled="False"
|
||||
Text="打开"
|
||||
ToolTipService.ToolTip="制作中···" />
|
||||
<MenuFlyoutItem Click="Button_Rwmod" Text="打包" />
|
||||
<MenuFlyoutItem Text="发布" />
|
||||
<MenuFlyoutItem Click="Button_Delete" Text="删除" />
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Grid.ContextFlyout>
|
||||
<Grid
|
||||
Width="130"
|
||||
Height="160"
|
||||
|
@ -84,7 +84,7 @@
|
|||
TextWrapping="NoWrap" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
|
@ -107,12 +107,20 @@
|
|||
|
||||
<GridView
|
||||
x:Name="BasicGridView"
|
||||
IsItemClickEnabled="False"
|
||||
AllowDrop="True"
|
||||
CanReorderItems="True"
|
||||
DoubleTapped="BasicGridView_DoubleTapped"
|
||||
IsItemClickEnabled="True"
|
||||
ItemsSource="{x:Bind ViewModel.ListMod}"
|
||||
SelectionMode="None">
|
||||
SelectionMode="Single">
|
||||
<GridView.ItemTemplateSelector>
|
||||
<local:MyItemTemplateSelector Template1="{StaticResource RwmodItem}" Template2="{StaticResource FolderItem}" />
|
||||
</GridView.ItemTemplateSelector>
|
||||
<GridView.ItemContainerStyle>
|
||||
<Style TargetType="GridViewItem">
|
||||
<Setter Property="Margin" Value="6" />
|
||||
</Style>
|
||||
</GridView.ItemContainerStyle>
|
||||
</GridView>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ using Microsoft.UI.Xaml;
|
|||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using RustTools.muqing;
|
||||
using RustTools.ViewModels;
|
||||
using SharpCompress.Common;
|
||||
namespace RustTools.Views;
|
||||
/// <summary>
|
||||
/// 模组碎片
|
||||
|
@ -110,7 +112,7 @@ public sealed partial class ModulePage : Page
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Button_Delete(object sender, RoutedEventArgs e)
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var menuItem = sender as Control;
|
||||
gj.sc(menuItem);
|
||||
|
@ -118,15 +120,21 @@ public sealed partial class ModulePage : Page
|
|||
{
|
||||
if (menuItem.DataContext is DataObject folderItem)
|
||||
{
|
||||
if (Directory.Exists(folderItem.Dri))
|
||||
var task = await Dialog.DialogWarnYes("你确定要删除(回收站)" + folderItem.Dri, XamlRoot);
|
||||
if (task == ContentDialogResult.Primary)
|
||||
{
|
||||
// 删除文件夹
|
||||
Directory.Delete(folderItem.Dri, true);
|
||||
}
|
||||
else if (File.Exists(folderItem.Dri))
|
||||
{
|
||||
//删除文件
|
||||
File.Delete(folderItem.Dri);
|
||||
if (Directory.Exists(folderItem.Dri))
|
||||
{
|
||||
// 删除文件夹
|
||||
//Directory.Delete(folderItem.Dri, true);
|
||||
FileSystem.DeleteDirectory(folderItem.Dri, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||
}
|
||||
else if (File.Exists(folderItem.Dri))
|
||||
{
|
||||
//删除文件
|
||||
//File.Delete(folderItem.Dri);
|
||||
FileSystem.DeleteFile(folderItem.Dri, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||
}
|
||||
}
|
||||
ViewModel.ListMod.Remove(folderItem);
|
||||
}
|
||||
|
@ -140,7 +148,7 @@ public sealed partial class ModulePage : Page
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void Button_Click_RwmodItem(object sender, RoutedEventArgs e)
|
||||
private async void UnzipRwmod(DataObject a)
|
||||
{
|
||||
ContentDialog dialog = new ContentDialog
|
||||
{
|
||||
|
@ -153,33 +161,24 @@ public sealed partial class ModulePage : Page
|
|||
var contentDialogResult = await dialog.ShowAsync();
|
||||
if (contentDialogResult == ContentDialogResult.Primary)
|
||||
{
|
||||
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
||||
|
||||
var button = sender as Button;
|
||||
if (button != null)
|
||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(a.Dri);
|
||||
var GetDirectoryName = Path.GetDirectoryName(a.Dri);
|
||||
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
||||
{
|
||||
var container = VisualTreeHelper.GetParent(button) as FrameworkElement;
|
||||
if (container != null && container.DataContext is DataObject dataItem)
|
||||
var targetDirectory = Path.Combine(GetDirectoryName, fileNameWithoutExtension);
|
||||
var v = wj.UnzipFile(a.Dri, targetDirectory);
|
||||
gj.sc("解压成功:" + v);
|
||||
if (checkbox?.IsChecked == true)
|
||||
{
|
||||
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
||||
|
||||
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(dataItem.Dri);
|
||||
var GetDirectoryName = Path.GetDirectoryName(dataItem.Dri);
|
||||
if (Directory.Exists(GetDirectoryName) && fileNameWithoutExtension != null)
|
||||
{
|
||||
var targetDirectory = Path.Combine(GetDirectoryName, fileNameWithoutExtension);
|
||||
var v = wj.UnzipFile(dataItem.Dri, targetDirectory);
|
||||
gj.sc("解压成功:"+v);
|
||||
if (checkbox?.IsChecked == true)
|
||||
{
|
||||
File.Delete(dataItem.Dri);
|
||||
ViewModel.ListMod.Remove(dataItem);
|
||||
}
|
||||
if (v)
|
||||
{
|
||||
ViewModel.ListMod.Remove(new DataObject(new DirectoryInfo(targetDirectory)));
|
||||
ViewModel.ListMod.Insert(0,new DataObject(new DirectoryInfo(targetDirectory)));
|
||||
}
|
||||
}
|
||||
File.Delete(a.Dri);
|
||||
ViewModel.ListMod.Remove(a);
|
||||
}
|
||||
if (v)
|
||||
{
|
||||
ViewModel.ListMod.Remove(new DataObject(new DirectoryInfo(targetDirectory)));
|
||||
ViewModel.ListMod.Insert(0, new DataObject(new DirectoryInfo(targetDirectory)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,6 +248,32 @@ public sealed partial class ModulePage : Page
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击GridView事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void BasicGridView_DoubleTapped(object sender, Microsoft.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
|
||||
{
|
||||
|
||||
var gridView = sender as GridView;
|
||||
var item = (e.OriginalSource as FrameworkElement)?.DataContext;
|
||||
|
||||
if (item != null && gridView != null)
|
||||
{
|
||||
// 这里处理双击事件,例如显示一个消息框
|
||||
// 替换为实际的数据类型
|
||||
if (item is DataObject clickedItem)
|
||||
{
|
||||
// 在这里处理双击项
|
||||
var IsRwmod = clickedItem.IsRwmod; // 假设你的项有一个 Name 属性
|
||||
if (IsRwmod) {
|
||||
UnzipRwmod(clickedItem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class MyItemTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
|
|
|
@ -98,10 +98,14 @@
|
|||
Style="{ThemeResource BodyTextBlockStyle}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<HyperlinkButton
|
||||
Margin="0,4,26,0"
|
||||
Margin="{StaticResource SettingsPageHyperlinkButtonMargin}"
|
||||
Content="开源地址"
|
||||
NavigateUri="https://git.coldmint.top/muqing" />
|
||||
<HyperlinkButton x:Uid="SettingsPage_PrivacyTermsLink" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
|
||||
<HyperlinkButton
|
||||
Margin="{StaticResource SettingsPageHyperlinkButtonMargin}"
|
||||
Content="创建快捷方式"
|
||||
NavigateUri="https://blog.csdn.net/Tisfy/article/details/132254567" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ public class Dialog
|
|||
|
||||
public const string warning = "警告";
|
||||
public const string Close = "取消";
|
||||
public const string Primary = "确定";
|
||||
public static async Task<ContentDialogResult> DialogWarn(string sub, XamlRoot xamlRoot)
|
||||
{
|
||||
var contentDialog = new ContentDialog()
|
||||
|
@ -46,4 +47,24 @@ public class Dialog
|
|||
};
|
||||
return await contentDialog.ShowAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带有确定按钮的警告
|
||||
/// </summary>
|
||||
/// <param name="sub"></param>
|
||||
/// <param name="xamlRoot"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<ContentDialogResult> DialogWarnYes(string sub, XamlRoot xamlRoot)
|
||||
{
|
||||
var contentDialog = new ContentDialog()
|
||||
{
|
||||
XamlRoot = xamlRoot,
|
||||
Title = warning,
|
||||
Content = sub,
|
||||
CloseButtonText = Close,
|
||||
PrimaryButtonText= Primary,
|
||||
PrimaryButtonStyle= Application.Current.Resources["AccentButtonStyle"] as Style
|
||||
};
|
||||
return await contentDialog.ShowAsync();
|
||||
}
|
||||
}
|
||||
|
|
74
RustTools/muqing/IShellLinkW.cs
Normal file
74
RustTools/muqing/IShellLinkW.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
[ComImport]
|
||||
[Guid("000214F9-0000-0000-C000-000000000046")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IShellLinkW
|
||||
{
|
||||
void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, ref WIN32_FIND_DATAW pfd, uint fFlags);
|
||||
void GetIDList(out IntPtr ppidl);
|
||||
void SetIDList(IntPtr pidl);
|
||||
void GetDescription([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
|
||||
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
|
||||
void GetWorkingDirectory([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
|
||||
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
|
||||
void GetArguments([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
|
||||
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
|
||||
void GetHotkey(out short pwHotkey);
|
||||
void SetHotkey(short wHotkey);
|
||||
void GetShowCmd(out int piShowCmd);
|
||||
void SetShowCmd(int iShowCmd);
|
||||
void GetIconLocation([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath);
|
||||
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
|
||||
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved);
|
||||
void Resolve(IntPtr hwnd, uint fFlags);
|
||||
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
|
||||
public struct WIN32_FIND_DATAW
|
||||
{
|
||||
public uint dwFileAttributes;
|
||||
public FILETIME ftCreationTime;
|
||||
public FILETIME ftLastAccessTime;
|
||||
public FILETIME ftLastWriteTime;
|
||||
public uint nFileSizeHigh;
|
||||
public uint nFileSizeLow;
|
||||
public uint dwReserved0;
|
||||
public uint dwReserved1;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
public string cFileName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
|
||||
public string cAlternateFileName;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct FILETIME
|
||||
{
|
||||
public uint dwLowDateTime;
|
||||
public uint dwHighDateTime;
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[Guid("0000010B-0000-0000-C000-000000000046")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IPersistFile
|
||||
{
|
||||
void GetClassID(out Guid pClassID);
|
||||
[PreserveSig]
|
||||
int IsDirty();
|
||||
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode);
|
||||
void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember);
|
||||
void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName);
|
||||
void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName);
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[Guid("00021401-0000-0000-C000-000000000046")]
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
public class ShellLink
|
||||
{
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using Windows.Storage;
|
||||
using RustTools.muqing;
|
||||
using Windows.Storage;
|
||||
|
||||
#pragma warning disable CA1050 // 在命名空间中声明类型
|
||||
public class IniHelper
|
||||
|
|
|
@ -6,21 +6,21 @@ using Microsoft.UI.Xaml;
|
|||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.Win32;
|
||||
using RustTools.muqing;
|
||||
/// <summary>
|
||||
/// 模组搜索引擎操作
|
||||
/// </summary>
|
||||
public class Mod
|
||||
{
|
||||
|
||||
//开始计时
|
||||
private static DateTime StartTime;
|
||||
/// <summary>
|
||||
/// 统计运行耗时
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
private static void EndTime()
|
||||
{
|
||||
Console.WriteLine("执行时间:" + (DateTime.Now - StartTime).TotalMilliseconds + "ms");
|
||||
Console.WriteLine("结束" + (DateTime.Now - StartTime).TotalMilliseconds + "ms");
|
||||
}
|
||||
|
||||
private readonly bool Isdot = true;//是否排除.开头的文件夹
|
||||
//排除的文件夹
|
||||
private readonly bool Isdot = true;
|
||||
private readonly List<string> ExcludeFile = new(){
|
||||
"Android", "androidword", "Java",
|
||||
"Linux", "linuxword", "Mac",
|
||||
|
@ -28,12 +28,10 @@ public class Mod
|
|||
"Genshin Impact Game", "Godot", "Gradle",
|
||||
"WeGame", "Mental Omega", "WeGameApps",
|
||||
"ramboplayGame", "QQ", "QQWORD","Microsoft SDKs","Creator","editors","AndroidSDK","SDK","Pr","PR","PS","Ps","WE",
|
||||
"androidstudioword","鸿图对战平台","xshell7"
|
||||
"androidstudioword","<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>սƽ̨","xshell7"
|
||||
};
|
||||
//游戏位置
|
||||
public string FileDir = string.Empty;
|
||||
private readonly ContentDialog? dialog = null;
|
||||
//在MainPage的后台code里面添加这个申明
|
||||
public async void Invoke(Action action, Windows.UI.Core.CoreDispatcherPriority Priority = Windows.UI.Core.CoreDispatcherPriority.Normal)
|
||||
{
|
||||
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Priority, () => { action(); });
|
||||
|
@ -48,20 +46,16 @@ public class Mod
|
|||
this.xamlRoot = xamlRoot;
|
||||
this.action = action;
|
||||
StartTime = DateTime.Now;
|
||||
|
||||
Debug.WriteLine("开始执行文件搜索引擎");
|
||||
//先找steam中的位置
|
||||
steam();
|
||||
if (FileDir == string.Empty)
|
||||
{
|
||||
//找不到执行搜索引擎
|
||||
gj.sc("找不到执行搜索引擎");
|
||||
|
||||
dialog = new ContentDialog()
|
||||
{
|
||||
XamlRoot = xamlRoot,
|
||||
Title = "提示",
|
||||
Content = "搜索中",
|
||||
PrimaryButtonText = "关闭"
|
||||
Title = "提示ʾ",
|
||||
Content = "搜索中···",
|
||||
PrimaryButtonText = "取消"
|
||||
};
|
||||
dialog.Closing += Dialog_Closing;
|
||||
|
||||
|
@ -69,8 +63,6 @@ public class Mod
|
|||
Task.Run(async () =>
|
||||
{
|
||||
await init();
|
||||
// 使用 DispatcherQueue 将 UI 更新委托回 UI 线程
|
||||
|
||||
_dispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
dialog.Closing -= Dialog_Closing;
|
||||
|
@ -78,22 +70,12 @@ public class Mod
|
|||
action?.Invoke(FileDir);
|
||||
});
|
||||
});
|
||||
//if (IsSearch)
|
||||
//{
|
||||
//}
|
||||
//var thread = new Thread(init);
|
||||
//thread.Start();
|
||||
//thread.Join();
|
||||
}
|
||||
else
|
||||
{
|
||||
action?.Invoke(FileDir);
|
||||
}
|
||||
//dialog.Closing -= Dialog_Closing;
|
||||
//if (FileDir != string.Empty) {
|
||||
// dialog.Content = FileDir;
|
||||
//}
|
||||
//dialog.Hide();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,23 +94,18 @@ public class Mod
|
|||
var steamPath = GetSteamInstallPath();
|
||||
if (!string.IsNullOrEmpty(steamPath))
|
||||
{
|
||||
Console.WriteLine("已经找到steam安装位置" + steamPath);
|
||||
var b = Directory.Exists(steamPath + "\\steamapps\\common\\Rusted Warfare");
|
||||
if (b)
|
||||
{
|
||||
//结束计时
|
||||
Console.WriteLine("已找到游戏文件路径 " + steamPath + "\\steamapps\\common\\Rusted Warfare");
|
||||
FileDir = steamPath + "\\steamapps\\common\\Rusted Warfare";
|
||||
EndTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("未找到游戏文件路径");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("找不到steam的安装位置");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,7 +116,6 @@ public class Mod
|
|||
foreach (var d in allDrives)
|
||||
{
|
||||
Console.WriteLine();
|
||||
// Console.WriteLine(" Drive type: {0}", d.DriveType);
|
||||
if (d.IsReady == true)
|
||||
{
|
||||
var name = d.Name;
|
||||
|
@ -147,20 +123,15 @@ public class Mod
|
|||
{
|
||||
continue;
|
||||
}
|
||||
//只要不是C盘
|
||||
|
||||
if (name.Equals("C:\\"))
|
||||
{
|
||||
Debug.WriteLine("在C盘游戏文件路径");
|
||||
FileSearch(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("在其他盘中快速找游戏文件路径");
|
||||
// steam\steamapps\common\Rusted Warfare
|
||||
// new FileSearch(name).Search();
|
||||
if (Directory.Exists(name + "/Rusted Warfare"))
|
||||
{
|
||||
Debug.WriteLine("找到游戏文件路径");
|
||||
EndTime();
|
||||
break;
|
||||
}
|
||||
|
@ -174,42 +145,28 @@ public class Mod
|
|||
}
|
||||
}
|
||||
|
||||
//是否还搜索
|
||||
public bool IsSearch = true;
|
||||
private void FileSearch(string path)
|
||||
{
|
||||
Debug.WriteLine("开始遍历文件夹" + path);
|
||||
try
|
||||
{
|
||||
// 遍历文件夹
|
||||
foreach (var file in Directory.EnumerateDirectories(path))
|
||||
{
|
||||
if (!IsSearch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//排除特殊符号的文件夹
|
||||
// if (file.contains("$"))
|
||||
// {
|
||||
// Console.WriteLine("排除特殊符号开头的文件夹" + file);
|
||||
// continue;
|
||||
// }
|
||||
//排除.开头的文件
|
||||
var name = Path.GetFileName(file);
|
||||
if (Isdot && name.StartsWith("."))
|
||||
{
|
||||
Debug.WriteLine("排除。开头的文件夹" + file);
|
||||
continue;
|
||||
}
|
||||
//排除掉列表中的文件夹
|
||||
if (ExcludeFile.Contains(name))
|
||||
{
|
||||
Debug.WriteLine("排除列表中的文件夹" + file);
|
||||
continue;
|
||||
}
|
||||
if (name.Equals("Rusted Warfare"))
|
||||
{
|
||||
Debug.WriteLine("找到游戏文件路径" + file);
|
||||
FileDir = file;
|
||||
EndTime();
|
||||
break;
|
||||
|
@ -223,12 +180,10 @@ public class Mod
|
|||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// 如果访问被拒绝,跳过该文件夹并记录信息
|
||||
Console.WriteLine($"Access denied for: {path}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 捕获其他可能的异常
|
||||
Console.WriteLine($"Error accessing directory '{path}': {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +195,6 @@ public class Mod
|
|||
|
||||
if (string.IsNullOrEmpty(installPath))
|
||||
{
|
||||
// 如果在当前用户下找不到,再试一下所有用户
|
||||
installPath = GetInstallPathFromKey(@"SOFTWARE\Wow6432Node\Valve\Steam");
|
||||
}
|
||||
|
||||
|
@ -252,7 +206,7 @@ public class Mod
|
|||
{
|
||||
if (key != null)
|
||||
{
|
||||
object path = key.GetValue("InstallPath");
|
||||
var path = key.GetValue("InstallPath");
|
||||
if (path != null)
|
||||
{
|
||||
return (string)path;
|
||||
|
@ -260,7 +214,7 @@ public class Mod
|
|||
}
|
||||
}
|
||||
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKey))
|
||||
using (var key = Registry.LocalMachine.OpenSubKey(subKey))
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
|
@ -272,7 +226,7 @@ public class Mod
|
|||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user