mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[FindMyMouse]Support different activation modes (#28096)
* multiple activation modes for find my mouse * use custom shortcut
This commit is contained in:
committed by
GitHub
parent
752c298ef3
commit
83f0625427
@@ -3,26 +3,20 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Converters
|
||||
{
|
||||
public sealed class FindMyMouseActivationShakeMouseIntToVisibilityConverter : IValueConverter
|
||||
public sealed class FindMyMouseActivationIntToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var activationShake = (int)value;
|
||||
var selectedActivation = (int)value;
|
||||
var expectedActivation = int.Parse(parameter as string, CultureInfo.InvariantCulture);
|
||||
|
||||
// Assumes 1 is the index for the shake mouse option in the activation method combo box
|
||||
if (activationShake == 1)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
return selectedActivation == expectedActivation ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
@@ -11,7 +11,7 @@
|
||||
AutomationProperties.LandmarkType="Main"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<localConverters:FindMyMouseActivationShakeMouseIntToVisibilityConverter x:Key="FindMyMouseActivationShakeMouseIntToVisibilityConverter" />
|
||||
<localConverters:FindMyMouseActivationIntToVisibilityConverter x:Key="FindMyMouseActivationIntToVisibilityConverter" />
|
||||
</Page.Resources>
|
||||
<controls:SettingsPageControl
|
||||
x:Uid="MouseUtils"
|
||||
@@ -42,12 +42,14 @@
|
||||
MinWidth="{StaticResource SettingActionControlMinWidth}"
|
||||
SelectedIndex="{x:Bind Path=ViewModel.FindMyMouseActivationMethod, Mode=TwoWay}">
|
||||
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationDoubleControlPress" />
|
||||
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationDoubleRightControlPress" />
|
||||
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationShakeMouse" />
|
||||
<ComboBoxItem x:Uid="MouseUtils_FindMyMouse_ActivationCustomizedShortcut" />
|
||||
</ComboBox>
|
||||
<labs:SettingsExpander.Items>
|
||||
<labs:SettingsCard
|
||||
x:Uid="MouseUtils_FindMyMouse_ShakingMinimumDistance"
|
||||
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationShakeMouseIntToVisibilityConverter}}">
|
||||
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationIntToVisibilityConverter}, ConverterParameter=2}">
|
||||
<NumberBox
|
||||
MinWidth="{StaticResource SettingActionControlMinWidth}"
|
||||
LargeChange="1000"
|
||||
@@ -57,6 +59,14 @@
|
||||
SpinButtonPlacementMode="Compact"
|
||||
Value="{x:Bind Mode=TwoWay, Path=ViewModel.FindMyMouseShakingMinimumDistance}" />
|
||||
</labs:SettingsCard>
|
||||
<labs:SettingsCard
|
||||
x:Uid="MouseUtils_FindMyMouse_ActivationShortcut"
|
||||
HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=}"
|
||||
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationIntToVisibilityConverter}, ConverterParameter=3}">
|
||||
<controls:ShortcutControl
|
||||
MinWidth="{StaticResource SettingActionControlMinWidth}"
|
||||
HotkeySettings="{x:Bind Path=ViewModel.FindMyMouseActivationShortcut, Mode=TwoWay}" />
|
||||
</labs:SettingsCard>
|
||||
<labs:SettingsCard ContentAlignment="Left">
|
||||
<CheckBox
|
||||
x:Uid="MouseUtils_Prevent_Activation_On_Game_Mode"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -1148,7 +1148,7 @@
|
||||
<value>Use a shortcut or press the Windows key for some time to activate</value>
|
||||
</data>
|
||||
<data name="Radio_ShortcutGuide_ActivationMethod_CustomizedShortcut.Content" xml:space="preserve">
|
||||
<value>Customized shortcut</value>
|
||||
<value>Custom shortcut</value>
|
||||
</data>
|
||||
<data name="Radio_ShortcutGuide_ActivationMethod_LongPressWindowsKey.Content" xml:space="preserve">
|
||||
<value>Hold down Windows key</value>
|
||||
@@ -2384,7 +2384,7 @@ From there, simply click on one of the supported files in the File Explorer and
|
||||
<comment>Mouse as in the hardware peripheral</comment>
|
||||
</data>
|
||||
<data name="Oobe_MouseUtils_FindMyMouse_Description.Text" xml:space="preserve">
|
||||
<value>Shake the mouse or press the left Ctrl key twice to focus the mouse pointer.</value>
|
||||
<value>Focus the mouse pointer pressing the Ctrl key twice, using a custom shortcut or shaking the mouse.</value>
|
||||
<comment>Mouse as in the hardware peripheral. Key as in a keyboard key</comment>
|
||||
</data>
|
||||
<data name="Oobe_MouseUtils_MouseHighlighter.Text" xml:space="preserve">
|
||||
@@ -2512,7 +2512,7 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
|
||||
<comment>Refers to the utility name</comment>
|
||||
</data>
|
||||
<data name="MouseUtils_FindMyMouse.Description" xml:space="preserve">
|
||||
<value>Find My Mouse highlights the position of the cursor when shaking the mouse or pressing the left Ctrl key twice.</value>
|
||||
<value>Find My Mouse highlights the position of the cursor when pressing the Ctrl key twice, using a custom shortcut or when shaking the mouse.</value>
|
||||
<comment>"Ctrl" is a keyboard key. "Find My Mouse" is the name of the utility</comment>
|
||||
</data>
|
||||
<data name="MouseUtils_Enable_FindMyMouse.Header" xml:space="preserve">
|
||||
@@ -3658,4 +3658,17 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="AlwaysOnTop_FrameOpacity.Header" xml:space="preserve">
|
||||
<value>Opacity (%)</value>
|
||||
</data>
|
||||
<data name="MouseUtils_FindMyMouse_ActivationCustomizedShortcut.Content" xml:space="preserve">
|
||||
<value>Custom shortcut</value>
|
||||
</data>
|
||||
<data name="MouseUtils_FindMyMouse_ActivationDoubleRightControlPress.Content" xml:space="preserve">
|
||||
<value>Press Right Control twice</value>
|
||||
<comment>Right control is the physical key on the keyboard.</comment>
|
||||
</data>
|
||||
<data name="MouseUtils_FindMyMouse_ActivationShortcut.Description" xml:space="preserve">
|
||||
<value>Customize the shortcut to turn on or off this mode</value>
|
||||
</data>
|
||||
<data name="MouseUtils_FindMyMouse_ActivationShortcut.Header" xml:space="preserve">
|
||||
<value>Activation shortcut</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -48,7 +48,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
|
||||
FindMyMouseSettingsConfig = findMyMouseSettingsRepository.SettingsConfig;
|
||||
_findMyMouseActivationMethod = FindMyMouseSettingsConfig.Properties.ActivationMethod.Value < 2 ? FindMyMouseSettingsConfig.Properties.ActivationMethod.Value : 0;
|
||||
_findMyMouseActivationMethod = FindMyMouseSettingsConfig.Properties.ActivationMethod.Value < 4 ? FindMyMouseSettingsConfig.Properties.ActivationMethod.Value : 0;
|
||||
_findMyMouseDoNotActivateOnGameMode = FindMyMouseSettingsConfig.Properties.DoNotActivateOnGameMode.Value;
|
||||
|
||||
string backgroundColor = FindMyMouseSettingsConfig.Properties.BackgroundColor.Value;
|
||||
@@ -218,6 +218,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public HotkeySettings FindMyMouseActivationShortcut
|
||||
{
|
||||
get
|
||||
{
|
||||
return FindMyMouseSettingsConfig.Properties.ActivationShortcut;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (FindMyMouseSettingsConfig.Properties.ActivationShortcut != value)
|
||||
{
|
||||
FindMyMouseSettingsConfig.Properties.ActivationShortcut = value ?? FindMyMouseSettingsConfig.Properties.DefaultActivationShortcut;
|
||||
NotifyFindMyMousePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool FindMyMouseDoNotActivateOnGameMode
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user