diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index e70ad229d..ab05fa5a7 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -56,7 +56,10 @@ jobs: - name: Build shell: pwsh - run: .\build.ps1 + run: | + .\build.ps1 + .\build.WinUI.ps1 x64 + .\build.WinUI.ps1 arm64 - name: Upload uses: actions/upload-artifact@v3 @@ -64,6 +67,18 @@ jobs: name: ${{ env.ProjectName }} path: ${{ env.ProjectName }}\bin\${{ env.Configuration }}\${{ env.NET_TFM }}\generic\publish\ + - name: Upload WinUI x64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ProjectName }}.WinUI.x64 + path: ${{ env.ProjectName }}.WinUI\bin\x64\${{ env.Configuration }}\${{ env.NET_TFM }}\win-x64\publish\ + + - name: Upload WinUI arm64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ProjectName }}.WinUI.arm64 + path: ${{ env.ProjectName }}.WinUI\bin\arm64\${{ env.Configuration }}\${{ env.NET_TFM }}\win-arm64\publish\ + nuget: needs: [test, check_format] if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} @@ -102,6 +117,16 @@ jobs: name: ${{ env.ProjectName }} path: ${{ env.ProjectName }} + - uses: actions/download-artifact@v3 + with: + name: ${{ env.ProjectName }}.WinUI.x64 + path: ${{ env.ProjectName }}.WinUI.x64 + + - uses: actions/download-artifact@v3 + with: + name: ${{ env.ProjectName }}.WinUI.arm64 + path: ${{ env.ProjectName }}.WinUI.arm64 + - name: Get tag id: tag uses: dawidd6/action-get-tag@v1 @@ -114,6 +139,20 @@ jobs: 7z a -mx9 "$zip_path" ${{ env.ProjectName }} echo "GENERIC_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Package WinUI x64 + shell: pwsh + run: | + $zip_path = "builtfiles/$env:ProjectName-${{ steps.tag.outputs.tag }}-x64.7z" + 7z a -mx9 "$zip_path" ${{ env.ProjectName }}.WinUI.x64 + echo "X64_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Package WinUI arm64 + shell: pwsh + run: | + $zip_path = "builtfiles/$env:ProjectName-${{ steps.tag.outputs.tag }}-arm64.7z" + 7z a -mx9 "$zip_path" ${{ env.ProjectName }}.WinUI.arm64 + echo "ARM64_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Create a new GitHub release uses: ncipollo/release-action@v1 with: @@ -126,3 +165,5 @@ jobs: | Filename | SHA-256 | | :- | :- | | ${{ env.ProjectName }}-${{ steps.tag.outputs.tag }}.7z | ${{ env.GENERIC_SHA256 }} | + | ${{ env.ProjectName }}-${{ steps.tag.outputs.tag }}-x64.7z | ${{ env.X64_SHA256 }} | + | ${{ env.ProjectName }}-${{ steps.tag.outputs.tag }}-arm64.7z | ${{ env.ARM64_SHA256 }} | diff --git a/NatTypeTester.WinUI/Extensions/ContentDialogExtensions.cs b/NatTypeTester.WinUI/Extensions/ContentDialogExtensions.cs index ff852d7fb..889a140ec 100644 --- a/NatTypeTester.WinUI/Extensions/ContentDialogExtensions.cs +++ b/NatTypeTester.WinUI/Extensions/ContentDialogExtensions.cs @@ -4,13 +4,21 @@ internal static class ContentDialogExtensions { public static async ValueTask HandleExceptionWithContentDialogAsync(this Exception ex, XamlRoot root) { + ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse(); ContentDialog dialog = new(); try { dialog.XamlRoot = root; dialog.Title = nameof(NatTypeTester); - dialog.Content = ex.Message; - dialog.PrimaryButtonText = @"OK"; + + string content = resourceLoader.GetString(ex.Message); + if (string.IsNullOrEmpty(content)) + { + content = ex.Message; + } + dialog.Content = content; + + dialog.PrimaryButtonText = resourceLoader.GetString(@"OK"); await dialog.ShowAsync(); } diff --git a/NatTypeTester.WinUI/MainWindow.xaml.cs b/NatTypeTester.WinUI/MainWindow.xaml.cs index a296edc78..d499d64cb 100644 --- a/NatTypeTester.WinUI/MainWindow.xaml.cs +++ b/NatTypeTester.WinUI/MainWindow.xaml.cs @@ -9,7 +9,7 @@ public MainWindow() Title = nameof(NatTypeTester); ExtendsContentIntoTitleBar = true; - AppWindow.Resize(new SizeInt32(500, 590)); + AppWindow.Resize(new SizeInt32(500, 560)); AppWindow.SetIcon(@"Assets\icon.ico"); // CenterScreen diff --git a/NatTypeTester.WinUI/NatTypeTesterModule.cs b/NatTypeTester.WinUI/NatTypeTesterModule.cs index b8f9db0a6..5b01a5b3e 100644 --- a/NatTypeTester.WinUI/NatTypeTesterModule.cs +++ b/NatTypeTester.WinUI/NatTypeTesterModule.cs @@ -20,6 +20,7 @@ global using Volo.Abp.Autofac; global using Volo.Abp.DependencyInjection; global using Volo.Abp.Modularity; +global using Windows.ApplicationModel.Resources; global using Windows.Graphics; global using Windows.System; diff --git a/NatTypeTester.WinUI/Strings/en-US/Resources.resw b/NatTypeTester.WinUI/Strings/en-US/Resources.resw new file mode 100644 index 000000000..0117c7385 --- /dev/null +++ b/NatTypeTester.WinUI/Strings/en-US/Resources.resw @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Binding test + + + Filtering behavior + + + Local end + + + Any + + + Mapping behavior + + + Don't use Proxy + + + OK + + + Password + + + Proxy + + + Server + + + Username + + + Public end + + + NAT type + + + This protocol is obsoleted and may not be suitable for modern routers or NAT. + + + STUN Server + + + SOCKS5 + + + Test + + + Unknown proxy address + + + Wrong STUN Server! + + \ No newline at end of file diff --git a/NatTypeTester.WinUI/Strings/zh-CN/Resources.resw b/NatTypeTester.WinUI/Strings/zh-CN/Resources.resw new file mode 100644 index 000000000..788130b7c --- /dev/null +++ b/NatTypeTester.WinUI/Strings/zh-CN/Resources.resw @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 绑定测试 + + + 过滤行为 + + + 本地地址 + + + 任意地址 + + + 映射行为 + + + 不使用代理 + + + 确定 + + + 密码 + + + 代理设置 + + + 服务器 + + + 用户名 + + + 公网地址 + + + NAT 类型 + + + 该协议已过时,可能不适用于现代路由器或 NAT。 + + + STUN 服务器 + + + SOCKS5 代理 + + + 测试 + + + 代理服务器地址输入有误! + + + STUN 服务器输入有误! + + \ No newline at end of file diff --git a/NatTypeTester.WinUI/Views/MainPage.xaml b/NatTypeTester.WinUI/Views/MainPage.xaml index acad7f369..ae5fff215 100644 --- a/NatTypeTester.WinUI/Views/MainPage.xaml +++ b/NatTypeTester.WinUI/Views/MainPage.xaml @@ -9,7 +9,7 @@ mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - + - + diff --git a/NatTypeTester.WinUI/Views/MainPage.xaml.cs b/NatTypeTester.WinUI/Views/MainPage.xaml.cs index e57374c1b..a75792c4a 100644 --- a/NatTypeTester.WinUI/Views/MainPage.xaml.cs +++ b/NatTypeTester.WinUI/Views/MainPage.xaml.cs @@ -53,6 +53,7 @@ public MainPage() NavigationView.SelectedItem = NavigationView.MenuItems.OfType().First(); ViewModel.LoadStunServer(); + ServersComboBox.SelectedIndex = 0; }); } } diff --git a/NatTypeTester.WinUI/Views/RFC3489Page.xaml b/NatTypeTester.WinUI/Views/RFC3489Page.xaml index f2d62e53f..abdfbc95f 100644 --- a/NatTypeTester.WinUI/Views/RFC3489Page.xaml +++ b/NatTypeTester.WinUI/Views/RFC3489Page.xaml @@ -7,27 +7,28 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - + - - - 0.0.0.0:0 - [::]:0 - - + + -