[Build]Use XamlStyler to check XAML formatting (#28643)

* Use XamlStyler to check XAML formatting

* fix spellcheck

* fix

* format XAML FLS, Hosts, ImageResizer, MeasureTool, PowerRename

* format XAML Peek

* exclude settings XAML and make CI pass

* doc
This commit is contained in:
Davide Giacometti 2023-10-09 16:58:13 +02:00 committed by GitHub
parent b41dd81177
commit 6482e9b0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 594 additions and 411 deletions

View File

@ -7,6 +7,12 @@
"commands": [ "commands": [
"dotnet-consolidate" "dotnet-consolidate"
] ]
},
"xamlstyler.console": {
"version": "3.2206.4",
"commands": [
"xstyler"
]
} }
} }
} }

View File

@ -2083,6 +2083,7 @@ vscdb
vsconfig vsconfig
VSCROLL VSCROLL
vsetq vsetq
VSM
vsonline vsonline
vstemplate vstemplate
VSTHRD VSTHRD
@ -2229,6 +2230,8 @@ Wubi
WVC WVC
Wwan Wwan
Wwanpp Wwanpp
xamlstyler
Xavalon
XAxis XAxis
xbf xbf
Xbox Xbox
@ -2249,6 +2252,7 @@ XPels
XPixel XPixel
XResource XResource
xsi xsi
xstyler
XStr XStr
XUP XUP
XVIRTUALSCREEN XVIRTUALSCREEN

View File

@ -0,0 +1,128 @@
<#
.SYNOPSIS
Modify XAML files to adhere to XAML Styler settings.
.DESCRIPTION
The Apply XAML Stying Script can be used to check or modify XAML files with the repo's XAML Styler settings.
Learn more about XAML Styler at https://github.com/Xavalon/XamlStyler
By default, uses git status to check all new or modified files.
Use "PS> Help .\applyXamlStyling.ps1 -Full" for more details on parameters.
.PARAMETER LastCommit
Runs against last commit vs. current changes
.PARAMETER Unstaged
Runs against unstaged changed files
.PARAMETER Staged
Runs against staged files vs. current changes
.PARAMETER Main
Runs against main vs. current branch
.PARAMETER Passive
Runs a passive check against all files in the repo for the CI
.EXAMPLE
PS> .\applyXamlStyling.ps1 -Main
#>
param(
[switch]$LastCommit = $false,
[switch]$Unstaged = $false,
[switch]$Staged = $false,
[switch]$Main = $false,
[switch]$Passive = $false
)
Write-Output "Use 'Help .\applyXamlStyling.ps1' for more info or '-Main' to run against all files."
Write-Output ""
Write-Output "Restoring dotnet tools..."
dotnet tool restore
if (-not $Passive)
{
# Look for unstaged changed files by default
$gitDiffCommand = "git status -s --porcelain"
if ($Main)
{
Write-Output 'Checking Current Branch against `main` Files Only'
$branch = git status | Select-String -Pattern "On branch (?<branch>.*)$"
if ($null -eq $branch.Matches)
{
$branch = git status | Select-String -Pattern "HEAD detached at (?<branch>.*)$"
if ($null -eq $branch.Matches)
{
Write-Error 'Don''t know how to fetch branch from `git status`:'
git status | Write-Error
exit 1
}
}
$branch = $branch.Matches.groups[1].Value
$gitDiffCommand = "git diff origin/main $branch --name-only --diff-filter=ACM"
}
elseif ($Unstaged)
{
# Look for unstaged files
Write-Output "Checking Unstaged Files"
$gitDiffCommand = "git diff --name-only --diff-filter=ACM"
}
elseif ($Staged)
{
# Look for staged files
Write-Output "Checking Staged Files Only"
$gitDiffCommand = "git diff --cached --name-only --diff-filter=ACM"
}
elseif ($LastCommit)
{
# Look at last commit files
Write-Output "Checking the Last Commit's Files Only"
$gitDiffCommand = "git diff HEAD^ HEAD --name-only --diff-filter=ACM"
}
else
{
Write-Output "Checking Git Status Files Only"
}
Write-Output "Running Git Diff: $gitDiffCommand"
$files = Invoke-Expression $gitDiffCommand | Select-String -Pattern "\.xaml$"
if (-not $Passive -and -not $Main -and -not $Unstaged -and -not $Staged -and -not $LastCommit)
{
# Remove 'status' column of 3 characters at beginning of lines
$files = $files | ForEach-Object { $_.ToString().Substring(3) }
}
if ($files.count -gt 0)
{
dotnet tool run xstyler -c "$PSScriptRoot\..\Settings.XamlStyler" -f $files
}
else
{
Write-Output "No XAML Files found to style..."
}
}
else
{
Write-Output "Checking all files (passively)"
$files = Get-ChildItem -Path "$PSScriptRoot\..\src\*.xaml" -Recurse | Select-Object -ExpandProperty FullName | Where-Object { $_ -notmatch "(\\obj\\)|(\\bin\\)|(\\x64\\)|(\\launcher\\PowerLauncher\\)|(\\launcher\\Wox.Plugin\\)|(\\colorPicker\\ColorPickerUI\\)|(\\editor\\FancyZonesEditor\\)|(\\settings-ui\\Settings.UI\\)" }
if ($files.count -gt 0)
{
dotnet tool run xstyler -p -c "$PSScriptRoot\..\Settings.XamlStyler" -f $files
if ($lastExitCode -eq 1)
{
Write-Error 'XAML Styling is incorrect, please run `.\.pipelines\applyXamlStyling.ps1 -Main` locally.'
}
# Return XAML Styler Status
exit $lastExitCode
}
else
{
exit 0
}
}

View File

@ -8,7 +8,14 @@ steps:
clean: true clean: true
- task: PowerShell@2 - task: PowerShell@2
displayName: Verifying Nuget package versions for PowerToys.sln displayName: Verify XAML formatting
inputs:
filePath: '$(build.sourcesdirectory)\.pipelines\applyXamlStyling.ps1'
arguments: -Passive
pwsh: true
- task: PowerShell@2
displayName: Verify Nuget package versions for PowerToys.sln
inputs: inputs:
filePath: '$(build.sourcesdirectory)\.pipelines\verifyNugetPackages.ps1' filePath: '$(build.sourcesdirectory)\.pipelines\verifyNugetPackages.ps1'
arguments: -solution '$(build.sourcesdirectory)\PowerToys.sln' arguments: -solution '$(build.sourcesdirectory)\PowerToys.sln'
@ -240,7 +247,7 @@ steps:
dotnet list $(build.sourcesdirectory)\src\common\Common.UI\Common.UI.csproj package dotnet list $(build.sourcesdirectory)\src\common\Common.UI\Common.UI.csproj package
- task: PowerShell@2 - task: PowerShell@2
displayName: Verifying Notice.md and Nuget packages match displayName: Verify Notice.md and Nuget packages match
inputs: inputs:
filePath: '$(build.sourcesdirectory)\.pipelines\verifyNoticeMdAgainstNugetPackages.ps1' filePath: '$(build.sourcesdirectory)\.pipelines\verifyNoticeMdAgainstNugetPackages.ps1'
arguments: -path '$(build.sourcesdirectory)\' arguments: -path '$(build.sourcesdirectory)\'

42
Settings.XamlStyler Normal file
View File

@ -0,0 +1,42 @@
{
"AttributesTolerance": 2,
"KeepFirstAttributeOnSameLine": false,
"MaxAttributeCharactersPerLine": 0,
"MaxAttributesPerLine": 1,
"NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
"SeparateByGroups": false,
"AttributeIndentation": 0,
"AttributeIndentationStyle": 1,
"RemoveDesignTimeReferences": false,
"IgnoreDesignTimeReferencePrefix": false,
"EnableAttributeReordering": true,
"AttributeOrderingRuleGroups": [
"x:Class",
"xmlns, xmlns:x",
"xmlns:*",
"x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
"Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
"Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
"Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
"*:*, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
"FirstLineAttributes": "",
"OrderAttributesByName": true,
"PutEndingBracketOnNewLine": false,
"RemoveEndingTagOfEmptyElement": true,
"SpaceBeforeClosingSlash": true,
"RootElementLineBreakRule": 0,
"ReorderVSM": 2,
"ReorderGridChildren": false,
"ReorderCanvasChildren": false,
"ReorderSetters": 0,
"FormatMarkupExtension": true,
"NoNewLineMarkupExtensions": "x:Bind, Binding",
"ThicknessSeparator": 2,
"ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin",
"FormatOnSave": true,
"CommentPadding": 2,
}

View File

@ -6,6 +6,7 @@
## Formatting ## Formatting
- We use [XamlStyler](https://github.com/Xavalon/XamlStyler/) to format XAML files. You can use the [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler2022) or apply formatting executing `.\.pipelines\applyXamlStyling.ps1 -Main`.
- We use [`.clang-format`](https://github.com/microsoft/PowerToys/blob/main/src/.clang-format) style file to enable automatic code formatting. You can [easily format source files from Visual Studio](https://devblogs.microsoft.com/cppblog/clangformat-support-in-visual-studio-2017-15-7-preview-1/). For example, `CTRL+K CTRL+D` formats the current document. - We use [`.clang-format`](https://github.com/microsoft/PowerToys/blob/main/src/.clang-format) style file to enable automatic code formatting. You can [easily format source files from Visual Studio](https://devblogs.microsoft.com/cppblog/clangformat-support-in-visual-studio-2017-15-7-preview-1/). For example, `CTRL+K CTRL+D` formats the current document.
- If you prefer another text editor or have ClangFormat disabled in Visual Studio, you could invoke [`format_sources`](https://github.com/microsoft/PowerToys/blob/main/src/codeAnalysis/format_sources.ps1) powershell script from command line. It gets a list of all currently modified files from `git` and invokes clang-format on them. - If you prefer another text editor or have ClangFormat disabled in Visual Studio, you could invoke [`format_sources`](https://github.com/microsoft/PowerToys/blob/main/src/codeAnalysis/format_sources.ps1) powershell script from command line. It gets a list of all currently modified files from `git` and invokes clang-format on them.
Please note that you should also have `clang-format.exe` in `%PATH%` for it to work. The script can infer the path of `clang-format.exe` version which is shipped with Visual Studio at `%VCINSTALLDIR%\Tools\Llvm\bin\`, if you launch it from the *Native Tools Command Prompt for VS*. Please note that you should also have `clang-format.exe` in `%PATH%` for it to work. The script can infer the path of `clang-format.exe` version which is shipped with Visual Studio at `%VCINSTALLDIR%\Tools\Llvm\bin\`, if you launch it from the *Native Tools Command Prompt for VS*.

View File

@ -20,22 +20,23 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid x:Name="AppTitleBar" <Grid
x:Name="AppTitleBar"
Height="32" Height="32"
ColumnSpacing="16"> ColumnSpacing="16">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/> <ColumnDefinition x:Name="LeftPaddingColumn" Width="0" />
<ColumnDefinition x:Name="IconColumn" Width="Auto"/> <ColumnDefinition x:Name="IconColumn" Width="Auto" />
<ColumnDefinition x:Name="TitleColumn" Width="Auto"/> <ColumnDefinition x:Name="TitleColumn" Width="Auto" />
<ColumnDefinition x:Name="RightDragColumn" Width="*"/> <ColumnDefinition x:Name="RightDragColumn" Width="*" />
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/> <ColumnDefinition x:Name="RightPaddingColumn" Width="0" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image <Image
Grid.Column="1" Grid.Column="1"
Source="../Assets/FileLocksmith/Icon.ico"
VerticalAlignment="Center"
Width="16" Width="16"
Height="16"/> Height="16"
VerticalAlignment="Center"
Source="../Assets/FileLocksmith/Icon.ico" />
<TextBlock <TextBlock
x:Name="AppTitleTextBlock" x:Name="AppTitleTextBlock"
Grid.Column="2" Grid.Column="2"

View File

@ -1,4 +1,4 @@
<winuiex:WindowEx <winuiex:WindowEx
x:Class="Hosts.MainWindow" x:Class="Hosts.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -20,24 +20,27 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid x:Name="titleBar" Height="32" ColumnSpacing="16"> <Grid
x:Name="titleBar"
Height="32"
ColumnSpacing="16">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/> <ColumnDefinition x:Name="LeftPaddingColumn" Width="0" />
<ColumnDefinition x:Name="IconColumn" Width="Auto"/> <ColumnDefinition x:Name="IconColumn" Width="Auto" />
<ColumnDefinition x:Name="TitleColumn" Width="Auto"/> <ColumnDefinition x:Name="TitleColumn" Width="Auto" />
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/> <ColumnDefinition x:Name="RightPaddingColumn" Width="0" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image <Image
Grid.Column="1" Grid.Column="1"
Source="../Assets/Hosts/Hosts.ico"
VerticalAlignment="Center"
Width="16" Width="16"
Height="16"/> Height="16"
VerticalAlignment="Center"
Source="../Assets/Hosts/Hosts.ico" />
<TextBlock <TextBlock
x:Name="AppTitleTextBlock" x:Name="AppTitleTextBlock"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource CaptionTextBlockStyle}" VerticalAlignment="Center"
VerticalAlignment="Center" /> Style="{StaticResource CaptionTextBlockStyle}" />
</Grid> </Grid>
<views:MainPage Grid.Row="1" /> <views:MainPage Grid.Row="1" />

View File

@ -1,4 +1,4 @@
<Page <Page
x:Class="Hosts.Views.MainPage" x:Class="Hosts.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -169,8 +169,8 @@
GotFocus="Entries_GotFocus" GotFocus="Entries_GotFocus"
IsItemClickEnabled="True" IsItemClickEnabled="True"
ItemClick="Entries_ItemClick" ItemClick="Entries_ItemClick"
RightTapped="Entries_RightTapped"
ItemsSource="{x:Bind ViewModel.Entries, Mode=TwoWay}" ItemsSource="{x:Bind ViewModel.Entries, Mode=TwoWay}"
RightTapped="Entries_RightTapped"
SelectedItem="{x:Bind ViewModel.Selected, Mode=TwoWay}"> SelectedItem="{x:Bind ViewModel.Selected, Mode=TwoWay}">
<ListView.ContextFlyout> <ListView.ContextFlyout>
<MenuFlyout> <MenuFlyout>
@ -180,8 +180,8 @@
Icon="Edit"> Icon="Edit">
<MenuFlyoutItem.KeyboardAccelerators> <MenuFlyoutItem.KeyboardAccelerators>
<KeyboardAccelerator <KeyboardAccelerator
Modifiers="Control"
Key="E" Key="E"
Modifiers="Control"
ScopeOwner="{x:Bind Entries}" /> ScopeOwner="{x:Bind Entries}" />
</MenuFlyoutItem.KeyboardAccelerators> </MenuFlyoutItem.KeyboardAccelerators>
</MenuFlyoutItem> </MenuFlyoutItem>
@ -191,8 +191,8 @@
Icon="TwoBars"> Icon="TwoBars">
<MenuFlyoutItem.KeyboardAccelerators> <MenuFlyoutItem.KeyboardAccelerators>
<KeyboardAccelerator <KeyboardAccelerator
Modifiers="Control"
Key="P" Key="P"
Modifiers="Control"
ScopeOwner="{x:Bind Entries}" /> ScopeOwner="{x:Bind Entries}" />
</MenuFlyoutItem.KeyboardAccelerators> </MenuFlyoutItem.KeyboardAccelerators>
</MenuFlyoutItem> </MenuFlyoutItem>
@ -218,9 +218,7 @@
Click="Delete_Click" Click="Delete_Click"
Icon="Delete"> Icon="Delete">
<MenuFlyoutItem.KeyboardAccelerators> <MenuFlyoutItem.KeyboardAccelerators>
<KeyboardAccelerator <KeyboardAccelerator Key="Delete" ScopeOwner="{x:Bind Entries}" />
Key="Delete"
ScopeOwner="{x:Bind Entries}" />
</MenuFlyoutItem.KeyboardAccelerators> </MenuFlyoutItem.KeyboardAccelerators>
</MenuFlyoutItem> </MenuFlyoutItem>
</MenuFlyout> </MenuFlyout>
@ -232,11 +230,16 @@
Background="Transparent" Background="Transparent"
ColumnSpacing="8"> ColumnSpacing="8">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="256"/> <!-- Address --> <ColumnDefinition Width="256" />
<ColumnDefinition Width="*"/> <!-- Comment --> <!-- Address -->
<ColumnDefinition Width="Auto"/> <!-- Status --> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto"/> <!-- Duplicate --> <!-- Comment -->
<ColumnDefinition Width="Auto"/> <!-- ToggleSwitch --> <ColumnDefinition Width="Auto" />
<!-- Status -->
<ColumnDefinition Width="Auto" />
<!-- Duplicate -->
<ColumnDefinition Width="Auto" />
<!-- ToggleSwitch -->
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock <TextBlock
Grid.Column="0" Grid.Column="0"
@ -371,9 +374,9 @@
<InfoBar <InfoBar
x:Uid="FileSaveError" x:Uid="FileSaveError"
Margin="0,8,0,0" Margin="0,8,0,0"
Severity="Error"
Message="{x:Bind ViewModel.ErrorMessage, Mode=TwoWay}"
IsOpen="{x:Bind ViewModel.Error, Mode=TwoWay}" IsOpen="{x:Bind ViewModel.Error, Mode=TwoWay}"
Message="{x:Bind ViewModel.ErrorMessage, Mode=TwoWay}"
Severity="Error"
Visibility="{x:Bind ViewModel.Error, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}" /> Visibility="{x:Bind ViewModel.Error, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}" />
<InfoBar <InfoBar
x:Uid="FileChanged" x:Uid="FileChanged"
@ -397,8 +400,8 @@
<ContentDialog <ContentDialog
x:Name="EntryDialog" x:Name="EntryDialog"
x:Uid="EntryDialog" x:Uid="EntryDialog"
Loaded="ContentDialog_Loaded_ApplyMargin"
IsPrimaryButtonEnabled="{Binding Valid, Mode=OneWay}" IsPrimaryButtonEnabled="{Binding Valid, Mode=OneWay}"
Loaded="ContentDialog_Loaded_ApplyMargin"
PrimaryButtonStyle="{StaticResource AccentButtonStyle}"> PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
<ContentDialog.DataContext> <ContentDialog.DataContext>
<models:Entry /> <models:Entry />

View File

@ -1,10 +1,11 @@
<Application x:Class="ImageResizer.App" <Application
x:Class="ImageResizer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:ImageResizer.Models" xmlns:m="clr-namespace:ImageResizer.Models"
xmlns:sys="clr-namespace:System;assembly=System.Runtime" xmlns:sys="clr-namespace:System;assembly=System.Runtime"
xmlns:v="clr-namespace:ImageResizer.Views" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"> xmlns:v="clr-namespace:ImageResizer.Views">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@ -12,27 +13,29 @@
<ui:ControlsDictionary /> <ui:ControlsDictionary />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<ObjectDataProvider x:Key="ResizeFitValues" <ObjectDataProvider
x:Key="ResizeFitValues"
MethodName="GetValues" MethodName="GetValues"
ObjectType="sys:Enum"> ObjectType="sys:Enum">
<ObjectDataProvider.MethodParameters> <ObjectDataProvider.MethodParameters>
<x:Type Type="{x:Type m:ResizeFit}"/> <x:Type Type="{x:Type m:ResizeFit}" />
</ObjectDataProvider.MethodParameters> </ObjectDataProvider.MethodParameters>
</ObjectDataProvider> </ObjectDataProvider>
<ObjectDataProvider x:Key="ResizeUnitValues" <ObjectDataProvider
x:Key="ResizeUnitValues"
MethodName="GetValues" MethodName="GetValues"
ObjectType="sys:Enum"> ObjectType="sys:Enum">
<ObjectDataProvider.MethodParameters> <ObjectDataProvider.MethodParameters>
<x:Type Type="{x:Type m:ResizeUnit}"/> <x:Type Type="{x:Type m:ResizeUnit}" />
</ObjectDataProvider.MethodParameters> </ObjectDataProvider.MethodParameters>
</ObjectDataProvider> </ObjectDataProvider>
<v:SizeTypeToVisibilityConverter x:Key="SizeTypeToVisibilityConverter"/> <v:SizeTypeToVisibilityConverter x:Key="SizeTypeToVisibilityConverter" />
<v:EnumValueConverter x:Key="EnumValueConverter"/> <v:EnumValueConverter x:Key="EnumValueConverter" />
<v:AutoDoubleConverter x:Key="AutoDoubleConverter"/> <v:AutoDoubleConverter x:Key="AutoDoubleConverter" />
<v:BoolValueConverter x:Key="BoolValueConverter"/> <v:BoolValueConverter x:Key="BoolValueConverter" />
<v:VisibilityBoolConverter x:Key="VisibilityBoolConverter"/> <v:VisibilityBoolConverter x:Key="VisibilityBoolConverter" />
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@ -25,7 +25,10 @@
SelectedIndex="{Binding Settings.SelectedSizeIndex}"> SelectedIndex="{Binding Settings.SelectedSizeIndex}">
<ComboBox.Resources> <ComboBox.Resources>
<DataTemplate DataType="{x:Type m:ResizeSize}"> <DataTemplate DataType="{x:Type m:ResizeSize}">
<Grid Margin="2,0,0,0" VerticalAlignment="Center" AutomationProperties.Name="{Binding Name}"> <Grid
Margin="2,0,0,0"
VerticalAlignment="Center"
AutomationProperties.Name="{Binding Name}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -67,9 +70,7 @@
<DataTemplate DataType="{x:Type m:CustomSize}"> <DataTemplate DataType="{x:Type m:CustomSize}">
<Grid VerticalAlignment="Center" AutomationProperties.Name="{Binding Name}"> <Grid VerticalAlignment="Center" AutomationProperties.Name="{Binding Name}">
<TextBlock <TextBlock FontWeight="SemiBold" Text="{Binding Name}" />
FontWeight="SemiBold"
Text="{Binding Name}" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ComboBox.Resources> </ComboBox.Resources>

View File

@ -1,46 +1,39 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. --> <!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<!-- Licensed under the MIT License. See LICENSE in the project root for license information. --> <!-- Licensed under the MIT License. See LICENSE in the project root for license information. -->
<UserControl <UserControl
x:Class="Peek.FilePreviewer.Controls.ArchiveControl" x:Class="Peek.FilePreviewer.Controls.ArchiveControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Peek.FilePreviewer.Controls" xmlns:converters="using:Peek.Common.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Peek.FilePreviewer.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:Peek.FilePreviewer.Previewers.Archives.Models" xmlns:models="using:Peek.FilePreviewer.Previewers.Archives.Models"
xmlns:converters="using:Peek.Common.Converters"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<DataTemplate <DataTemplate x:Key="DirectoryTemplate" x:DataType="models:ArchiveItem">
x:Key="DirectoryTemplate"
x:DataType="models:ArchiveItem">
<TreeViewItem <TreeViewItem
AutomationProperties.Name="{x:Bind Name}" AutomationProperties.Name="{x:Bind Name}"
ItemsSource="{x:Bind Children}" IsExpanded="{x:Bind IsExpanded}"
IsExpanded="{x:Bind IsExpanded}"> ItemsSource="{x:Bind Children}">
<Grid ColumnSpacing="10"> <Grid ColumnSpacing="10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image <Image
Grid.Column="0"
Width="16" Width="16"
Height="16" Height="16"
Grid.Column="0"
Source="{x:Bind Icon}" /> Source="{x:Bind Icon}" />
<TextBlock <TextBlock Grid.Column="1" Text="{x:Bind Name}" />
Grid.Column="1"
Text="{x:Bind Name}" />
</Grid> </Grid>
</TreeViewItem> </TreeViewItem>
</DataTemplate> </DataTemplate>
<DataTemplate <DataTemplate x:Key="FileTemplate" x:DataType="models:ArchiveItem">
x:Key="FileTemplate" <TreeViewItem AutomationProperties.Name="{x:Bind Name}">
x:DataType="models:ArchiveItem">
<TreeViewItem
AutomationProperties.Name="{x:Bind Name}">
<Grid ColumnSpacing="10"> <Grid ColumnSpacing="10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
@ -48,13 +41,11 @@
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image <Image
Grid.Column="0"
Width="16" Width="16"
Height="16" Height="16"
Grid.Column="0"
Source="{x:Bind Icon}" /> Source="{x:Bind Icon}" />
<TextBlock <TextBlock Grid.Column="1" Text="{x:Bind Name}" />
Grid.Column="1"
Text="{x:Bind Name}" />
<TextBlock <TextBlock
Grid.Column="2" Grid.Column="2"
Foreground="{ThemeResource TextFillColorSecondaryBrush}" Foreground="{ThemeResource TextFillColorSecondaryBrush}"
@ -75,29 +66,25 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ScrollViewer <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto">
Grid.Row="0"
HorizontalScrollBarVisibility="Auto">
<TreeView <TreeView
x:Name="ArchivePreview" x:Name="ArchivePreview"
ItemsSource="{x:Bind Source, Mode=OneWay}" CanDragItems="False"
ItemTemplateSelector="{StaticResource ArchiveItemTemplateSelector}"
SelectionMode="None"
CanReorderItems="False" CanReorderItems="False"
CanDragItems="False" /> ItemTemplateSelector="{StaticResource ArchiveItemTemplateSelector}"
ItemsSource="{x:Bind Source, Mode=OneWay}"
SelectionMode="None" />
</ScrollViewer> </ScrollViewer>
<Border <Border
Grid.Row="1" Grid.Row="1"
MinWidth="300" MinWidth="300"
Margin="16"
HorizontalAlignment="Center"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="8" CornerRadius="8">
Margin="16" <Grid Padding="16" ColumnSpacing="16">
HorizontalAlignment="Center">
<Grid
ColumnSpacing="16"
Padding="16">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
@ -107,29 +94,29 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock <TextBlock
Grid.Column="0" Grid.Column="0"
Text="{x:Bind DirectoryCount, Mode=OneWay}"
IsTextSelectionEnabled="True"
VerticalAlignment="Center" VerticalAlignment="Center"
IsTextSelectionEnabled="True"
Text="{x:Bind DirectoryCount, Mode=OneWay}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<Border <Border
Grid.Column="1" Grid.Column="1"
BorderBrush="{ThemeResource TextFillColorPrimaryBrush}" BorderBrush="{ThemeResource TextFillColorPrimaryBrush}"
BorderThickness="0 0 1 0" /> BorderThickness="0,0,1,0" />
<TextBlock <TextBlock
Grid.Column="2" Grid.Column="2"
Text="{x:Bind FileCount, Mode=OneWay}"
IsTextSelectionEnabled="True"
VerticalAlignment="Center" VerticalAlignment="Center"
IsTextSelectionEnabled="True"
Text="{x:Bind FileCount, Mode=OneWay}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<Border <Border
Grid.Column="3" Grid.Column="3"
BorderBrush="{ThemeResource TextFillColorPrimaryBrush}" BorderBrush="{ThemeResource TextFillColorPrimaryBrush}"
BorderThickness="0 0 1 0" /> BorderThickness="0,0,1,0" />
<TextBlock <TextBlock
Grid.Column="4" Grid.Column="4"
Text="{x:Bind Size, Mode=OneWay}"
IsTextSelectionEnabled="True"
VerticalAlignment="Center" VerticalAlignment="Center"
IsTextSelectionEnabled="True"
Text="{x:Bind Size, Mode=OneWay}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</Grid> </Grid>
</Border> </Border>

View File

@ -1,22 +1,22 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. --> <!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<!-- Licensed under the MIT License. See LICENSE in the project root for license information. --> <!-- Licensed under the MIT License. See LICENSE in the project root for license information. -->
<UserControl <UserControl
x:Class="Peek.FilePreviewer.Controls.BrowserControl" x:Class="Peek.FilePreviewer.Controls.BrowserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Peek.FilePreviewer.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.UI.Xaml.Controls" xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Peek.FilePreviewer.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<controls:WebView2 <controls:WebView2
x:Name="PreviewBrowser" x:Name="PreviewBrowser"
Loaded="PreviewWV2_Loaded" Loaded="PreviewWV2_Loaded"
NavigationStarting="PreviewBrowser_NavigationStarting" NavigationCompleted="PreviewWV2_NavigationCompleted"
NavigationCompleted="PreviewWV2_NavigationCompleted" /> NavigationStarting="PreviewBrowser_NavigationStarting" />
<ContentDialog <ContentDialog
x:Name="OpenUriDialog" x:Name="OpenUriDialog"
x:Uid="OpenUriDialog" x:Uid="OpenUriDialog"

View File

@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. --> <!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. --> <!-- Licensed under the MIT License. -->
<UserControl <UserControl
@ -34,18 +34,18 @@
Text="{x:Bind Source.FileName, Mode=OneWay}" Text="{x:Bind Source.FileName, Mode=OneWay}"
TextTrimming="CharacterEllipsis"> TextTrimming="CharacterEllipsis">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
<ToolTip Content="{x:Bind Source.FileName, Mode=OneWay}"/> <ToolTip Content="{x:Bind Source.FileName, Mode=OneWay}" />
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</TextBlock> </TextBlock>
<TextBlock Text="{x:Bind FormatFileType(Source.FileType), Mode=OneWay}"> <TextBlock Text="{x:Bind FormatFileType(Source.FileType), Mode=OneWay}">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
<ToolTip Content="{x:Bind FormatFileType(Source.FileType), Mode=OneWay}"/> <ToolTip Content="{x:Bind FormatFileType(Source.FileType), Mode=OneWay}" />
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</TextBlock> </TextBlock>
<TextBlock Text="{x:Bind FormatFileSize(Source.FileSize), Mode=OneWay}"/> <TextBlock Text="{x:Bind FormatFileSize(Source.FileSize), Mode=OneWay}" />
<TextBlock Text="{x:Bind FormatFileDateModified(Source.DateModified), Mode=OneWay}"> <TextBlock Text="{x:Bind FormatFileDateModified(Source.DateModified), Mode=OneWay}">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
<ToolTip Content="{x:Bind FormatFileDateModified(Source.DateModified), Mode=OneWay}"/> <ToolTip Content="{x:Bind FormatFileDateModified(Source.DateModified), Mode=OneWay}" />
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>

View File

@ -53,11 +53,11 @@
<controls:ArchiveControl <controls:ArchiveControl
x:Name="ArchivePreview" x:Name="ArchivePreview"
LoadingState="{x:Bind ArchivePreviewer.State, Mode=OneWay}"
Source="{x:Bind ArchivePreviewer.Tree, Mode=OneWay}"
FileCount="{x:Bind ArchivePreviewer.FileCountText, Mode=OneWay}"
DirectoryCount="{x:Bind ArchivePreviewer.DirectoryCountText, Mode=OneWay}" DirectoryCount="{x:Bind ArchivePreviewer.DirectoryCountText, Mode=OneWay}"
FileCount="{x:Bind ArchivePreviewer.FileCountText, Mode=OneWay}"
LoadingState="{x:Bind ArchivePreviewer.State, Mode=OneWay}"
Size="{x:Bind ArchivePreviewer.SizeText, Mode=OneWay}" Size="{x:Bind ArchivePreviewer.SizeText, Mode=OneWay}"
Source="{x:Bind ArchivePreviewer.Tree, Mode=OneWay}"
Visibility="{x:Bind IsPreviewVisible(ArchivePreviewer, Previewer.State), Mode=OneWay}" /> Visibility="{x:Bind IsPreviewVisible(ArchivePreviewer, Previewer.State), Mode=OneWay}" />
<controls:UnsupportedFilePreview <controls:UnsupportedFilePreview

View File

@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. --> <!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. --> <!-- Licensed under the MIT License. -->
<Application <Application

View File

@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft Corporation and Contributors. --> <!-- Copyright (c) Microsoft Corporation and Contributors. -->
<!-- Licensed under the MIT License. --> <!-- Licensed under the MIT License. -->
<UserControl <UserControl
@ -7,8 +7,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Peek.UI.Views" xmlns:local="using:Peek.UI.Views"
FlowDirection="{x:Bind TitleBarFlowDirection, Mode=OneWay}"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FlowDirection="{x:Bind TitleBarFlowDirection, Mode=OneWay}"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid x:Name="TitleBarRootContainer" Height="48"> <Grid x:Name="TitleBarRootContainer" Height="48">

View File

@ -34,7 +34,6 @@
x:Name="RootGrid" x:Name="RootGrid"
Background="{ThemeResource AccentButtonBackground}" Background="{ThemeResource AccentButtonBackground}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<Grid.Resources> <Grid.Resources>
<!-- Override the style of the inner buttons so that they don't affect background/foreground/border colors --> <!-- Override the style of the inner buttons so that they don't affect background/foreground/border colors -->
<Style TargetType="Button"> <Style TargetType="Button">
@ -52,6 +51,18 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Background="Transparent"> <Grid x:Name="RootGrid" Background="Transparent">
<ContentPresenter
x:Name="ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AnimatedIcon.State="Normal"
AutomationProperties.AccessibilityView="Raw"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}" />
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates"> <VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" /> <VisualState x:Name="Normal" />
@ -75,19 +86,6 @@
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<ContentPresenter
x:Name="ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AnimatedIcon.State="Normal"
AutomationProperties.AccessibilityView="Raw"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}" />
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@ -104,6 +102,85 @@
<ColumnDefinition x:Name="SecondaryButtonColumn" Width="{ThemeResource SplitButtonSecondaryButtonSize}" /> <ColumnDefinition x:Name="SecondaryButtonColumn" Width="{ThemeResource SplitButtonSecondaryButtonSize}" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid
x:Name="PrimaryBackgroundGrid"
Grid.ColumnSpan="2"
Background="{TemplateBinding Background}" />
<Grid
x:Name="DividerBackgroundGrid"
Grid.Column="1"
Width="1"
Background="{ThemeResource AccentButtonBorderBrush}" />
<Grid
x:Name="SecondaryBackgroundGrid"
Grid.Column="2"
Background="{TemplateBinding Background}" />
<Grid
x:Name="Border"
Grid.ColumnSpan="3"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Button
x:Name="PrimaryButton"
Grid.Column="0"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0"
Command="{TemplateBinding Command}"
CommandParameter="{TemplateBinding CommandParameter}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
IsTabStop="False" />
<Button
x:Name="SecondaryButton"
Grid.Column="2"
Padding="0,0,12,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0"
Foreground="{ThemeResource AccentButtonForeground}"
IsTabStop="False">
<Button.Content>
<AnimatedIcon
Width="12"
Height="12"
HorizontalAlignment="Right"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw">
<animatedVisuals:AnimatedChevronDownSmallVisualSource />
<AnimatedIcon.FallbackIconSource>
<FontIconSource
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="8"
Glyph="&#xE96E;"
IsTextScaleFactorEnabled="False" />
</AnimatedIcon.FallbackIconSource>
</AnimatedIcon>
</Button.Content>
</Button>
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates"> <VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" /> <VisualState x:Name="Normal" />
@ -251,85 +328,6 @@
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<Grid
x:Name="PrimaryBackgroundGrid"
Grid.ColumnSpan="2"
Background="{TemplateBinding Background}" />
<Grid
x:Name="DividerBackgroundGrid"
Grid.Column="1"
Width="1"
Background="{ThemeResource AccentButtonBorderBrush}" />
<Grid
x:Name="SecondaryBackgroundGrid"
Grid.Column="2"
Background="{TemplateBinding Background}" />
<Grid
x:Name="Border"
Grid.ColumnSpan="3"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Button
x:Name="PrimaryButton"
Grid.Column="0"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0"
Command="{TemplateBinding Command}"
CommandParameter="{TemplateBinding CommandParameter}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
IsTabStop="False" />
<Button
x:Name="SecondaryButton"
Grid.Column="2"
Padding="0,0,12,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0"
Foreground="{ThemeResource AccentButtonForeground}"
IsTabStop="False">
<Button.Content>
<AnimatedIcon
Width="12"
Height="12"
HorizontalAlignment="Right"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw">
<animatedVisuals:AnimatedChevronDownSmallVisualSource />
<AnimatedIcon.FallbackIconSource>
<FontIconSource
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="8"
Glyph="&#xE96E;"
IsTextScaleFactorEnabled="False" />
</AnimatedIcon.FallbackIconSource>
</AnimatedIcon>
</Button.Content>
</Button>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@ -371,6 +369,16 @@
BorderBrush="{ThemeResource TextControlButtonBorderBrush}" BorderBrush="{ThemeResource TextControlButtonBorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{ThemeResource ControlCornerRadius}"> CornerRadius="{ThemeResource ControlCornerRadius}">
<TextBlock
x:Name="GlyphElement"
HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{ThemeResource AutoSuggestBoxIconFontSize}"
FontStyle="Normal"
Foreground="{ThemeResource TextControlButtonForeground}"
Text="&#xe894;" />
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates"> <VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" /> <VisualState x:Name="Normal" />
@ -414,16 +422,6 @@
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<TextBlock
x:Name="GlyphElement"
HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{ThemeResource AutoSuggestBoxIconFontSize}"
FontStyle="Normal"
Foreground="{ThemeResource TextControlButtonForeground}"
Text="&#xe894;" />
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@ -518,92 +516,6 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlHeaderForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Focused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderThemeThicknessFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="QueryButton" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForeground}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ButtonStates">
<VisualState x:Name="ButtonVisible">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="ButtonCollapsed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border <Border
x:Name="BorderElement" x:Name="BorderElement"
Grid.Row="1" Grid.Row="1"
@ -692,6 +604,91 @@
Content="{TemplateBinding Description}" Content="{TemplateBinding Description}"
Foreground="{ThemeResource SystemControlDescriptionTextForegroundBrush}" /> Foreground="{ThemeResource SystemControlDescriptionTextForegroundBrush}" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlHeaderForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Focused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderThemeThicknessFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundFocused}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="QueryButton" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlButtonForeground}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ButtonStates">
<VisualState x:Name="ButtonVisible">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="ButtonCollapsed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
@ -719,7 +716,6 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="AutoSuggestBox"> <ControlTemplate TargetType="AutoSuggestBox">
<Grid x:Name="LayoutRoot"> <Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -728,14 +724,6 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Orientation">
<VisualState x:Name="Landscape" />
<VisualState x:Name="Portrait" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBox <TextBox
x:Name="TextBox" x:Name="TextBox"
Width="{TemplateBinding Width}" Width="{TemplateBinding Width}"
@ -781,6 +769,13 @@
</Border> </Border>
</Popup> </Popup>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Orientation">
<VisualState x:Name="Landscape" />
<VisualState x:Name="Portrait" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>

View File

@ -17,27 +17,6 @@
<!-- Error tooltip --> <!-- Error tooltip -->
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Highlight">
<VisualState.Setters>
<Setter Target="HighlightBorder.Opacity" Value="0.1" />
<Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
<Setter Target="HighlightBorder.Background" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Error">
<VisualState.Setters>
<Setter Target="HighlightBorder.Opacity" Value="1" />
<Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
<Setter Target="HighlightBorder.Background" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
<Setter Target="ErrorIcon.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border <Border
Name="HighlightBorder" Name="HighlightBorder"
Grid.ColumnSpan="4" Grid.ColumnSpan="4"
@ -121,5 +100,26 @@
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</Border> </Border>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Highlight">
<VisualState.Setters>
<Setter Target="HighlightBorder.Opacity" Value="0.1" />
<Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
<Setter Target="HighlightBorder.Background" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Error">
<VisualState.Setters>
<Setter Target="HighlightBorder.Opacity" Value="1" />
<Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
<Setter Target="HighlightBorder.Background" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
<Setter Target="ErrorIcon.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -366,26 +366,27 @@
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
<TextBlock x:Uid="CounterCheatSheet_Title" <TextBlock
x:Uid="CounterCheatSheet_Title"
Grid.Row="2"
Margin="0,10,0,0" Margin="0,10,0,0"
FontWeight="SemiBold" Grid.Row="2" /> FontWeight="SemiBold" />
<ListView Margin="-4,12,0,0" <ListView
Grid.Row="3"
Margin="-4,12,0,0"
IsItemClickEnabled="True" IsItemClickEnabled="True"
ItemClick="DateTimeItemClick" ItemClick="DateTimeItemClick"
ItemsSource="{x:Bind CounterShortcuts}" ItemsSource="{x:Bind CounterShortcuts}"
SelectionMode="None" Grid.Row="3"> SelectionMode="None">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate <DataTemplate x:DataType="local:PatternSnippet">
x:DataType="local:PatternSnippet"> <Grid Margin="-10,0,0,0" ColumnSpacing="8">
<Grid Margin="-10,0,0,0"
ColumnSpacing="8">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition <ColumnDefinition Width="Auto" />
Width="Auto" /> <ColumnDefinition Width="*" />
<ColumnDefinition
Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Padding="8" <Border
Padding="8"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Background="{ThemeResource ButtonBackground}" Background="{ThemeResource ButtonBackground}"
BorderBrush="{ThemeResource ButtonBorderBrush}" BorderBrush="{ThemeResource ButtonBorderBrush}"
@ -396,7 +397,8 @@
Foreground="{ThemeResource ButtonForeground}" Foreground="{ThemeResource ButtonForeground}"
Text="{x:Bind Code}" /> Text="{x:Bind Code}" />
</Border> </Border>
<TextBlock Grid.Column="1" <TextBlock
Grid.Column="1"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="12" FontSize="12"
Foreground="{ThemeResource TextFillColorSecondaryBrush}" Foreground="{ThemeResource TextFillColorSecondaryBrush}"