PowerToys/src/core/Microsoft.PowerToys.Settings.UI/Views/KeyboardManagerPage.xaml

337 lines
16 KiB
Plaintext
Raw Normal View History

<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.KeyboardManagerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModel="using:Microsoft.PowerToys.Settings.UI.ViewModels"
xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions"
xmlns:CustomControls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:Lib="using:Microsoft.PowerToys.Settings.UI.Lib"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<viewModel:KeyboardManagerViewModel x:Key="eventViewModel"/>
<local:VisibleIfNotEmpty x:Key="visibleIfNotEmptyConverter" />
<DataTemplate x:Name="KeysListViewTemplate" x:DataType="Lib:KeysDataModel">
<StackPanel
Orientation="Horizontal"
Height="56">
<ItemsControl
ItemsSource="{x:Bind GetOriginalKeys()}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Background="{ThemeResource SystemBaseLowColor}"
CornerRadius="4"
Padding="14,0,14,0"
Margin="5,0,5,0"
Height="36"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<TextBlock
FontWeight="SemiBold"
VerticalAlignment="Center"
TextAlignment="Center"
FontSize="12"
Text="{Binding}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<FontIcon Glyph="&#xE72A;"
Grid.Column="1"
FontSize="14"
VerticalAlignment="Center"
Margin="5,0,5,0"/>
<ItemsControl
ItemsSource="{x:Bind GetNewRemapKeys()}"
Grid.Column="2">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Background="{ThemeResource SystemAccentColor}"
CornerRadius="4"
Padding="14,0,14,0"
Margin="5,0,5,0"
Height="36"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<TextBlock
FontWeight="SemiBold"
VerticalAlignment="Center"
TextAlignment="Center"
Foreground="White"
FontSize="12"
Text="{Binding}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="ShortcutKeysListViewTemplate" x:DataType="Lib:AppSpecificKeysDataModel">
<StackPanel
Orientation="Horizontal"
Height="56">
<ItemsControl
ItemsSource="{x:Bind GetOriginalKeys()}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Background="{ThemeResource SystemBaseLowColor}"
CornerRadius="4"
Padding="14,0,14,0"
Margin="5,0,5,0"
Height="36"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<TextBlock
FontWeight="SemiBold"
VerticalAlignment="Center"
TextAlignment="Center"
FontSize="12"
Text="{Binding}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<FontIcon Glyph="&#xE72A;"
Grid.Column="1"
FontSize="14"
VerticalAlignment="Center"
Margin="5,0,5,0"/>
<ItemsControl
ItemsSource="{x:Bind GetNewRemapKeys()}"
Grid.Column="2">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Background="{ThemeResource SystemAccentColor}"
CornerRadius="4"
Padding="14,0,14,0"
Margin="5,0,5,0"
Height="36"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<TextBlock
FontWeight="SemiBold"
VerticalAlignment="Center"
TextAlignment="Center"
Foreground="White"
FontSize="12"
Text="{Binding}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<FontIcon Glyph="&#xE72A;"
Grid.Column="3"
FontSize="14"
VerticalAlignment="Center"
Margin="5,0,5,0"/>
<Border
Background="{ThemeResource SystemAccentColor}"
Grid.Column="4"
CornerRadius="4"
Padding="14,0,14,0"
Margin="5,0,5,0"
Height="36"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<TextBlock
FontWeight="SemiBold"
VerticalAlignment="Center"
TextAlignment="Center"
Foreground="White"
FontSize="12"
Text="{x:Bind TargetApp}" />
</Border>
</StackPanel>
</DataTemplate>
</Page.Resources>
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource WideLayoutMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SidePanel.(Grid.Column)" Value="1" />
<Setter Target="SidePanel.(Grid.Row)" Value="0" />
<Setter Target="SidePanel.Width" Value="{StaticResource SidePanelWidth}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="SmallLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource SmallLayoutMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SidePanel.(Grid.Column)" Value="0" />
<Setter Target="SidePanel.(Grid.Row)" Value="1" />
<Setter Target="SidePanel.Width" Value="Auto" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock x:Uid="KeyboardManager_Description"
TextWrapping="Wrap"/>
<ToggleSwitch x:Uid="KeyboardManager_EnableToggle"
IsOn="{x:Bind Path=ViewModel.Enabled, Mode=TwoWay}"
Margin="{StaticResource MediumTopMargin}" />
<!--<TextBlock x:Uid="KeyboardManager_ConfigHeader"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<TextBlock x:Uid="KeyboardManager_ProfileDescription"
Margin="{StaticResource SmallTopMargin}"/>
<ComboBox SelectedIndex="1" MinWidth="160"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem Content="Config-1"/>
<ComboBoxItem Content="Config-2"/>
<ComboBoxItem Content="Config-3"/>
</ComboBox>-->
<CustomControls:GroupTitleTextBlock x:Uid="KeyboardManager_RemapKeyboardHeader"
IsActive="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"/>
<CustomControls:BodyTextBlock Text="Click below to remap keys to other keys or shortcuts."
IsActive="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"
Margin="{StaticResource SmallTopMargin}"/>
<Button x:Uid="KeyboardManager_RemapKeyboardButton"
Margin="{StaticResource SmallTopMargin}"
Style="{StaticResource AccentButtonStyle}"
Command="{Binding Path=RemapKeyboardCommand}"
IsEnabled="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"/>
<ListView x:Name="RemapKeysList"
extensions:ListViewExtensions.AlternateColor="{ThemeResource SystemControlBackgroundListLowBrush}"
ItemsSource="{x:Bind Path=ViewModel.RemapKeys, Mode=OneWay}"
ItemTemplate="{StaticResource KeysListViewTemplate}"
BorderBrush="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
BorderThickness="1"
CornerRadius="4"
MinWidth="350"
MaxHeight="200"
Margin="{StaticResource SmallTopBottomMargin}"
HorizontalAlignment="Left"
SelectionMode="None"
IsSwipeEnabled="False"
Visibility="{x:Bind Path=ViewModel.RemapKeys, Mode=OneWay, Converter={StaticResource visibleIfNotEmptyConverter}}"
IsEnabled="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"
/>
<!--<AppBarButton x:Uid="KeyboardManager_RemapKeyboardButton"
Icon="Add"
Width="370"
Style="{StaticResource AddItemAppBarButtonStyle}"
Command="{Binding Path=RemapKeyboardCommand}"
Margin="{StaticResource AddItemButtonMargin}"
HorizontalAlignment="Left"
IsEnabled="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"/>-->
<CustomControls:GroupTitleTextBlock x:Uid="KeyboardManager_RemapShortcutsHeader"
IsActive="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"/>
<CustomControls:BodyTextBlock Text="Click below to remap a shortcuts to other shortcuts or keys. Additionally, mappings can be targeted to specific applications as well."
IsActive="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"/>
<Button x:Uid="KeyboardManager_RemapShortcutsButton"
Margin="{StaticResource SmallTopMargin}"
Style="{StaticResource AccentButtonStyle}"
Command="{Binding Path=EditShortcutCommand}"
IsEnabled="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"
/>
<ListView x:Name="RemapShortcutsList"
extensions:ListViewExtensions.AlternateColor="{ThemeResource SystemControlBackgroundListLowBrush}"
ItemsSource="{x:Bind Path=ViewModel.RemapShortcuts, Mode=OneWay}"
ItemTemplate="{StaticResource ShortcutKeysListViewTemplate}"
BorderBrush="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
BorderThickness="1"
CornerRadius="4"
MinWidth="350"
MaxHeight="200"
Margin="{StaticResource SmallTopBottomMargin}"
HorizontalAlignment="Left"
SelectionMode="None"
IsSwipeEnabled="False"
Visibility="{x:Bind Path=ViewModel.RemapShortcuts, Mode=OneWay, Converter={StaticResource visibleIfNotEmptyConverter}}"
IsEnabled="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.IsHorizontalRailEnabled="True"
/>
<!--<AppBarButton x:Uid="KeyboardManager_RemapShortcutsButton"
Icon="Add"
Width="370"
Style="{StaticResource AddItemAppBarButtonStyle}"
Command="{Binding Path=EditShortcutCommand}"
IsEnabled="{x:Bind Path=ViewModel.Enabled, Mode=OneWay}"
Margin="{StaticResource AddItemButtonMargin}"
HorizontalAlignment="Left"
/>-->
</StackPanel>
<StackPanel
x:Name="SidePanel"
Orientation="Vertical"
HorizontalAlignment="Left"
Width="{StaticResource SidePanelWidth}"
Grid.Column="1">
<TextBlock
x:Uid="About_KeyboardManager"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource XSmallBottomMargin}"
Foreground="{Binding Mode=TwoWay, Path=TextColor}"/>
<HyperlinkButton NavigateUri="https://aka.ms/PowerToysOverview_KeyboardManager">
<TextBlock x:Uid="Module_overview" />
</HyperlinkButton>
<HyperlinkButton NavigateUri="https://github.com/microsoft/PowerToys/issues">
<TextBlock x:Uid="Give_Feedback" />
</HyperlinkButton>
</StackPanel>
</Grid>
</Page>