Update Chinese Version
This commit is contained in:
parent
32f5b23ef1
commit
ab4b7397a2
11 changed files with 567 additions and 0 deletions
59
ServerLauncher/AboutWindow.xaml
Normal file
59
ServerLauncher/AboutWindow.xaml
Normal file
|
@ -0,0 +1,59 @@
|
|||
<Window x:Class="ServerLauncher.Window2"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ServerLauncher"
|
||||
mc:Ignorable="d"
|
||||
Title="TslGame 服务器启动器 - 关于我们"
|
||||
Icon="pack://application:,,,/Resource/Image/MWIcon.ico"
|
||||
Height="450"
|
||||
Width="800"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize">
|
||||
<!-- <Window.Background>
|
||||
<ImageBrush ImageSource="pack://application:,,,/Resource/Image/TslGameServerBack1.jpg"/>
|
||||
</Window.Background> -->
|
||||
<Grid Margin="10,10,10,-5">
|
||||
<!-- 定义行和列 -->
|
||||
<!-- 添加一列用于状态文字 -->
|
||||
<!-- 状态文字 -->
|
||||
<TextBlock
|
||||
Foreground="Black"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="20"
|
||||
FontFamily="Alimama FangYuanTi VF SemiBold"
|
||||
Margin="0,10,0,359"><Run Language="zh-cn" Text="社交媒体"/></TextBlock>
|
||||
<TextBlock
|
||||
Foreground="Black"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="14"
|
||||
FontFamily="Alimama FangYuanTi VF SemiBold"
|
||||
Margin="0,34,0,289"><Run Language="zh-cn" Text="切勿上当受骗!本项目及其他有关内容是完全开源的。"/></TextBlock>
|
||||
<Image Margin="392,-680,360,-458" Source="/Resource/Image/Line1.png" Stretch="Fill" RenderTransformOrigin="2.111,0.505">
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform Angle="90.021"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
<TextBlock
|
||||
Foreground="Black"
|
||||
FontSize="14"
|
||||
FontFamily="Alimama FangYuanTi VF SemiBold"
|
||||
Margin="209,369,0,-350" Width="388" ScrollViewer.HorizontalScrollBarVisibility="Visible" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left">
|
||||
<TextBlock.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform AngleX="0"/>
|
||||
<RotateTransform/>
|
||||
<TranslateTransform X="0"/>
|
||||
</TransformGroup>
|
||||
</TextBlock.RenderTransform><Run Text="Copyright © 2025 "/><Run Text=" 开发者:"/><Run Text="在下王某人 "/><Run Language="zh-cn" Text="(请勿转卖!)"/></TextBlock>
|
||||
<Button Content="加入 Discord" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,0" HorizontalAlignment="Center" Click="Button_JoinDC_Click" RenderTransformOrigin="0.368,0.386" Width="136" VerticalAlignment="Top" Height="27" Margin="0,164,0,0"/>
|
||||
<Button Content="加入 QQ 群" FontFamily="Alimama FangYuanTi VF SemiBold" Padding="9,0" HorizontalAlignment="Center" Click="Button_JoinQQ_Click" RenderTransformOrigin="0.368,0.386" Width="136" Background="Yellow" VerticalAlignment="Top" Height="27" Margin="0,215,0,0"/>
|
||||
</Grid>
|
||||
</Window>
|
56
ServerLauncher/AboutWindow.xaml.cs
Normal file
56
ServerLauncher/AboutWindow.xaml.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerLauncher
|
||||
{
|
||||
/// <summary>
|
||||
/// Window2.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Window2 : Window
|
||||
{
|
||||
public Window2()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//加入 Discord 按钮
|
||||
private void Button_JoinDC_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string url = "https://discord.gg/yrcaukyEcw";
|
||||
try
|
||||
{
|
||||
// 使用默认浏览器打开链接
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = url,
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception ex)
|
||||
{
|
||||
// 如果系统中没有默认浏览器,会抛出异常
|
||||
MessageBox.Show($"无法打开链接:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
//加入 QQ 群 按钮
|
||||
private void Button_JoinQQ_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string url = "https://qm.qq.com/q/q8dzw0E8Xm";
|
||||
try
|
||||
{
|
||||
// 使用默认浏览器打开链接
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = url,
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception ex)
|
||||
{
|
||||
// 如果系统中没有默认浏览器,会抛出异常
|
||||
MessageBox.Show($"无法打开链接:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
ServerLauncher/App.xaml
Normal file
9
ServerLauncher/App.xaml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="ServerLauncher.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:ServerLauncher"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
14
ServerLauncher/App.xaml.cs
Normal file
14
ServerLauncher/App.xaml.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerLauncher
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
|
||||
}
|
10
ServerLauncher/AssemblyInfo.cs
Normal file
10
ServerLauncher/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
BIN
ServerLauncher/MWIcon.ico
Normal file
BIN
ServerLauncher/MWIcon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
68
ServerLauncher/MainWindow.xaml
Normal file
68
ServerLauncher/MainWindow.xaml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<Window x:Class="ServerLauncher.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ServerLauncher"
|
||||
mc:Ignorable="d"
|
||||
Title="TslGame 服务器启动器"
|
||||
Icon="pack://application:,,,/Resource/Image/MWIcon.ico"
|
||||
Height="450"
|
||||
Width="800"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize">
|
||||
<Window.Background>
|
||||
<ImageBrush ImageSource="pack://application:,,,/Resource/Image/TslGameServerBack1.jpg"/>
|
||||
</Window.Background>
|
||||
<Grid Margin="10,10,0,-5">
|
||||
<!-- 定义行和列 -->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="45.96"/>
|
||||
<RowDefinition Height="104.44"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<!-- 添加一个额外的行用于状态显示 -->
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<!-- 添加一列用于状态文字 -->
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<Button Content="启动服务器" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,4" HorizontalAlignment="Center" Grid.Row="0" Margin="0,5,0,5" Click="Button_StartTSLServer_Click"/>
|
||||
<Button Content="结束服务器" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,4" HorizontalAlignment="Center" Grid.Row="1" Margin="0,1,0,9" Click="Button_KillTSLServer_Click"/>
|
||||
<Button Content="开始游戏" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,4" HorizontalAlignment="Center" Grid.Row="2" Margin="0,23,0,103" Click="Button_Start_TslGame" Grid.RowSpan="2"/>
|
||||
<Button Content="退出程序" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,0" HorizontalAlignment="Center" Grid.Row="3" Margin="0,6,0,71" Click="Button_Exit_Click" RenderTransformOrigin="0.368,0.386"/>
|
||||
<!-- 状态文字 -->
|
||||
<TextBlock x:Name="StatusText"
|
||||
Text="未运行"
|
||||
FontSize="20"
|
||||
FontFamily="Alimama FangYuanTi VF SemiBold"
|
||||
Foreground="Red"
|
||||
Margin="140,23,-140,21"
|
||||
Grid.Column="1" Grid.RowSpan="2"/>
|
||||
<TextBlock Text="服务器状态:"
|
||||
Foreground="White"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="20"
|
||||
FontFamily="Alimama FangYuanTi VF SemiBold"
|
||||
Margin="20,23,0,21" Grid.Column="1" Grid.RowSpan="2"/>
|
||||
<Button Content="关于我们" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,0" HorizontalAlignment="Center" Grid.Row="3" Margin="0,65,0,12" Click="Button_OpenNewWindow_Click" RenderTransformOrigin="0.368,0.386"/>
|
||||
<TextBlock
|
||||
Foreground="White"
|
||||
FontSize="14"
|
||||
FontFamily="Alimama FangYuanTi VF SemiBold"
|
||||
Margin="121,123,0,0" Width="388" ScrollViewer.HorizontalScrollBarVisibility="Visible" Grid.Row="4" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top" HorizontalAlignment="Left" Height="17" Grid.RowSpan="2" Grid.Column="1">
|
||||
<TextBlock.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform AngleX="0"/>
|
||||
<RotateTransform/>
|
||||
<TranslateTransform X="0"/>
|
||||
</TransformGroup>
|
||||
</TextBlock.RenderTransform><Run Text="Copyright © 2025 "/><Run Text=" 开发者:"/><Run Text="在下王某人 "/><Run Language="zh-cn" Text="(请勿转卖!)"/></TextBlock>
|
||||
</Grid>
|
||||
</Window>
|
204
ServerLauncher/MainWindow.xaml.cs
Normal file
204
ServerLauncher/MainWindow.xaml.cs
Normal file
|
@ -0,0 +1,204 @@
|
|||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ServerLauncher
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private DispatcherTimer timer;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 初始化定时器
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = TimeSpan.FromSeconds(5); // 每 5 秒检测一次
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
// 初始检测
|
||||
CheckTslGameProcess();
|
||||
|
||||
}
|
||||
|
||||
//启动服务器进程
|
||||
private static void StartTSLServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "TslGame.exe",
|
||||
Arguments = "/Game/Maps/Erangel/Erangel_Main?listen?game=/Game/Blueprints/TSLGameMode.TSLGameMode_C -nullrhi -nosound -AllowJoinAnyMatchState -Server -port=8888 -NoVerifyGC -NoEAC -NoBattleEye",
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法启动 TslGame Server:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
//结束服务器进程
|
||||
private static void KillTSLProcess()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取所有名为 "TslGame" 的进程
|
||||
Process[] processes = Process.GetProcessesByName("TslGame");
|
||||
|
||||
if (processes.Length > 0)
|
||||
{
|
||||
foreach (var process in processes)
|
||||
{
|
||||
process.Kill(); // 强制结束进程
|
||||
process.WaitForExit(); // 等待进程完全退出
|
||||
}
|
||||
|
||||
MessageBox.Show("TslGame Server 已成功关闭!", "操作成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("TslGame Server 没有在运行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法结束 TslGame Server: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
//启动游戏进程
|
||||
private static void StartTSLGame()
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "TslGame.exe",
|
||||
Arguments = "127.0.0.1:8888 -NoVerifyGC -NoEAC -NoBattleEye",
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法启动 TslGame:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
//监测 TslGame Server 是否正在运行(自动逻辑)
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// 定时检测进程状态
|
||||
CheckTslGameProcess();
|
||||
}
|
||||
private void CheckTslGameProcess()
|
||||
{
|
||||
// 获取所有名为 "TslGame" 的进程
|
||||
Process[] processes = Process.GetProcessesByName("TslGame");
|
||||
|
||||
if (processes.Length > 0)
|
||||
{
|
||||
// 如果进程存在,更新界面为“运行”
|
||||
StatusText.Text = "运行";
|
||||
StatusText.Foreground = new SolidColorBrush(Colors.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果进程不存在,更新界面为“未运行”
|
||||
StatusText.Text = "未运行";
|
||||
StatusText.Foreground = new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
}
|
||||
|
||||
//界面上的按钮事件
|
||||
//启动 TslGame 服务器
|
||||
private async void Button_StartTSLServer_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 启动TslGame.exe
|
||||
MessageBoxResult result = MessageBox.Show(
|
||||
"你确定要这么做吗?",
|
||||
"提示",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
await Task.Delay(3000);
|
||||
StartTSLServer();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法启动 TslGame Server: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
//结束 TslGame 服务器
|
||||
private void Button_KillTSLServer_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageBoxResult result = MessageBox.Show(
|
||||
"你确定要这么做吗?",
|
||||
"提示",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
KillTSLProcess();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法结束 TslGame Server: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//启动 TslGame
|
||||
private void Button_Start_TslGame(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageBoxResult result = MessageBox.Show(
|
||||
"你确定要这么做吗?",
|
||||
"提示",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
StartTSLGame();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"无法启动 TslGame {ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
//退出应用
|
||||
private void Button_Exit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
//关于我们
|
||||
private void Button_OpenNewWindow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 创建新窗口的实例
|
||||
Window2 newWindow = new Window2();
|
||||
// 显示新窗口
|
||||
newWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
75
ServerLauncher/ServerLauncher.csproj
Normal file
75
ServerLauncher/ServerLauncher.csproj
Normal file
|
@ -0,0 +1,75 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Platforms>AnyCPU;x64;x86</Platforms>
|
||||
<UseWindowsForms>False</UseWindowsForms>
|
||||
<ApplicationIcon>MWIcon.ico</ApplicationIcon>
|
||||
<NuGetAudit>False</NuGetAudit>
|
||||
<StartupObject></StartupObject>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<Title>TslGame 服务器启动器</Title>
|
||||
<Authors>在下王某人</Authors>
|
||||
<NeutralLanguage>zh-CN</NeutralLanguage>
|
||||
<Description>服务器启动器。</Description>
|
||||
<GenerateDocumentationFile>False</GenerateDocumentationFile>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<DelaySign>False</DelaySign>
|
||||
<ErrorReport>none</ErrorReport>
|
||||
<Copyright>Copyright © 2025 在下王某人 版权所有.</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Window1.xaml.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Resource\Fonts\Alimama FYT VF.ttf" />
|
||||
<None Remove="Resource\Image\Line1.png" />
|
||||
<None Remove="Resource\Image\MWIcon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Remove="Window1.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="MWIcon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Resource\Fonts\Alimama FYT VF.ttf" />
|
||||
<Resource Include="Resource\Image\Line1.png" />
|
||||
<Resource Include="Resource\Image\TslGameServerBack1.jpg" />
|
||||
<Resource Include="Resource\Image\MWIcon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
21
ServerLauncher/Window1.xaml
Normal file
21
ServerLauncher/Window1.xaml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<Window x:Class="ServerLauncher.NewWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ServerLauncher"
|
||||
mc:Ignorable="d"
|
||||
Title="Window1" Height="450" Width="800">
|
||||
<Grid Margin="10">
|
||||
<!-- 状态显示 -->
|
||||
<TextBlock Text="服务器状态:" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="20" Margin="0,0,10,0"/>
|
||||
<TextBlock x:Name="StatusText"
|
||||
Text="未运行"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Foreground="Red"
|
||||
Margin="0,0,590,0"/>
|
||||
</Grid>
|
||||
</Window>
|
51
ServerLauncher/Window1.xaml.cs
Normal file
51
ServerLauncher/Window1.xaml.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ServerLauncher
|
||||
{
|
||||
public partial class NewWindow : Window
|
||||
{
|
||||
private DispatcherTimer timer;
|
||||
|
||||
public NewWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 初始化定时器
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = TimeSpan.FromSeconds(5); // 每 5 秒检测一次
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
// 初始检测
|
||||
CheckTslGameProcess();
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// 定时检测进程状态
|
||||
CheckTslGameProcess();
|
||||
}
|
||||
|
||||
private void CheckTslGameProcess()
|
||||
{
|
||||
// 获取所有名为 "TslGame" 的进程
|
||||
Process[] processes = Process.GetProcessesByName("TslGame");
|
||||
|
||||
if (processes.Length > 0)
|
||||
{
|
||||
// 如果进程存在,更新界面为“运行”,并设置为绿色
|
||||
StatusText.Text = "运行";
|
||||
StatusText.Foreground = new SolidColorBrush(Colors.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果进程不存在,更新界面为“未运行”,并设置为红色
|
||||
StatusText.Text = "未运行";
|
||||
StatusText.Foreground = new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue