diff --git a/TslTools/App.xaml.cs b/TslTools/App.xaml.cs
new file mode 100644
index 0000000..e3a109f
--- /dev/null
+++ b/TslTools/App.xaml.cs
@@ -0,0 +1,14 @@
+using System.Configuration;
+using System.Data;
+using System.Windows;
+
+namespace TslTools
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+
+}
diff --git a/TslTools/MainWindow.xaml b/TslTools/MainWindow.xaml
new file mode 100644
index 0000000..dde0fc8
--- /dev/null
+++ b/TslTools/MainWindow.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TslTools/MainWindow.xaml.cs b/TslTools/MainWindow.xaml.cs
new file mode 100644
index 0000000..83d04c0
--- /dev/null
+++ b/TslTools/MainWindow.xaml.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace TslTools
+{
+ public partial class MainWindow : Window
+ {
+ private readonly string processName = "TslGame";
+ private readonly string batFilePath = @"D:\TslGameServer\TslGame\Binaries\Win64\LocalServer.bat";
+ private Timer processCheckTimer;
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ Log("Monitoring process initiated...");
+ StartProcessCheck();
+ }
+
+ private void StartProcessCheck()
+ {
+ processCheckTimer = new Timer(CheckProcess, null, 0, 3000);
+ }
+
+ private void CheckProcess(object state)
+ {
+ bool processExists = Process.GetProcessesByName(processName).Length > 0;
+
+ if (!processExists)
+ {
+ Log("TslGame not found! Attempting to restart...");
+ StartLocalServer();
+ }
+ }
+
+ private void StartLocalServer()
+ {
+ if (File.Exists(batFilePath))
+ {
+ ProcessStartInfo startInfo = new ProcessStartInfo
+ {
+ FileName = batFilePath,
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ CreateNoWindow = true
+ };
+
+ using (Process process = Process.Start(startInfo))
+ {
+ process.WaitForExit();
+ string output = process.StandardOutput.ReadToEnd();
+ string error = process.StandardError.ReadToEnd();
+
+ if (!string.IsNullOrEmpty(output))
+ {
+ Log(output);
+ }
+
+ if (!string.IsNullOrEmpty(error))
+ {
+ Log($"启动失败,错误信息:{error}");
+ }
+ }
+ }
+ else
+ {
+ Log("An error occurred during the attempt to start!");
+ }
+ }
+
+ private void Log(string message)
+ {
+ Dispatcher.Invoke(() =>
+ {
+ LogTextBox.AppendText(message + Environment.NewLine);
+ LogTextBox.ScrollToEnd();
+ });
+ }
+
+ // 清理.dmp文件按钮点击事件
+ private void btnCleanDmp_Click(object sender, RoutedEventArgs e)
+ {
+ string currentDirectory = Environment.CurrentDirectory;
+ string[] dmpFiles = Directory.GetFiles(currentDirectory, "*.dmp");
+ int deletedCount = 0;
+
+ foreach (string file in dmpFiles)
+ {
+ try
+ {
+ File.Delete(file);
+ deletedCount++;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"删除文件 {file} 时发生错误:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ if (deletedCount > 0)
+ {
+ TrashLog($"{deletedCount} DMP file has been deleted");
+ }
+ else
+ {
+ TrashLog("No .dmp files detected, no need to clean.");
+ }
+ }
+
+ // 清理Logs文件夹按钮点击事件
+ private void btnCleanLogs_Click(object sender, RoutedEventArgs e)
+ {
+ string logsDirectory = @"C:\Users\Administrator\AppData\Local\TslGame\Saved\Logs";
+ string[] files = Directory.GetFiles(logsDirectory);
+ int deletedCount = 0;
+
+ foreach (string file in files)
+ {
+ try
+ {
+ File.Delete(file);
+ deletedCount++;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"删除文件 {file} 时发生错误:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ string[] directories = Directory.GetDirectories(logsDirectory);
+ foreach (string directory in directories)
+ {
+ try
+ {
+ Directory.Delete(directory, true);
+ deletedCount++;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"删除文件夹 {directory} 时发生错误:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ if (deletedCount > 0)
+ {
+ TrashLog($"{deletedCount} file and folder have been deleted.");
+ }
+ else
+ {
+ TrashLog("No files or folders found, no need to clean.");
+ }
+ }
+
+ private void TrashLog(string message)
+ {
+ Dispatcher.Invoke(() =>
+ {
+ TrashLogTextBox.AppendText(message + Environment.NewLine);
+ TrashLogTextBox.ScrollToEnd();
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/TslTools/TslTools.csproj b/TslTools/TslTools.csproj
new file mode 100644
index 0000000..3c51e41
--- /dev/null
+++ b/TslTools/TslTools.csproj
@@ -0,0 +1,20 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ enable
+ true
+ AnyCPU;x64
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TslTools/TslTools.csproj.user b/TslTools/TslTools.csproj.user
new file mode 100644
index 0000000..bbee65c
--- /dev/null
+++ b/TslTools/TslTools.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ <_LastSelectedProfileId>C:\Users\WMR-821\source\repos\TslTools\TslTools\Properties\PublishProfiles\FolderProfile.pubxml
+
+
\ No newline at end of file