Moving checkbox to the left

This commit is contained in:
Niels Laute
2026-02-04 19:53:37 +01:00
parent 685a3d8388
commit 1ac8a236c7
2 changed files with 73 additions and 166 deletions

View File

@@ -60,7 +60,7 @@
<!-- Key or Shortcut Trigger --> <!-- Key or Shortcut Trigger -->
<tkcontrols:Case Value="KeyOrShortcut"> <tkcontrols:Case Value="KeyOrShortcut">
<StackPanel Orientation="Vertical" Spacing="16"> <StackPanel Orientation="Vertical" Spacing="8">
<ToggleButton <ToggleButton
x:Name="TriggerKeyToggleBtn" x:Name="TriggerKeyToggleBtn"
MinHeight="86" MinHeight="86"
@@ -116,6 +116,20 @@
</ComboBox> </ComboBox>
</tkcontrols:Case> </tkcontrols:Case>
</tkcontrols:SwitchPresenter> </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> </StackPanel>
<!-- Arrow Separator --> <!-- Arrow Separator -->
@@ -185,7 +199,6 @@
<!-- Key or Shortcut Action --> <!-- Key or Shortcut Action -->
<tkcontrols:Case Value="KeyOrShortcut"> <tkcontrols:Case Value="KeyOrShortcut">
<StackPanel Orientation="Vertical" Spacing="16">
<ToggleButton <ToggleButton
x:Name="ActionKeyToggleBtn" x:Name="ActionKeyToggleBtn"
MinHeight="86" MinHeight="86"
@@ -222,27 +235,10 @@
</ItemsControl> </ItemsControl>
</ToggleButton.Content> </ToggleButton.Content>
</ToggleButton> </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>
</tkcontrols:Case> </tkcontrols:Case>
<!-- Text Action --> <!-- Text Action -->
<tkcontrols:Case Value="Text"> <tkcontrols:Case Value="Text">
<StackPanel Orientation="Vertical" Spacing="16">
<TextBox <TextBox
x:Name="TextContentBox" x:Name="TextContentBox"
x:Uid="UnifiedMappingControlTextContentTextBox" x:Uid="UnifiedMappingControlTextContentTextBox"
@@ -255,22 +251,6 @@
Header="Text to type" Header="Text to type"
PlaceholderText="Enter the text to type when triggered" PlaceholderText="Enter the text to type when triggered"
TextWrapping="Wrap" /> 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>
</tkcontrols:Case> </tkcontrols:Case>
<!-- Open URL Action --> <!-- Open URL Action -->

View File

@@ -141,11 +141,9 @@ namespace KeyboardManagerEditorUI.Controls
private void UserControl_Loaded(object sender, RoutedEventArgs e) 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.Checked += AppSpecificCheckBox_Changed;
AppSpecificCheckBox.Unchecked += AppSpecificCheckBox_Changed; AppSpecificCheckBox.Unchecked += AppSpecificCheckBox_Changed;
TextAppSpecificCheckBox.Checked += TextAppSpecificCheckBox_Changed;
TextAppSpecificCheckBox.Unchecked += TextAppSpecificCheckBox_Changed;
// Activate keyboard hook for the trigger input // Activate keyboard hook for the trigger input
if (TriggerKeyToggleBtn.IsChecked == true) if (TriggerKeyToggleBtn.IsChecked == true)
@@ -273,21 +271,6 @@ namespace KeyboardManagerEditorUI.Controls
: Visibility.Collapsed; : 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() private void UpdateAppSpecificCheckBoxState()
{ {
// Only enable app-specific remapping for shortcuts (multiple keys) // Only enable app-specific remapping for shortcuts (multiple keys)
@@ -297,21 +280,12 @@ namespace KeyboardManagerEditorUI.Controls
{ {
_internalUpdate = true; _internalUpdate = true;
// Update Key/Shortcut action checkbox
AppSpecificCheckBox.IsEnabled = isShortcut; AppSpecificCheckBox.IsEnabled = isShortcut;
if (!isShortcut) if (!isShortcut)
{ {
AppSpecificCheckBox.IsChecked = false; AppSpecificCheckBox.IsChecked = false;
AppNameTextBox.Visibility = Visibility.Collapsed; AppNameTextBox.Visibility = Visibility.Collapsed;
} }
// Update Text action checkbox
TextAppSpecificCheckBox.IsEnabled = isShortcut;
if (!isShortcut)
{
TextAppSpecificCheckBox.IsChecked = false;
TextAppNameTextBox.Visibility = Visibility.Collapsed;
}
} }
finally finally
{ {
@@ -335,12 +309,6 @@ namespace KeyboardManagerEditorUI.Controls
UncheckAllToggleButtons(); UncheckAllToggleButtons();
} }
private void TextAppNameTextBox_GotFocus(object sender, RoutedEventArgs e)
{
CleanupKeyboardHook();
UncheckAllToggleButtons();
}
private void UrlPathInput_GotFocus(object sender, RoutedEventArgs e) private void UrlPathInput_GotFocus(object sender, RoutedEventArgs e)
{ {
CleanupKeyboardHook(); CleanupKeyboardHook();
@@ -510,12 +478,7 @@ namespace KeyboardManagerEditorUI.Controls
/// </summary> /// </summary>
public bool GetIsAppSpecific() public bool GetIsAppSpecific()
{ {
return CurrentActionType switch return AppSpecificCheckBox?.IsChecked ?? false;
{
ActionType.KeyOrShortcut => AppSpecificCheckBox?.IsChecked ?? false,
ActionType.Text => TextAppSpecificCheckBox?.IsChecked ?? false,
_ => false,
};
} }
/// <summary> /// <summary>
@@ -523,12 +486,7 @@ namespace KeyboardManagerEditorUI.Controls
/// </summary> /// </summary>
public string GetAppName() public string GetAppName()
{ {
return CurrentActionType switch return GetIsAppSpecific() ? (AppNameTextBox?.Text ?? string.Empty) : string.Empty;
{
ActionType.KeyOrShortcut => GetIsAppSpecific() ? (AppNameTextBox?.Text ?? string.Empty) : string.Empty,
ActionType.Text => GetIsAppSpecific() ? (TextAppNameTextBox?.Text ?? string.Empty) : string.Empty,
_ => string.Empty,
};
} }
/// <summary> /// <summary>
@@ -695,9 +653,6 @@ namespace KeyboardManagerEditorUI.Controls
/// </summary> /// </summary>
public void SetAppSpecific(bool isAppSpecific, string appName) public void SetAppSpecific(bool isAppSpecific, string appName)
{ {
switch (CurrentActionType)
{
case ActionType.KeyOrShortcut:
if (AppSpecificCheckBox != null) if (AppSpecificCheckBox != null)
{ {
AppSpecificCheckBox.IsChecked = isAppSpecific; AppSpecificCheckBox.IsChecked = isAppSpecific;
@@ -707,22 +662,6 @@ namespace KeyboardManagerEditorUI.Controls
AppNameTextBox.Visibility = Visibility.Visible; 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;
}
} }
#endregion #endregion
@@ -810,12 +749,6 @@ namespace KeyboardManagerEditorUI.Controls
AppNameTextBox.Visibility = Visibility.Collapsed; AppNameTextBox.Visibility = Visibility.Collapsed;
} }
if (TextAppNameTextBox != null)
{
TextAppNameTextBox.Text = string.Empty;
TextAppNameTextBox.Visibility = Visibility.Collapsed;
}
// Reset checkboxes // Reset checkboxes
if (AppSpecificCheckBox != null) if (AppSpecificCheckBox != null)
{ {
@@ -823,12 +756,6 @@ namespace KeyboardManagerEditorUI.Controls
AppSpecificCheckBox.IsEnabled = false; AppSpecificCheckBox.IsEnabled = false;
} }
if (TextAppSpecificCheckBox != null)
{
TextAppSpecificCheckBox.IsChecked = false;
TextAppSpecificCheckBox.IsEnabled = false;
}
// Reset app combo boxes // Reset app combo boxes
if (ElevationComboBox != null) if (ElevationComboBox != null)
{ {