[RegistryPreview] Extended preview for value data (#37689)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Add a button to the data grid that shows a windows for complex value
preview.

### Screenshots
**Button**

![image](https://github.com/user-attachments/assets/bb275831-be6d-490c-9193-5df719ce6c39)

**Context menu** (Usefull on long data, if button is scrolled out of
view.)

![image](https://github.com/user-attachments/assets/f5fb07ef-6f73-4eac-a289-9dce1c610ceb)

**Preview: REG_SZ**

![image](https://github.com/user-attachments/assets/e03fbbc7-adaa-40d0-967c-7783b1a97b74)

**Preview: REG_MULTI_SZ**

![image](https://github.com/user-attachments/assets/717590a6-7d91-4c9c-8e94-d875a5d2ba6b)

**Preview: REG_EXPAND_SZ**

![image](https://github.com/user-attachments/assets/20135b66-528f-40e7-beed-adfc2b50313d)

**Preview: REG_DWORD and REG_QWORD**

![image](https://github.com/user-attachments/assets/b60110ab-bfc7-40e7-ada3-d278a62b9d01)

**Preview: REG_BINARY**

![image](https://github.com/user-attachments/assets/95f81036-6833-439e-8c01-b3a45c2d8edd)

![image](https://github.com/user-attachments/assets/ce237664-da96-4dbd-835f-969982560b9f)


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] **Closes:** #36877
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized =>
missing yet
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

Additionally this PR updates the context menu for values.

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

Tested code with a local build.
This commit is contained in:
Heiko
2025-06-13 12:08:01 +02:00
committed by GitHub
parent ce058f1dc7
commit abc5c3e249
34 changed files with 4789 additions and 22 deletions

View File

@@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using CommunityToolkit.WinUI.UI.Controls;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
@@ -415,5 +414,48 @@ namespace RegistryPreviewUILib
saveButton.IsEnabled = true;
});
}
// Commands to show data preview
public void ButtonExtendedPreview_Click(object sender, RoutedEventArgs e)
{
var data = ((Button)sender).DataContext as RegistryValue;
InvokeExtendedDataPreview(data);
}
public void MenuExtendedPreview_Click(object sender, RoutedEventArgs e)
{
var data = ((MenuFlyoutItem)sender).DataContext as RegistryValue;
InvokeExtendedDataPreview(data);
}
private async void InvokeExtendedDataPreview(RegistryValue valueData)
{
// Only one content dialog can be open at the same time and multiple instances of data preview can crash the app.
if (_dialogSemaphore.CurrentCount == 0)
{
return;
}
try
{
// Lock ui and request dialog lock
_dialogSemaphore.Wait();
ChangeCursor(gridPreview, true);
await ShowExtendedDataPreview(valueData.Name, valueData.Type, valueData.Value);
}
catch
{
#if DEBUG
throw;
#endif
}
finally
{
// Unblock ui and release dialog lock
ChangeCursor(gridPreview, false);
_dialogSemaphore.Release();
}
}
}
}