Registry Preview UI (#27266)

* Registry Preview

* CommandBar

* titlebar and font size

* titlebar text foreground

* apply feedback

* apply feedback

* fix spacing
This commit is contained in:
Jay
2023-07-19 07:47:34 +02:00
committed by GitHub
parent 9ceb71a550
commit 4647491c68
3 changed files with 137 additions and 158 deletions

View File

@@ -7,173 +7,154 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:winuiex="using:WinUIEx"
Closed="Window_Closed"
MinWidth="480"
MinHeight="320"
mc:Ignorable="d">
<Window.SystemBackdrop>
<MicaBackdrop />
</Window.SystemBackdrop>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
x:Name="titleBar"
x:Name="titleBar"
Grid.Row="0"
Height="32"
ColumnSpacing="16"
Margin="16,0"
IsHitTestVisible="True">
<StackPanel
Margin="8,8,8,8"
VerticalAlignment="Bottom"
Orientation="Horizontal">
<Image Source="app.ico"/>
<TextBlock
x:Name="titleBarText"
Margin="8,0,0,0"
FontSize="12"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding ApplicationTitle}" />
</StackPanel>
<Grid.ColumnDefinitions>
<!--<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>-->
<ColumnDefinition x:Name="IconColumn" Width="Auto"/>
<ColumnDefinition x:Name="TitleColumn" Width="Auto"/>
<!--<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>-->
</Grid.ColumnDefinitions>
<Image
Source="app.ico"
Grid.Column="0"
VerticalAlignment="Center"
Width="16"
Height="16"/>
<TextBlock
x:Name="titleBarText"
Grid.Column="1"
VerticalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding ApplicationTitle}" />
</Grid>
<Grid
Grid.Row="1"
x:Name="gridPreview"
Grid.Row="1"
Width="Auto"
Height="Auto"
x:FieldModifier="public"
Loaded="GridPreview_Loaded"
TabFocusNavigation="Cycle">
TabFocusNavigation="Cycle"
Margin="12">
<Grid.Resources>
<Style x:Key="GridCardStyle" TargetType="Grid">
<Style x:Key="GridCardStyle" TargetType="Border">
<Style.Setters>
<Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
<Setter Property="CornerRadius" Value="{StaticResource OverlayCornerRadius}"/>
</Style.Setters>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<!-- Left, Splitter, Right -->
<ColumnDefinition Width="*" />
<ColumnDefinition Width="6" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!-- CommandBar, Tree, Splitter, List, StackPanel -->
<!-- CommandBar, Tree, Splitter, List -->
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="6" />
<RowDefinition Height="8" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
<Border Style="{StaticResource GridCardStyle}"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="8,0,8,8"
CornerRadius="{StaticResource OverlayCornerRadius}"
Style="{StaticResource GridCardStyle}">
Margin="0,0,0,12">
<CommandBar
Name="commandBar"
HorizontalAlignment="Left"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="Transparent"
BorderThickness="0"
DefaultLabelPosition="Right"
IsOpen="True"
IsTabStop="False">
DefaultLabelPosition="Right">
<AppBarButton
x:Name="openButton"
x:Uid="OpenButton"
HorizontalAlignment="Left"
Click="OpenButton_Click"
IsTabStop="False">
x:Name="openButton"
x:Uid="OpenButton"
Click="OpenButton_Click">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe8e5;"/>
<FontIcon Glyph="&#xe8e5;"/>
</AppBarButton.Icon>
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="O" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarSeparator />
<AppBarButton
x:Name="saveButton"
x:Uid="SaveButton"
HorizontalAlignment="Left"
Click="SaveButton_Click"
IsEnabled="False"
IsTabStop="False">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe74e;"/>
</AppBarButton.Icon>
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="S" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarButton
x:Name="saveAsButton"
x:Uid="SaveAsButton"
HorizontalAlignment="Left"
Click="SaveAsButton_Click"
IsEnabled="True"
IsTabStop="False">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe792;"/>
</AppBarButton.Icon>
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="S" Modifiers="Control,Shift" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarButton
x:Name="editButton"
x:Uid="EditButton"
HorizontalAlignment="Left"
Click="EditButton_Click"
IsTabStop="False">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe8a7;"/>
</AppBarButton.Icon>
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="E" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarButton
x:Name="refreshButton"
x:Uid="RefreshButton"
HorizontalAlignment="Left"
Click="RefreshButton_Click"
IsTabStop="False">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe72c;"/>
</AppBarButton.Icon>
x:Name="refreshButton"
x:Uid="RefreshButton"
Icon="Refresh"
Click="RefreshButton_Click">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="F5" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarSeparator />
<AppBarButton
x:Name="writeButton"
x:Uid="WriteButton"
HorizontalAlignment="Left"
Click="WriteButton_Click"
IsTabStop="False">
x:Name="saveButton"
x:Uid="SaveButton"
Icon="Save"
Click="SaveButton_Click"
IsEnabled="False">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="S" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarButton
x:Name="saveAsButton"
x:Uid="SaveAsButton"
Click="SaveAsButton_Click"
IsEnabled="True">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe72d;"/>
<FontIcon Glyph="&#xe792;"/>
</AppBarButton.Icon>
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="W" Modifiers="Control" />
<KeyboardAccelerator Key="S" Modifiers="Control,Shift" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarSeparator />
<AppBarButton
x:Name="editButton"
x:Uid="EditButton"
Icon="Edit"
Click="EditButton_Click">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="E" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarButton
x:Name="writeButton"
x:Uid="WriteButton"
Click="WriteButton_Click">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="W" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
<AppBarButton
x:Name="registryButton"
x:Uid="RegistryButton"
HorizontalAlignment="Left"
Click="RegistryButton_Click"
IsTabStop="False">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe8ad;"/>
</AppBarButton.Icon>
Click="RegistryButton_Click">
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="R" Modifiers="Control" />
</AppBarButton.KeyboardAccelerators>
@@ -181,26 +162,21 @@
<AppBarButton
x:Name="registryJumpToKeyButton"
x:Uid="RegistryJumpToKeyButton"
HorizontalAlignment="Left"
Click="RegistryJumpToKeyButton_Click"
IsTabStop="False"
IsEnabled="True">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe78b;"/>
</AppBarButton.Icon>
<AppBarButton.KeyboardAccelerators>
<KeyboardAccelerator Key="R" Modifiers="Control,Shift" />
</AppBarButton.KeyboardAccelerators>
</AppBarButton>
</CommandBar>
</Grid>
</Border>
<TextBox
x:Name="textBox"
x:Uid="textBox"
Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="0"
Margin="8,0,0,8"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AcceptsReturn="True"
@@ -219,18 +195,13 @@
CornerRadius="{StaticResource OverlayCornerRadius}"
/>
<Grid
Grid.Row="1"
<Border Style="{StaticResource GridCardStyle}"
Grid.Column="2"
Margin="0,0,8,0"
CornerRadius="{StaticResource OverlayCornerRadius}"
Style="{StaticResource GridCardStyle}">
Grid.Row="1">
<TreeView
x:Name="treeView"
Padding="0,0,0,0"
AllowDrop="False"
AllowFocusOnInteraction="True"
Background="Transparent"
CanDragItems="False"
CanReorderItems="False"
IsEnabled="True"
@@ -245,36 +216,31 @@
<TreeView.ItemTemplate>
<DataTemplate>
<StackPanel
Padding="0,0,0,0"
VerticalAlignment="Center"
IsTabStop="False"
Orientation="Horizontal">
Orientation="Horizontal"
Spacing="8">
<Image
MaxWidth="16"
MaxHeight="16"
Source="{Binding Path=Content.Image}"
ToolTipService.ToolTip="{Binding Path=Content.ToolTipText}" />
<TextBlock Padding="5,0,0,0" Text="{Binding Path=Content.Name}" />
<TextBlock Text="{Binding Path=Content.Name}" />
</StackPanel>
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
<Grid
</Border>
<Border Style="{StaticResource GridCardStyle}"
Grid.Row="3"
Grid.RowSpan="2"
Grid.Column="2"
Margin="0,0,8,8"
CornerRadius="{StaticResource OverlayCornerRadius}"
Style="{StaticResource GridCardStyle}">
Grid.Column="2">
<controls:DataGrid
x:Name="dataGrid"
AllowDrop="False"
AreRowDetailsFrozen="True"
AutoGenerateColumns="False"
Background="Transparent"
CanDrag="False"
CornerRadius="{StaticResource OverlayCornerRadius}"
HeadersVisibility="Column"
IsReadOnly="True"
IsTabStop="true"
@@ -289,12 +255,8 @@
IsReadOnly="True">
<controls:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Padding="10,0,0,0"
FontSize="14"
IsTabStop="False"
Text=" " />
<StackPanel VerticalAlignment="Center" Orientation="Horizontal"
Margin="4" Spacing="8">
<Image
MaxWidth="16"
MaxHeight="16"
@@ -302,10 +264,9 @@
Source="{Binding ImageUri}"
ToolTipService.ToolTip="{Binding ToolTipText}" />
<TextBlock
Padding="5,0,10,0"
FontSize="14"
IsTabStop="False"
Text="{Binding Name}" />
Text="{Binding Name}"
Style="{StaticResource CaptionTextBlockStyle}"/>
</StackPanel>
</DataTemplate>
</controls:DataGridTemplateColumn.CellTemplate>
@@ -314,20 +275,22 @@
x:Uid="TypeColumn"
Width="Auto"
Binding="{Binding Type}"
FontSize="14" />
FontSize="{StaticResource CaptionTextBlockFontSize}" />
<controls:DataGridTextColumn
x:Uid="ValueColumn"
Width="Auto"
Binding="{Binding Value}"
FontSize="14" />
FontSize="{StaticResource CaptionTextBlockFontSize}" />
</controls:DataGrid.Columns>
</controls:DataGrid>
</Grid>
</Border>
<controls:GridSplitter
x:Name="verticalSplitter"
Grid.Row="1"
Grid.RowSpan="4"
Grid.RowSpan="3"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Background="Transparent"
CursorBehavior="ChangeOnSplitterHover"
@@ -338,8 +301,8 @@
Grid.Row="2"
Grid.Column="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Background="Transparent"
CornerRadius="4"
CursorBehavior="ChangeOnSplitterHover"
GripperCursor="SizeNorthSouth"
IsTabStop="False" />

View File

@@ -6,7 +6,9 @@ using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Windows.ApplicationModel.Resources;
using Windows.Data.Json;
using Windows.Graphics;
@@ -51,6 +53,7 @@ namespace RegistryPreview
appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
appWindow.SetIcon("app.ico");
appWindow.Closing += AppWindow_Closing;
Activated += MainWindow_Activated;
// Extend the canvas to include the title bar so the app can support theming
ExtendsContentIntoTitleBar = true;
@@ -95,5 +98,19 @@ namespace RegistryPreview
UpdateWindowTitle(resourceLoader.GetString("FileNotFound"));
}
}
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
{
if (args.WindowActivationState == WindowActivationState.Deactivated)
{
titleBarText.Foreground =
(SolidColorBrush)App.Current.Resources["WindowCaptionForegroundDisabled"];
}
else
{
titleBarText.Foreground =
(SolidColorBrush)App.Current.Resources["WindowCaptionForeground"];
}
}
}
}

View File

@@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="EditButton.Label" xml:space="preserve">
<value>Edit file...</value>
<value>Edit</value>
</data>
<data name="ErrorDialogTitle" xml:space="preserve">
<value>Error</value>
@@ -127,7 +127,7 @@
<value>The REG file editor could not be opened.</value>
</data>
<data name="FileNotFound" xml:space="preserve">
<value>File was not found!</value>
<value>File was not found</value>
</data>
<data name="FileSaveError" xml:space="preserve">
<value>The REG file cannot be written to.</value>
@@ -142,16 +142,16 @@
<value>(Invalid QWORD (64-bit) value)</value>
</data>
<data name="InvalidRegistryFile" xml:space="preserve">
<value> doesn't appear to be a valid registry file!</value>
<value> appears to be an invalid registry file.</value>
</data>
<data name="InvalidRegistryFileTitle" xml:space="preserve">
<value>File was not a Registry file!</value>
<value>File was not a Registry file</value>
</data>
<data name="LargeRegistryFile" xml:space="preserve">
<value> is larger than 10MB which is too large for this application.</value>
</data>
<data name="LargeRegistryFileTitle" xml:space="preserve">
<value>File is too large!</value>
<value>File is too large</value>
</data>
<data name="NameColumn.Header" xml:space="preserve">
<value>Name</value>
@@ -161,36 +161,34 @@
</data>
<data name="OkButtonText" xml:space="preserve">
<value>OK</value>
<comment>as on the OK button</comment>
</data>
<data name="OpenButton.Label" xml:space="preserve">
<value>Open file...</value>
<value>Open</value>
</data>
<data name="OpenDialogTitle" xml:space="preserve">
<value>Open Registry file...</value>
<value>Open Registry file</value>
</data>
<data name="RefreshButton.Label" xml:space="preserve">
<value>Reload from file</value>
<value>Reload</value>
</data>
<data name="RegistryButton.Label" xml:space="preserve">
<value>Open Registry Editor...</value>
<value>Open Registry Editor</value>
</data>
<data name="RegistryJumpToKeyButton.Label" xml:space="preserve">
<value>Open Key...</value>
<value>Open Key</value>
</data>
<data name="SaveAsButton.Label" xml:space="preserve">
<value>Save file as...</value>
<value>Save as…</value>
</data>
<data name="SaveButton.Label" xml:space="preserve">
<value>Save file</value>
</data>
<data name="SaveButtonText" xml:space="preserve">
<value>Save</value>
</data>
<data name="SuggestFileName" xml:space="preserve">
<value>New Registry File</value>
<value>New Registry file</value>
</data>
<data name="textBox.PlaceholderText" xml:space="preserve">
<value>Registry file text will appear here...</value>
<value>Registry file text will appear here</value>
</data>
<data name="titleBarText.ApplicationTitle" xml:space="preserve">
<value>Registry Preview</value>
@@ -218,9 +216,10 @@
</data>
<data name="TypeColumn.Header" xml:space="preserve">
<value>Type</value>
<comment>noun, as in "a type of..."</comment>
</data>
<data name="UACDialogError" xml:space="preserve">
<value>You must click Yes on the previous popup if you want to run the Registry application.</value>
<value>Click Yes on the User Account Control dialog to run the application.</value>
</data>
<data name="UACDialogTitle" xml:space="preserve">
<value>User Account Control</value>
@@ -229,13 +228,13 @@
<value>Value</value>
</data>
<data name="WriteButton.Label" xml:space="preserve">
<value>Write to Registry...</value>
<value>Write to Registry</value>
</data>
<data name="YesNoCancelDialogCloseButtonText" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="YesNoCancelDialogContent" xml:space="preserve">
<value>Changes were made to the text file. Do you want to save your changes?</value>
<value>Save changes?</value>
</data>
<data name="YesNoCancelDialogPrimaryButtonText" xml:space="preserve">
<value>Save</value>