diff --git a/.github/workflows/create_release.js b/.github/workflows/create_release.js new file mode 100644 index 0000000..5a7a9c6 --- /dev/null +++ b/.github/workflows/create_release.js @@ -0,0 +1,144 @@ +const fs = require('fs'); +const {execSync} = require('child_process'); +const github = require('@actions/github'); +const {Octokit} = require('@octokit/rest'); + +function notice(msg) { + console.log(`* ${msg}`); +} + +function retry(fn, retryCount = 0) { + return fn().catch((e) => { + if (retryCount >= 3) { + throw e; + } + console.error(e); + console.warn(`第 ${retryCount + 1} 次执行失败,正在重试……`); + return retry(fn, retryCount + 1); + }); +} + +(async () => { + const owner = github.context.repo.owner; + const repo = github.context.repo.repo; + + await Promise.all(['x64', 'x86', 'arm64'].map((arch) => { + execSync(`dotnet publish -p:Platform=${arch} -p:PublishProfile=Properties/PublishProfiles/win-${arch}.pubxml`); + notice(`${arch} 架构软件包生成完成。`); + execSync(`7z a -tzip Publish-${arch}.zip ./bin/publish/win-${arch}/*`); + execSync(`7z a -t7z Publish-${arch}.7z ./bin/publish/win-${arch}/*`); + notice(`${arch} 架构软件包压缩完成。`); + })); + + const files = [ + { + name: 'EdgePolicyManager-v${PUBLISH_VERSION}-x64.zip', + path: 'Publish-x64.zip', + contentType: 'application/zip' + }, + { + name: 'EdgePolicyManager-v${PUBLISH_VERSION}-x64.7z', + path: 'Publish-x64.7z', + contentType: 'application/7z' + }, + { + name: 'EdgePolicyManager-v${PUBLISH_VERSION}-x86.zip', + path: 'Publish-x86.zip', + contentType: 'application/zip' + }, + { + name: 'EdgePolicyManager-v${PUBLISH_VERSION}-x86.7z', + path: 'Publish-x86.7z', + contentType: 'application/7z' + }, + { + name: 'EdgePolicyManager-v${PUBLISH_VERSION}-arm64.zip', + path: 'Publish-arm64.zip', + contentType: 'application/zip' + }, + { + name: 'EdgePolicyManager-v${PUBLISH_VERSION}-arm64.7z', + path: 'Publish-arm64.7z', + contentType: 'application/7z' + } + ]; + + function handleEnv(str) { + return str.replace(/\$\{(.+?)}/g, (_, name) => { + return process.env[name]; + }); + } + + // GitHub Release + let releaseInfo; + { + const githubO = new Octokit({ + auth: process.env.GITHUB_TOKEN + }); + + const release = await githubO.repos.createRelease({ + owner, repo, + tag_name: `v${process.env.PUBLISH_VERSION}`, + name: `Release ${process.env.PUBLISH_VERSION}`, + body: `## 更新日志\n\n概述:**${process.env.COMMIT_TITLE}**\n\n
\n\n${process.env.COMMIT_BODY}\n\n
\n\n
\n\n> 发布时间:${process.env.PUBLISH_DATETIME}\n\n> 策略版本:${process.env.EDGE_POLICY_VERSION}`, + draft: false, + prerelease: false + }); + + const releaseId = release.data.id; + + for (const file of files) { + // 上传到upload_url + await githubO.repos.uploadReleaseAsset({ + release_id: releaseId, + owner, repo, + name: handleEnv(file.name), + data: fs.readFileSync(file.path) + }); + } + + releaseInfo = await githubO.repos.getRelease({ + release_id: releaseId, + owner, repo + }); + } + notice('GitHub Release 发布完成。'); + + // Gitee Release + { + const giteeO = new Octokit({ + baseUrl: 'https://gitee.com/api/v5', + auth: process.env.GITEE_TOKEN + }); + + function fileSizeString(size) { + if (size < 1024) { + return `${size} B`; + } else if (size < 1024 * 1024) { + return `${(size / 1024).toFixed(2)} KB`; + } else if (size < 1024 * 1024 * 1024) { + return `${(size / 1024 / 1024).toFixed(2)} MB`; + } else if (size < 1024 * 1024 * 1024 * 1024) { + return `${(size / 1024 / 1024 / 1024).toFixed(2)} GB`; + } else { + return `${(size / 1024 / 1024 / 1024 / 1024).toFixed(2)} TB`; + } + } + + let assetsTable = "|附件|大小|\n|---|---|\n", + assetIcon = "![asset icon](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%20width%3D%2216%22%3E%3Cpath%20d%3D%22m8.878.392%205.25%203.045c.54.314.872.89.872%201.514v6.098a1.75%201.75%200%200%201-.872%201.514l-5.25%203.045a1.75%201.75%200%200%201-1.756%200l-5.25-3.045A1.75%201.75%200%200%201%201%2011.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75%201.75%200%200%201%201.756%200ZM7.875%201.69l-4.63%202.685L8%207.133l4.755-2.758-4.63-2.685a.248.248%200%200%200-.25%200ZM2.5%205.677v5.372c0%20.09.047.171.125.216l4.625%202.683V8.432Zm6.25%208.271%204.625-2.683a.25.25%200%200%200%20.125-.216V5.677L8.75%208.432Z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E)"; + for (const asset of releaseInfo.data.assets) { + assetsTable += `|${assetIcon} [${asset.name}](${asset.browser_download_url})|${fileSizeString(asset.size)}|\n`; + } + + await retry(() => giteeO.repos.createRelease({ + owner, repo, + tag_name: `v${process.env.PUBLISH_VERSION}`, + target_commitish: process.env.CONFIG === 'debug' ? 'test' : 'master', + name: `发行版 ${process.env.PUBLISH_VERSION}`, + body: `## 更新日志\n\n概述:**${process.env.COMMIT_TITLE}**\n\n
\n\n${process.env.COMMIT_BODY}\n\n
\n\n
\n\n> 发布时间:${process.env.PUBLISH_DATETIME}\n\n> 策略版本:${process.env.EDGE_POLICY_VERSION}\n\n${assetsTable}`, + prerelease: false + })); + } + notice('Gitee Release 发布完成。'); +})(); \ No newline at end of file diff --git a/.github/workflows/edit_version.js b/.github/workflows/edit_version.js new file mode 100644 index 0000000..740c10c --- /dev/null +++ b/.github/workflows/edit_version.js @@ -0,0 +1,40 @@ +const fs = require('fs'); +const {XMLParser, XMLBuilder} = require('fast-xml-parser'); + +(async () => { + const {PUBLISH_VERSION} = process.env; + + const csprojPath = './PolicyManager.csproj'; + const csprojData = fs.readFileSync(csprojPath); + + // 解析XML + const options = { + ignoreAttributes: false, + attributeNamePrefix: '@', + suppressEmptyNode: true, + format: process.env.CONFIG === 'debug' + }; + + const parser = new XMLParser(options); + const csprojObj = parser.parse(csprojData); + + // 修改版本号 + if (csprojObj.Project?.PropertyGroup) { + const config = csprojObj.Project.PropertyGroup.find((item) => item["Version"]); + if (!config) { + console.log(JSON.stringify(csprojObj.Project.PropertyGroup)); + throw new Error('Cannot find version property.'); + } + config["Version"] = PUBLISH_VERSION; + } else { + console.log(JSON.stringify(csprojObj)); + throw new Error('Cannot find PropertyGroup.'); + } + + // 转换为XML字符串 + const builder = new XMLBuilder(options); + const xml = builder.build(csprojObj); + + // 写回.csproj文件 + fs.writeFileSync(csprojPath, xml); +})(); \ No newline at end of file diff --git a/.github/workflows/publisher.yml b/.github/workflows/publisher.yml index f63097c..e79dabd 100644 --- a/.github/workflows/publisher.yml +++ b/.github/workflows/publisher.yml @@ -8,10 +8,15 @@ on: jobs: publish: runs-on: windows-latest + strategy: + matrix: + node-version: [ 20.x ] + env: + CONFIG: Release steps: - name: 检出代码 - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: 获取发布信息 run: | @@ -30,109 +35,40 @@ jobs: } >> "$GITHUB_ENV" shell: bash - - name: 创建 Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ env.PUBLISH_VERSION }} - release_name: Release ${{ env.PUBLISH_VERSION }} - body: | - ## 更新日志 - - 概述:**${{ env.COMMIT_TITLE }}** - -
- - ${{ env.COMMIT_BODY }} - -
- -
- - > 发布时间:${{ env.PUBLISH_DATETIME }} - - > 策略版本:${{ env.EDGE_POLICY_VERSION }} - draft: false - prerelease: false - - - name: 安装 .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: 生成软件包 + - name: 修改版本号 run: | - dotnet publish -p:Platform=x64 -p:PublishProfile=Properties/PublishProfiles/win-x64.pubxml - dotnet publish -p:Platform=x86 -p:PublishProfile=Properties/PublishProfiles/win-x86.pubxml - dotnet publish -p:Platform=ARM64 -p:PublishProfile=Properties/PublishProfiles/win-arm64.pubxml + npm i fast-xml-parser + node .github/workflows/edit_version.js - - name: 压缩软件包 + - name: 克隆完整仓库 run: | - 7z a -tzip -mx=9 Publish-x64.zip ./bin/publish/win-x64/* - 7z a -t7z -mx=9 Publish-x64.7z ./bin/publish/win-x64/* - 7z a -tzip -mx=9 Publish-x86.zip ./bin/publish/win-x86/* - 7z a -t7z -mx=9 Publish-x86.7z ./bin/publish/win-x86/* - 7z a -tzip -mx=9 Publish-arm64.zip ./bin/publish/win-arm64/* - 7z a -t7z -mx=9 Publish-arm64.7z ./bin/publish/win-arm64/* + git fetch --unshallow - - name: 上传软件包(x64-zip) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x64.zip - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x64.zip - asset_content_type: application/zip - - - name: 上传软件包(x64-7z) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x64.7z - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x64.7z - asset_content_type: application/7z + - name: 优化 Gitee 连接 + run: | + echo 182.255.33.134 gitee.com >> C:\Windows\System32\drivers\etc\hosts + ipconfig /flushdns - - name: 上传软件包(x86-zip) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 同步分支到 Gitee + uses: nick-fields/retry@v3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x86.zip - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x86.zip - asset_content_type: application/zip - - - name: 上传软件包(x86-7z) - uses: actions/upload-release-asset@v1 + timeout_minutes: 5 + max_attempts: 3 + command: | + git fetch --unshallow + git push -f "https://NXY666:$env:GITEE_TOKEN@gitee.com/NXY666/EdgePolicyManager.git" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x86.7z - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x86.7z - asset_content_type: application/7z + GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} - - name: 上传软件包(arm64-zip) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 安装 .NET + uses: actions/setup-dotnet@v4 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-arm64.zip - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-arm64.zip - asset_content_type: application/zip + dotnet-version: '8.0.x' - - name: 上传软件包(arm64-7z) - uses: actions/upload-release-asset@v1 + - name: 发布软件包 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-arm64.7z - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-arm64.7z - asset_content_type: application/7z \ No newline at end of file + GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} + run: | + npm i @actions/github @octokit/rest + node .github/workflows/create_release.js diff --git a/.github/workflows/test_publisher.yml b/.github/workflows/test_publisher.yml index df0ed59..31e0769 100644 --- a/.github/workflows/test_publisher.yml +++ b/.github/workflows/test_publisher.yml @@ -8,10 +8,15 @@ on: jobs: publish: runs-on: windows-latest + strategy: + matrix: + node-version: [ 20.x ] + env: + CONFIG: Debug steps: - name: 检出代码 - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: 获取发布信息 run: | @@ -30,109 +35,40 @@ jobs: } >> "$GITHUB_ENV" shell: bash - - name: 创建 Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ env.PUBLISH_VERSION }} - release_name: Release ${{ env.PUBLISH_VERSION }} - body: | - ## 更新日志 - - 概述:**${{ env.COMMIT_TITLE }}** - -
- - ${{ env.COMMIT_BODY }} - -
- -
- - > 发布时间:${{ env.PUBLISH_DATETIME }} - - > 策略版本:${{ env.EDGE_POLICY_VERSION }} - draft: true - prerelease: false - - - name: 安装 .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '8.0.x' - - - name: 生成软件包 + - name: 修改版本号 run: | - dotnet publish -p:Platform=x64 -p:PublishProfile=Properties/PublishProfiles/win-x64.pubxml - dotnet publish -p:Platform=x86 -p:PublishProfile=Properties/PublishProfiles/win-x86.pubxml - dotnet publish -p:Platform=ARM64 -p:PublishProfile=Properties/PublishProfiles/win-arm64.pubxml + npm i fast-xml-parser + node .github/workflows/edit_version.js - - name: 压缩软件包 + - name: 克隆完整仓库 run: | - 7z a -tzip -mx=9 Publish-x64.zip ./bin/publish/win-x64/* - 7z a -t7z -mx=9 Publish-x64.7z ./bin/publish/win-x64/* - 7z a -tzip -mx=9 Publish-x86.zip ./bin/publish/win-x86/* - 7z a -t7z -mx=9 Publish-x86.7z ./bin/publish/win-x86/* - 7z a -tzip -mx=9 Publish-arm64.zip ./bin/publish/win-arm64/* - 7z a -t7z -mx=9 Publish-arm64.7z ./bin/publish/win-arm64/* + git fetch --unshallow - - name: 上传软件包(x64-zip) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x64.zip - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x64.zip - asset_content_type: application/zip - - - name: 上传软件包(x64-7z) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x64.7z - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x64.7z - asset_content_type: application/7z - - - name: 上传软件包(x86-zip) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 优化 Gitee 连接 + run: | + echo 182.255.33.134 gitee.com >> C:\Windows\System32\drivers\etc\hosts + ipconfig /flushdns + + - name: 同步分支到 Gitee + uses: nick-fields/retry@v3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x86.zip - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x86.zip - asset_content_type: application/zip - - - name: 上传软件包(x86-7z) - uses: actions/upload-release-asset@v1 + timeout_minutes: 5 + max_attempts: 3 + command: | + git fetch --unshallow + git push -f "https://NXY666:$env:GITEE_TOKEN@gitee.com/NXY666/EdgePolicyManager.git" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-x86.7z - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-x86.7z - asset_content_type: application/7z + GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} - - name: 上传软件包(arm64-zip) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 安装 .NET + uses: actions/setup-dotnet@v4 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-arm64.zip - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-arm64.zip - asset_content_type: application/zip - - - name: 上传软件包(arm64-7z) - uses: actions/upload-release-asset@v1 + dotnet-version: '8.0.x' + + - name: 发布软件包 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./Publish-arm64.7z - asset_name: EdgePolicyManager-Release-${{ env.PUBLISH_VERSION }}-arm64.7z - asset_content_type: application/7z \ No newline at end of file + GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} + run: | + npm i @actions/github @octokit/rest + node .github/workflows/create_release.js diff --git a/App.xaml b/App.xaml index 9091f22..2f2b78e 100644 --- a/App.xaml +++ b/App.xaml @@ -5,8 +5,8 @@ x:Class="PolicyManager.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:converters="using:PolicyManager.Utils.Converters" xmlns:controls="using:Microsoft.UI.Xaml.Controls" + xmlns:uiConverters="using:CommunityToolkit.WinUI.UI.Converters" RequestedTheme="Light"> @@ -101,8 +101,9 @@ - - + + + \ No newline at end of file diff --git a/MainPage.xaml b/MainPage.xaml index 924ac61..1d793b2 100644 --- a/MainPage.xaml +++ b/MainPage.xaml @@ -8,7 +8,6 @@ Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" DataContext="{x:Bind _dataContext}"> diff --git a/MainWindow.xaml b/MainWindow.xaml index 79fd36d..e242d67 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -1,8 +1,10 @@ - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:winUiEx="using:WinUIEx" + MinWidth="545" MinHeight="510"> - \ No newline at end of file + \ No newline at end of file diff --git a/Pages/Policy/Contents/BooleanContent.xaml b/Pages/Policy/Contents/BooleanContent.xaml index eb22957..1cc9172 100644 --- a/Pages/Policy/Contents/BooleanContent.xaml +++ b/Pages/Policy/Contents/BooleanContent.xaml @@ -9,9 +9,9 @@ + Visibility="{Binding Path=PolicyManager.PolicyValueExists, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=True}" /> \ No newline at end of file diff --git a/Pages/Policy/Contents/DropdownContent.xaml b/Pages/Policy/Contents/DropdownContent.xaml index 48fca34..64373f5 100644 --- a/Pages/Policy/Contents/DropdownContent.xaml +++ b/Pages/Policy/Contents/DropdownContent.xaml @@ -8,9 +8,9 @@ DataContext="{x:Bind This}"> + SelectionChanged="ComboBox_OnSelectionChanged" MaxWidth="300" + Visibility="{Binding Path=PolicyManager.PolicyValueExists, Converter={StaticResource BoolToVisibilityConverter}}" /> + Visibility="{Binding Path=PolicyManager.PolicyValueExists, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=True}" /> \ No newline at end of file diff --git a/Pages/Policy/Contents/IntegerContent.xaml b/Pages/Policy/Contents/IntegerContent.xaml index 77c7a94..cc0f83d 100644 --- a/Pages/Policy/Contents/IntegerContent.xaml +++ b/Pages/Policy/Contents/IntegerContent.xaml @@ -8,10 +8,16 @@ DataContext="{x:Bind This}"> + Maximum="2147483647" Minimum="-2147483648" Width="120" MaxWidth="300" + GotFocus="NumberBox_OnGotFocus" LostFocus="NumberBox_OnLostFocus" /> + + + + + + Visibility="{Binding Path=PolicyManager.PolicyValueExists, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=True}" /> \ No newline at end of file diff --git a/Pages/Policy/Contents/IntegerContent.xaml.cs b/Pages/Policy/Contents/IntegerContent.xaml.cs index c1063e0..2957bcf 100644 --- a/Pages/Policy/Contents/IntegerContent.xaml.cs +++ b/Pages/Policy/Contents/IntegerContent.xaml.cs @@ -1,3 +1,4 @@ +using Microsoft.UI.Xaml; using PolicyManager.Utils; namespace PolicyManager.Pages.Policy.Contents; @@ -8,4 +9,14 @@ public IntegerContent(NotifyPolicyManager policyManager) : base(policyManager) { InitializeComponent(); } + + private void NumberBox_OnGotFocus(object sender, RoutedEventArgs e) + { + AcceptButton.Visibility = Visibility.Visible; + } + + private void NumberBox_OnLostFocus(object sender, RoutedEventArgs e) + { + AcceptButton.Visibility = Visibility.Collapsed; + } } \ No newline at end of file diff --git a/Pages/Policy/Contents/StringContent.xaml b/Pages/Policy/Contents/StringContent.xaml index ea50af8..b8ac362 100644 --- a/Pages/Policy/Contents/StringContent.xaml +++ b/Pages/Policy/Contents/StringContent.xaml @@ -8,9 +8,15 @@ DataContext="{x:Bind This}"> + Visibility="{Binding Path=PolicyManager.PolicyValueExists, Converter={StaticResource BoolToVisibilityConverter}}" + Text="{Binding Path=PolicyManager.PolicyValue, Mode=TwoWay}" MaxLength="100000" MaxWidth="300" + GotFocus="TextBox_OnGotFocus" LostFocus="TextBox_OnLostFocus" /> + + + + + + Visibility="{Binding Path=PolicyManager.PolicyValueExists, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=True}" /> \ No newline at end of file diff --git a/Pages/Policy/Contents/StringContent.xaml.cs b/Pages/Policy/Contents/StringContent.xaml.cs index 241be88..f95de7d 100644 --- a/Pages/Policy/Contents/StringContent.xaml.cs +++ b/Pages/Policy/Contents/StringContent.xaml.cs @@ -1,3 +1,4 @@ +using Microsoft.UI.Xaml; using PolicyManager.Utils; namespace PolicyManager.Pages.Policy.Contents; @@ -8,4 +9,14 @@ public StringContent(NotifyPolicyManager policyManager) : base(policyManager) { InitializeComponent(); } + + private void TextBox_OnGotFocus(object sender, RoutedEventArgs e) + { + AcceptButton.Visibility = Visibility.Visible; + } + + private void TextBox_OnLostFocus(object sender, RoutedEventArgs e) + { + AcceptButton.Visibility = Visibility.Collapsed; + } } \ No newline at end of file diff --git a/Pages/Policy/DetailPage.xaml b/Pages/Policy/DetailPage.xaml index aad1ff9..b4054d5 100644 --- a/Pages/Policy/DetailPage.xaml +++ b/Pages/Policy/DetailPage.xaml @@ -5,7 +5,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:CommunityToolkit.WinUI.Controls" - xmlns:controls1="using:CommunityToolkit.WinUI.UI.Controls" + xmlns:uiControls="using:CommunityToolkit.WinUI.UI.Controls" DataContext="{x:Bind _dataContext}"> @@ -27,12 +27,30 @@ - + Style="{ThemeResource BodyStrongTextBlockStyle}" + TextTrimming="CharacterEllipsis"> + + + + + + + + + + + + + - + + + + - + @@ -72,8 +90,8 @@ - + Visibility="{Binding Path=IsExpanderListItemsEmpty, Converter={StaticResource BoolToVisibilityConverter}}"> + \ No newline at end of file diff --git a/Pages/Policy/DetailPage.xaml.cs b/Pages/Policy/DetailPage.xaml.cs index b7691e7..27592fa 100644 --- a/Pages/Policy/DetailPage.xaml.cs +++ b/Pages/Policy/DetailPage.xaml.cs @@ -5,6 +5,7 @@ using Windows.ApplicationModel.DataTransfer; using Windows.System; using CommunityToolkit.WinUI.UI.Controls; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Navigation; using PolicyManager.Models.Policy; @@ -182,7 +183,29 @@ private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArg protected override void OnNavigatedFrom(NavigationEventArgs e) { base.OnNavigatedFrom(e); - + _dataContext.Dispose(); } + + private void CopyItemTitle_Click(object sender, RoutedEventArgs e) + { + var menuFlyoutItem = sender as MenuFlyoutItem; + + var itemData = menuFlyoutItem?.DataContext as ExpanderListItem; + + var dataPackage = new DataPackage(); + dataPackage.SetText(itemData?.PolicyDetail.Name); + Clipboard.SetContent(dataPackage); + } + + private void CopyItemShortDescription_Click(object sender, RoutedEventArgs e) + { + var menuFlyoutItem = sender as MenuFlyoutItem; + + var itemData = menuFlyoutItem?.DataContext as ExpanderListItem; + + var dataPackage = new DataPackage(); + dataPackage.SetText(itemData?.PolicyDetail.ShortDescription); + Clipboard.SetContent(dataPackage); + } } \ No newline at end of file diff --git a/Pages/Policy/SettingsPage.xaml b/Pages/Policy/SettingsPage.xaml index 16e5a87..d27ccc1 100644 --- a/Pages/Policy/SettingsPage.xaml +++ b/Pages/Policy/SettingsPage.xaml @@ -5,6 +5,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:CommunityToolkit.WinUI.Controls" + xmlns:winUi="using:CommunityToolkit.WinUI" DataContext="{x:Bind _dataContext}"> @@ -28,6 +29,15 @@ - - - + + + + + - - + + + - - +