mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-21 02:30:04 +01:00
Moving checkbox to the left
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
|
||||
<!-- Key or Shortcut Trigger -->
|
||||
<tkcontrols:Case Value="KeyOrShortcut">
|
||||
<StackPanel Orientation="Vertical" Spacing="16">
|
||||
<StackPanel Orientation="Vertical" Spacing="8">
|
||||
<ToggleButton
|
||||
x:Name="TriggerKeyToggleBtn"
|
||||
MinHeight="86"
|
||||
@@ -116,6 +116,20 @@
|
||||
</ComboBox>
|
||||
</tkcontrols:Case>
|
||||
</tkcontrols:SwitchPresenter>
|
||||
|
||||
<CheckBox
|
||||
x:Name="AppSpecificCheckBox"
|
||||
x:Uid="UnifiedMappingControlAppSpecificCheckBox"
|
||||
Content="Only apply to a specific app"
|
||||
IsEnabled="False" />
|
||||
<TextBox
|
||||
x:Name="AppNameTextBox"
|
||||
x:Uid="UnifiedMappingControlAppNameTextBox"
|
||||
Background="{ThemeResource TextControlBackgroundFocused}"
|
||||
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"
|
||||
GotFocus="AppNameTextBox_GotFocus"
|
||||
PlaceholderText="Enter app name (e.g., notepad.exe)"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Arrow Separator -->
|
||||
@@ -185,92 +199,58 @@
|
||||
|
||||
<!-- Key or Shortcut Action -->
|
||||
<tkcontrols:Case Value="KeyOrShortcut">
|
||||
<StackPanel Orientation="Vertical" Spacing="16">
|
||||
<ToggleButton
|
||||
x:Name="ActionKeyToggleBtn"
|
||||
MinHeight="86"
|
||||
Padding="8,24,8,24"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Checked="ActionKeyToggleBtn_Checked"
|
||||
Style="{StaticResource CustomShortcutToggleButtonStyle}"
|
||||
Unchecked="ActionKeyToggleBtn_Unchecked">
|
||||
<ToggleButton.Content>
|
||||
<ItemsControl x:Name="ActionKeys">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<controls:WrapPanel
|
||||
HorizontalSpacing="4"
|
||||
Orientation="Horizontal"
|
||||
VerticalSpacing="4" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<local:KeyVisual
|
||||
Padding="8"
|
||||
Background="{ThemeResource CustomAccentBackgroundBrush}"
|
||||
BorderThickness="0"
|
||||
Content="{Binding}"
|
||||
CornerRadius="{StaticResource OverlayCornerRadius}"
|
||||
FontSize="16"
|
||||
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
||||
Style="{StaticResource DefaultKeyVisualStyle}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
|
||||
<!-- App-specific remapping (only for shortcuts) -->
|
||||
<CheckBox
|
||||
x:Name="AppSpecificCheckBox"
|
||||
x:Uid="UnifiedMappingControlAppSpecificCheckBox"
|
||||
Content="Make this app-specific"
|
||||
IsEnabled="False" />
|
||||
<TextBox
|
||||
x:Name="AppNameTextBox"
|
||||
x:Uid="UnifiedMappingControlAppNameTextBox"
|
||||
Background="{ThemeResource TextControlBackgroundFocused}"
|
||||
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"
|
||||
GotFocus="AppNameTextBox_GotFocus"
|
||||
PlaceholderText="Enter app name (e.g., notepad.exe)"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
<ToggleButton
|
||||
x:Name="ActionKeyToggleBtn"
|
||||
MinHeight="86"
|
||||
Padding="8,24,8,24"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Checked="ActionKeyToggleBtn_Checked"
|
||||
Style="{StaticResource CustomShortcutToggleButtonStyle}"
|
||||
Unchecked="ActionKeyToggleBtn_Unchecked">
|
||||
<ToggleButton.Content>
|
||||
<ItemsControl x:Name="ActionKeys">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<controls:WrapPanel
|
||||
HorizontalSpacing="4"
|
||||
Orientation="Horizontal"
|
||||
VerticalSpacing="4" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<local:KeyVisual
|
||||
Padding="8"
|
||||
Background="{ThemeResource CustomAccentBackgroundBrush}"
|
||||
BorderThickness="0"
|
||||
Content="{Binding}"
|
||||
CornerRadius="{StaticResource OverlayCornerRadius}"
|
||||
FontSize="16"
|
||||
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
||||
Style="{StaticResource DefaultKeyVisualStyle}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
</tkcontrols:Case>
|
||||
|
||||
<!-- Text Action -->
|
||||
<tkcontrols:Case Value="Text">
|
||||
<StackPanel Orientation="Vertical" Spacing="16">
|
||||
<TextBox
|
||||
x:Name="TextContentBox"
|
||||
x:Uid="UnifiedMappingControlTextContentTextBox"
|
||||
Height="120"
|
||||
AcceptsReturn="True"
|
||||
Background="{ThemeResource TextControlBackgroundFocused}"
|
||||
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"
|
||||
FontSize="13"
|
||||
GotFocus="TextContentBox_GotFocus"
|
||||
Header="Text to type"
|
||||
PlaceholderText="Enter the text to type when triggered"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<!-- App-specific for text -->
|
||||
<CheckBox
|
||||
x:Name="TextAppSpecificCheckBox"
|
||||
x:Uid="UnifiedMappingControlTextAppSpecificCheckBox"
|
||||
Content="Make this app-specific"
|
||||
IsEnabled="False" />
|
||||
<TextBox
|
||||
x:Name="TextAppNameTextBox"
|
||||
x:Uid="UnifiedMappingControlTextAppNameTextBox"
|
||||
Background="{ThemeResource TextControlBackgroundFocused}"
|
||||
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"
|
||||
GotFocus="TextAppNameTextBox_GotFocus"
|
||||
PlaceholderText="Enter app name (e.g., notepad.exe)"
|
||||
Visibility="Collapsed" />
|
||||
</StackPanel>
|
||||
<TextBox
|
||||
x:Name="TextContentBox"
|
||||
x:Uid="UnifiedMappingControlTextContentTextBox"
|
||||
Height="120"
|
||||
AcceptsReturn="True"
|
||||
Background="{ThemeResource TextControlBackgroundFocused}"
|
||||
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"
|
||||
FontSize="13"
|
||||
GotFocus="TextContentBox_GotFocus"
|
||||
Header="Text to type"
|
||||
PlaceholderText="Enter the text to type when triggered"
|
||||
TextWrapping="Wrap" />
|
||||
</tkcontrols:Case>
|
||||
|
||||
<!-- Open URL Action -->
|
||||
|
||||
@@ -141,11 +141,9 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Set up event handlers for app-specific checkboxes
|
||||
// Set up event handlers for app-specific checkbox
|
||||
AppSpecificCheckBox.Checked += AppSpecificCheckBox_Changed;
|
||||
AppSpecificCheckBox.Unchecked += AppSpecificCheckBox_Changed;
|
||||
TextAppSpecificCheckBox.Checked += TextAppSpecificCheckBox_Changed;
|
||||
TextAppSpecificCheckBox.Unchecked += TextAppSpecificCheckBox_Changed;
|
||||
|
||||
// Activate keyboard hook for the trigger input
|
||||
if (TriggerKeyToggleBtn.IsChecked == true)
|
||||
@@ -273,21 +271,6 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
: Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void TextAppSpecificCheckBox_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_internalUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CleanupKeyboardHook();
|
||||
UncheckAllToggleButtons();
|
||||
|
||||
TextAppNameTextBox.Visibility = TextAppSpecificCheckBox.IsChecked == true
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void UpdateAppSpecificCheckBoxState()
|
||||
{
|
||||
// Only enable app-specific remapping for shortcuts (multiple keys)
|
||||
@@ -297,21 +280,12 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
{
|
||||
_internalUpdate = true;
|
||||
|
||||
// Update Key/Shortcut action checkbox
|
||||
AppSpecificCheckBox.IsEnabled = isShortcut;
|
||||
if (!isShortcut)
|
||||
{
|
||||
AppSpecificCheckBox.IsChecked = false;
|
||||
AppNameTextBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
// Update Text action checkbox
|
||||
TextAppSpecificCheckBox.IsEnabled = isShortcut;
|
||||
if (!isShortcut)
|
||||
{
|
||||
TextAppSpecificCheckBox.IsChecked = false;
|
||||
TextAppNameTextBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -335,12 +309,6 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
UncheckAllToggleButtons();
|
||||
}
|
||||
|
||||
private void TextAppNameTextBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CleanupKeyboardHook();
|
||||
UncheckAllToggleButtons();
|
||||
}
|
||||
|
||||
private void UrlPathInput_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CleanupKeyboardHook();
|
||||
@@ -510,12 +478,7 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
/// </summary>
|
||||
public bool GetIsAppSpecific()
|
||||
{
|
||||
return CurrentActionType switch
|
||||
{
|
||||
ActionType.KeyOrShortcut => AppSpecificCheckBox?.IsChecked ?? false,
|
||||
ActionType.Text => TextAppSpecificCheckBox?.IsChecked ?? false,
|
||||
_ => false,
|
||||
};
|
||||
return AppSpecificCheckBox?.IsChecked ?? false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -523,12 +486,7 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
/// </summary>
|
||||
public string GetAppName()
|
||||
{
|
||||
return CurrentActionType switch
|
||||
{
|
||||
ActionType.KeyOrShortcut => GetIsAppSpecific() ? (AppNameTextBox?.Text ?? string.Empty) : string.Empty,
|
||||
ActionType.Text => GetIsAppSpecific() ? (TextAppNameTextBox?.Text ?? string.Empty) : string.Empty,
|
||||
_ => string.Empty,
|
||||
};
|
||||
return GetIsAppSpecific() ? (AppNameTextBox?.Text ?? string.Empty) : string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -695,33 +653,14 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
/// </summary>
|
||||
public void SetAppSpecific(bool isAppSpecific, string appName)
|
||||
{
|
||||
switch (CurrentActionType)
|
||||
if (AppSpecificCheckBox != null)
|
||||
{
|
||||
case ActionType.KeyOrShortcut:
|
||||
if (AppSpecificCheckBox != null)
|
||||
{
|
||||
AppSpecificCheckBox.IsChecked = isAppSpecific;
|
||||
if (isAppSpecific && AppNameTextBox != null)
|
||||
{
|
||||
AppNameTextBox.Text = appName;
|
||||
AppNameTextBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ActionType.Text:
|
||||
if (TextAppSpecificCheckBox != null)
|
||||
{
|
||||
TextAppSpecificCheckBox.IsChecked = isAppSpecific;
|
||||
if (isAppSpecific && TextAppNameTextBox != null)
|
||||
{
|
||||
TextAppNameTextBox.Text = appName;
|
||||
TextAppNameTextBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
AppSpecificCheckBox.IsChecked = isAppSpecific;
|
||||
if (isAppSpecific && AppNameTextBox != null)
|
||||
{
|
||||
AppNameTextBox.Text = appName;
|
||||
AppNameTextBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,12 +749,6 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
AppNameTextBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (TextAppNameTextBox != null)
|
||||
{
|
||||
TextAppNameTextBox.Text = string.Empty;
|
||||
TextAppNameTextBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
// Reset checkboxes
|
||||
if (AppSpecificCheckBox != null)
|
||||
{
|
||||
@@ -823,12 +756,6 @@ namespace KeyboardManagerEditorUI.Controls
|
||||
AppSpecificCheckBox.IsEnabled = false;
|
||||
}
|
||||
|
||||
if (TextAppSpecificCheckBox != null)
|
||||
{
|
||||
TextAppSpecificCheckBox.IsChecked = false;
|
||||
TextAppSpecificCheckBox.IsEnabled = false;
|
||||
}
|
||||
|
||||
// Reset app combo boxes
|
||||
if (ElevationComboBox != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user