Skip to content

Commit

Permalink
添加项目文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
StopWuyu committed Jun 17, 2023
1 parent 077cbde commit c256753
Show file tree
Hide file tree
Showing 15 changed files with 1,165 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
69 changes: 69 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<Application
x:Class="MinecraftServerDownloader.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MinecraftServerDownloader"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="ListBox">
<Setter Property="BorderThickness" Value="0,0,1,0" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="0 5"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="5"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#F0F0F0"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#D0D0D0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#E0E0E0"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#F0F0F0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>
29 changes: 29 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MinecraftServerDownloader
{
public partial class App : System.Windows.Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// 订阅 DispatcherUnhandledException 事件
Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
}

private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
// 处理异常
Exception exception = e.Exception;
// 进行异常处理逻辑,如记录异常信息、显示错误消息等

// 标记为已处理,以防止应用程序崩溃
e.Handled = true;
}
}
}
105 changes: 105 additions & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<Window
x:Class="MinecraftServerDownloader.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:local="clr-namespace:MinecraftServerDownloader"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Minecraft Server Downloader"
Width="1000"
Height="600"
Closing="Window_Closing"
FontFamily="Segoe UI Semilight"
FontSize="18"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="3.5*" />
</Grid.ColumnDefinitions>
<!-- 选择栏 -->
<Grid Grid.Column="0">
<ListBox
x:Name="projectsSel"
Padding="10"
SelectionChanged="projectsSel_SelectionChanged" />
</Grid>
<Grid Grid.Column="1">
<ListBox
x:Name="versionSel"
Padding="10"
SelectionChanged="versionSel_SelectionChanged" />
</Grid>
<Grid Grid.Column="2">
<ListBox
x:Name="buildSel"
Padding="10"
SelectionChanged="buildSel_SelectionChanged" />
</Grid>
<Grid Grid.Column="3" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="6*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>

<Grid Grid.Row="0">
<!-- 详细信息 -->
<StackPanel>
<TextBlock
x:Name="typeName"
Text="服务端类型:{0}"
Visibility="Collapsed" />
<TextBlock
x:Name="typeVersion"
Text="服务端版本:{0}"
Visibility="Collapsed" />
<TextBlock
x:Name="typeBuild"
Text="服务端构建号:{0}"
Visibility="Collapsed" />
<TextBlock
x:Name="typeHash"
MouseDown="typeHash_MouseDown"
Text="服务端SHA-256:{0}"
TextTrimming="CharacterEllipsis"
Visibility="Collapsed">
<TextBlock.ToolTip>
<ToolTip Content="点击复制" />
</TextBlock.ToolTip>
</TextBlock>
<TextBlock
x:Name="typeTime"
Text="服务端发布时间:{0}"
Visibility="Collapsed" />
<TextBlock
x:Name="typeDownload"
MouseDown="typeDownload_MouseDown"
Text="服务端下载地址:{0}"
TextTrimming="CharacterEllipsis"
Visibility="Collapsed">
<TextBlock.ToolTip>
<ToolTip Content="点击复制" />
</TextBlock.ToolTip>
</TextBlock>
</StackPanel>
</Grid>

<Grid Grid.Row="1" Margin="15">
<!-- 进度条与下载按钮 -->
<Button
x:Name="buttonDownload"
Width="100"
Click="buttonDownload_Click"
Content="下载"
FontSize="18"
IsEnabled="False" />
<ProgressBar
x:Name="ProgressDownload"
Height="25"
Visibility="Collapsed" />
</Grid>
</Grid>
</Grid>
</Window>
Loading

0 comments on commit c256753

Please sign in to comment.