2021-10-22 20:30:18 +08:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
using System;
|
2021-10-26 02:39:48 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2021-10-22 20:30:18 +08:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class MouseUtilsViewModel : Observable
|
|
|
|
|
{
|
2021-10-26 02:39:48 +08:00
|
|
|
|
private ISettingsUtils SettingsUtils { get; set; }
|
|
|
|
|
|
2021-10-22 20:30:18 +08:00
|
|
|
|
private GeneralSettings GeneralSettingsConfig { get; set; }
|
|
|
|
|
|
2021-10-26 02:39:48 +08:00
|
|
|
|
private FindMyMouseSettings FindMyMouseSettingsConfig { get; set; }
|
|
|
|
|
|
2021-11-22 21:31:31 +08:00
|
|
|
|
private MouseHighlighterSettings MouseHighlighterSettingsConfig { get; set; }
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
private MousePointerCrosshairsSettings MousePointerCrosshairsSettingsConfig { get; set; }
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public MouseUtilsViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<FindMyMouseSettings> findMyMouseSettingsRepository, ISettingsRepository<MouseHighlighterSettings> mouseHighlighterSettingsRepository, ISettingsRepository<MousePointerCrosshairsSettings> mousePointerCrosshairsSettingsRepository, Func<string, int> ipcMSGCallBackFunc)
|
2021-10-22 20:30:18 +08:00
|
|
|
|
{
|
2021-10-26 02:39:48 +08:00
|
|
|
|
SettingsUtils = settingsUtils;
|
|
|
|
|
|
2021-10-22 20:30:18 +08:00
|
|
|
|
// To obtain the general settings configurations of PowerToys Settings.
|
|
|
|
|
if (settingsRepository == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(settingsRepository));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
|
|
|
|
|
|
|
|
|
_isFindMyMouseEnabled = GeneralSettingsConfig.Enabled.FindMyMouse;
|
|
|
|
|
|
2021-11-22 21:31:31 +08:00
|
|
|
|
_isMouseHighlighterEnabled = GeneralSettingsConfig.Enabled.MouseHighlighter;
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_isMousePointerCrosshairsEnabled = GeneralSettingsConfig.Enabled.MousePointerCrosshairs;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2021-10-26 02:39:48 +08:00
|
|
|
|
// To obtain the find my mouse settings, if the file exists.
|
|
|
|
|
// If not, to create a file with the default settings and to return the default configurations.
|
|
|
|
|
if (findMyMouseSettingsRepository == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(findMyMouseSettingsRepository));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FindMyMouseSettingsConfig = findMyMouseSettingsRepository.SettingsConfig;
|
2022-02-12 06:52:57 +08:00
|
|
|
|
_findMyMouseActivationMethod = FindMyMouseSettingsConfig.Properties.ActivationMethod.Value;
|
2021-10-26 02:39:48 +08:00
|
|
|
|
_findMyMouseDoNotActivateOnGameMode = FindMyMouseSettingsConfig.Properties.DoNotActivateOnGameMode.Value;
|
|
|
|
|
|
2021-11-24 00:52:17 +08:00
|
|
|
|
string backgroundColor = FindMyMouseSettingsConfig.Properties.BackgroundColor.Value;
|
|
|
|
|
_findMyMouseBackgroundColor = !string.IsNullOrEmpty(backgroundColor) ? backgroundColor : "#000000";
|
|
|
|
|
|
|
|
|
|
string spotlightColor = FindMyMouseSettingsConfig.Properties.SpotlightColor.Value;
|
|
|
|
|
_findMyMouseSpotlightColor = !string.IsNullOrEmpty(spotlightColor) ? spotlightColor : "#FFFFFF";
|
|
|
|
|
|
|
|
|
|
_findMyMouseOverlayOpacity = FindMyMouseSettingsConfig.Properties.OverlayOpacity.Value;
|
|
|
|
|
_findMyMouseSpotlightRadius = FindMyMouseSettingsConfig.Properties.SpotlightRadius.Value;
|
|
|
|
|
_findMyMouseAnimationDurationMs = FindMyMouseSettingsConfig.Properties.AnimationDurationMs.Value;
|
|
|
|
|
_findMyMouseSpotlightInitialZoom = FindMyMouseSettingsConfig.Properties.SpotlightInitialZoom.Value;
|
2022-02-15 02:22:05 +08:00
|
|
|
|
_findMyMouseExcludedApps = FindMyMouseSettingsConfig.Properties.ExcludedApps.Value;
|
2021-11-24 00:52:17 +08:00
|
|
|
|
|
2021-11-22 21:31:31 +08:00
|
|
|
|
if (mouseHighlighterSettingsRepository == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(mouseHighlighterSettingsRepository));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseHighlighterSettingsConfig = mouseHighlighterSettingsRepository.SettingsConfig;
|
|
|
|
|
string leftClickColor = MouseHighlighterSettingsConfig.Properties.LeftButtonClickColor.Value;
|
|
|
|
|
_highlighterLeftButtonClickColor = !string.IsNullOrEmpty(leftClickColor) ? leftClickColor : "#FFFF00";
|
|
|
|
|
|
|
|
|
|
string rightClickColor = MouseHighlighterSettingsConfig.Properties.RightButtonClickColor.Value;
|
|
|
|
|
_highlighterRightButtonClickColor = !string.IsNullOrEmpty(rightClickColor) ? rightClickColor : "#0000FF";
|
|
|
|
|
|
|
|
|
|
_highlighterOpacity = MouseHighlighterSettingsConfig.Properties.HighlightOpacity.Value;
|
|
|
|
|
_highlighterRadius = MouseHighlighterSettingsConfig.Properties.HighlightRadius.Value;
|
|
|
|
|
_highlightFadeDelayMs = MouseHighlighterSettingsConfig.Properties.HighlightFadeDelayMs.Value;
|
|
|
|
|
_highlightFadeDurationMs = MouseHighlighterSettingsConfig.Properties.HighlightFadeDurationMs.Value;
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (mousePointerCrosshairsSettingsRepository == null)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
throw new ArgumentNullException(nameof(mousePointerCrosshairsSettingsRepository));
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
MousePointerCrosshairsSettingsConfig = mousePointerCrosshairsSettingsRepository.SettingsConfig;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
string crosshairsColor = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsColor.Value;
|
|
|
|
|
_mousePointerCrosshairsColor = !string.IsNullOrEmpty(crosshairsColor) ? crosshairsColor : "#FF0000";
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
string crosshairsBorderColor = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsBorderColor.Value;
|
|
|
|
|
_mousePointerCrosshairsBorderColor = !string.IsNullOrEmpty(crosshairsBorderColor) ? crosshairsBorderColor : "#FFFFFF";
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsOpacity = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsOpacity.Value;
|
|
|
|
|
_mousePointerCrosshairsRadius = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsRadius.Value;
|
|
|
|
|
_mousePointerCrosshairsThickness = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsThickness.Value;
|
|
|
|
|
_mousePointerCrosshairsBorderSize = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsBorderSize.Value;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2021-10-26 02:39:48 +08:00
|
|
|
|
// set the callback functions value to handle outgoing IPC message.
|
2021-10-22 20:30:18 +08:00
|
|
|
|
SendConfigMSG = ipcMSGCallBackFunc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsFindMyMouseEnabled
|
|
|
|
|
{
|
|
|
|
|
get => _isFindMyMouseEnabled;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_isFindMyMouseEnabled != value)
|
|
|
|
|
{
|
|
|
|
|
_isFindMyMouseEnabled = value;
|
|
|
|
|
|
|
|
|
|
GeneralSettingsConfig.Enabled.FindMyMouse = value;
|
|
|
|
|
OnPropertyChanged(nameof(IsFindMyMouseEnabled));
|
|
|
|
|
|
|
|
|
|
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
|
|
|
|
SendConfigMSG(outgoing.ToString());
|
|
|
|
|
|
2021-10-26 02:39:48 +08:00
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-12 06:52:57 +08:00
|
|
|
|
public int FindMyMouseActivationMethod
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseActivationMethod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _findMyMouseActivationMethod)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseActivationMethod = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.ActivationMethod.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-26 02:39:48 +08:00
|
|
|
|
public bool FindMyMouseDoNotActivateOnGameMode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseDoNotActivateOnGameMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_findMyMouseDoNotActivateOnGameMode != value)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseDoNotActivateOnGameMode = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.DoNotActivateOnGameMode.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
2021-10-22 20:30:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-24 00:52:17 +08:00
|
|
|
|
public string FindMyMouseBackgroundColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseBackgroundColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#000000";
|
|
|
|
|
if (!value.Equals(_findMyMouseBackgroundColor, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseBackgroundColor = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.BackgroundColor.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string FindMyMouseSpotlightColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseSpotlightColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#FFFFFF";
|
|
|
|
|
if (!value.Equals(_findMyMouseSpotlightColor, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseSpotlightColor = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.SpotlightColor.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int FindMyMouseOverlayOpacity
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseOverlayOpacity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _findMyMouseOverlayOpacity)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseOverlayOpacity = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.OverlayOpacity.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int FindMyMouseSpotlightRadius
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseSpotlightRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _findMyMouseSpotlightRadius)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseSpotlightRadius = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.SpotlightRadius.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int FindMyMouseAnimationDurationMs
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseAnimationDurationMs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _findMyMouseAnimationDurationMs)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseAnimationDurationMs = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.AnimationDurationMs.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int FindMyMouseSpotlightInitialZoom
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseSpotlightInitialZoom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _findMyMouseSpotlightInitialZoom)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseSpotlightInitialZoom = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.SpotlightInitialZoom.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-15 02:22:05 +08:00
|
|
|
|
public string FindMyMouseExcludedApps
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _findMyMouseExcludedApps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _findMyMouseExcludedApps)
|
|
|
|
|
{
|
|
|
|
|
_findMyMouseExcludedApps = value;
|
|
|
|
|
FindMyMouseSettingsConfig.Properties.ExcludedApps.Value = value;
|
|
|
|
|
NotifyFindMyMousePropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-26 02:39:48 +08:00
|
|
|
|
public void NotifyFindMyMousePropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
|
|
|
|
|
SndFindMyMouseSettings outsettings = new SndFindMyMouseSettings(FindMyMouseSettingsConfig);
|
|
|
|
|
SndModuleSettings<SndFindMyMouseSettings> ipcMessage = new SndModuleSettings<SndFindMyMouseSettings>(outsettings);
|
|
|
|
|
SendConfigMSG(ipcMessage.ToJsonString());
|
|
|
|
|
SettingsUtils.SaveSettings(FindMyMouseSettingsConfig.ToJsonString(), FindMyMouseSettings.ModuleName);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-22 21:31:31 +08:00
|
|
|
|
public bool IsMouseHighlighterEnabled
|
|
|
|
|
{
|
|
|
|
|
get => _isMouseHighlighterEnabled;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_isMouseHighlighterEnabled != value)
|
|
|
|
|
{
|
|
|
|
|
_isMouseHighlighterEnabled = value;
|
|
|
|
|
|
|
|
|
|
GeneralSettingsConfig.Enabled.MouseHighlighter = value;
|
|
|
|
|
OnPropertyChanged(nameof(_isMouseHighlighterEnabled));
|
|
|
|
|
|
|
|
|
|
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
|
|
|
|
SendConfigMSG(outgoing.ToString());
|
|
|
|
|
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HotkeySettings MouseHighlighterActivationShortcut
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return MouseHighlighterSettingsConfig.Properties.ActivationShortcut;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (MouseHighlighterSettingsConfig.Properties.ActivationShortcut != value)
|
|
|
|
|
{
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.ActivationShortcut = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string MouseHighlighterLeftButtonClickColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _highlighterLeftButtonClickColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
// The fallback value is based on ToRGBHex's behavior, which returns
|
|
|
|
|
// #FFFFFF if any exceptions are encountered, e.g. from passing in a null value.
|
|
|
|
|
// This extra handling is added here to deal with FxCop warnings.
|
|
|
|
|
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#FFFFFF";
|
|
|
|
|
if (!value.Equals(_highlighterLeftButtonClickColor, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_highlighterLeftButtonClickColor = value;
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.LeftButtonClickColor.Value = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string MouseHighlighterRightButtonClickColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _highlighterRightButtonClickColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
// The fallback value is based on ToRGBHex's behavior, which returns
|
|
|
|
|
// #FFFFFF if any exceptions are encountered, e.g. from passing in a null value.
|
|
|
|
|
// This extra handling is added here to deal with FxCop warnings.
|
|
|
|
|
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#FFFFFF";
|
|
|
|
|
if (!value.Equals(_highlighterRightButtonClickColor, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_highlighterRightButtonClickColor = value;
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.RightButtonClickColor.Value = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int MouseHighlighterOpacity
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _highlighterOpacity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _highlighterOpacity)
|
|
|
|
|
{
|
|
|
|
|
_highlighterOpacity = value;
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.HighlightOpacity.Value = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int MouseHighlighterRadius
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _highlighterRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _highlighterRadius)
|
|
|
|
|
{
|
|
|
|
|
_highlighterRadius = value;
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.HighlightRadius.Value = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int MouseHighlighterFadeDelayMs
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _highlightFadeDelayMs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _highlightFadeDelayMs)
|
|
|
|
|
{
|
|
|
|
|
_highlightFadeDelayMs = value;
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.HighlightFadeDelayMs.Value = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int MouseHighlighterFadeDurationMs
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _highlightFadeDurationMs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _highlightFadeDurationMs)
|
|
|
|
|
{
|
|
|
|
|
_highlightFadeDurationMs = value;
|
|
|
|
|
MouseHighlighterSettingsConfig.Properties.HighlightFadeDurationMs.Value = value;
|
|
|
|
|
NotifyMouseHighlighterPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void NotifyMouseHighlighterPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
|
|
|
|
|
SndMouseHighlighterSettings outsettings = new SndMouseHighlighterSettings(MouseHighlighterSettingsConfig);
|
|
|
|
|
SndModuleSettings<SndMouseHighlighterSettings> ipcMessage = new SndModuleSettings<SndMouseHighlighterSettings>(outsettings);
|
|
|
|
|
SendConfigMSG(ipcMessage.ToJsonString());
|
|
|
|
|
SettingsUtils.SaveSettings(MouseHighlighterSettingsConfig.ToJsonString(), MouseHighlighterSettings.ModuleName);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public bool IsMousePointerCrosshairsEnabled
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
get => _isMousePointerCrosshairsEnabled;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (_isMousePointerCrosshairsEnabled != value)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_isMousePointerCrosshairsEnabled = value;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
GeneralSettingsConfig.Enabled.MousePointerCrosshairs = value;
|
|
|
|
|
OnPropertyChanged(nameof(_isMousePointerCrosshairsEnabled));
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
|
|
|
|
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
|
|
|
|
SendConfigMSG(outgoing.ToString());
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public HotkeySettings MousePointerCrosshairsActivationShortcut
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return MousePointerCrosshairsSettingsConfig.Properties.ActivationShortcut;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (MousePointerCrosshairsSettingsConfig.Properties.ActivationShortcut != value)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.ActivationShortcut = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public string MousePointerCrosshairsColor
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return _mousePointerCrosshairsColor;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
// The fallback value is based on ToRGBHex's behavior, which returns
|
|
|
|
|
// #FFFFFF if any exceptions are encountered, e.g. from passing in a null value.
|
|
|
|
|
// This extra handling is added here to deal with FxCop warnings.
|
|
|
|
|
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#FFFFFF";
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (!value.Equals(_mousePointerCrosshairsColor, StringComparison.OrdinalIgnoreCase))
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsColor = value;
|
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsColor.Value = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public int MousePointerCrosshairsOpacity
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return _mousePointerCrosshairsOpacity;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (value != _mousePointerCrosshairsOpacity)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsOpacity = value;
|
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsOpacity.Value = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public int MousePointerCrosshairsRadius
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return _mousePointerCrosshairsRadius;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (value != _mousePointerCrosshairsRadius)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsRadius = value;
|
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsRadius.Value = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public int MousePointerCrosshairsThickness
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return _mousePointerCrosshairsThickness;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (value != _mousePointerCrosshairsThickness)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsThickness = value;
|
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsThickness.Value = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public string MousePointerCrosshairsBorderColor
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return _mousePointerCrosshairsBorderColor;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
// The fallback value is based on ToRGBHex's behavior, which returns
|
|
|
|
|
// #FFFFFF if any exceptions are encountered, e.g. from passing in a null value.
|
|
|
|
|
// This extra handling is added here to deal with FxCop warnings.
|
|
|
|
|
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#FFFFFF";
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (!value.Equals(_mousePointerCrosshairsBorderColor, StringComparison.OrdinalIgnoreCase))
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsBorderColor = value;
|
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsBorderColor.Value = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public int MousePointerCrosshairsBorderSize
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
return _mousePointerCrosshairsBorderSize;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
if (value != _mousePointerCrosshairsBorderSize)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
2022-01-26 22:01:24 +08:00
|
|
|
|
_mousePointerCrosshairsBorderSize = value;
|
|
|
|
|
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsBorderSize.Value = value;
|
|
|
|
|
NotifyMousePointerCrosshairsPropertyChanged();
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
public void NotifyMousePointerCrosshairsPropertyChanged([CallerMemberName] string propertyName = null)
|
2022-01-24 21:29:16 +08:00
|
|
|
|
{
|
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
SndMousePointerCrosshairsSettings outsettings = new SndMousePointerCrosshairsSettings(MousePointerCrosshairsSettingsConfig);
|
|
|
|
|
SndModuleSettings<SndMousePointerCrosshairsSettings> ipcMessage = new SndModuleSettings<SndMousePointerCrosshairsSettings>(outsettings);
|
2022-01-24 21:29:16 +08:00
|
|
|
|
SendConfigMSG(ipcMessage.ToJsonString());
|
2022-01-26 22:01:24 +08:00
|
|
|
|
SettingsUtils.SaveSettings(MousePointerCrosshairsSettingsConfig.ToJsonString(), MousePointerCrosshairsSettings.ModuleName);
|
2022-01-24 21:29:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-22 20:30:18 +08:00
|
|
|
|
private Func<string, int> SendConfigMSG { get; }
|
|
|
|
|
|
|
|
|
|
private bool _isFindMyMouseEnabled;
|
2022-02-12 06:52:57 +08:00
|
|
|
|
private int _findMyMouseActivationMethod;
|
2021-10-26 02:39:48 +08:00
|
|
|
|
private bool _findMyMouseDoNotActivateOnGameMode;
|
2021-11-24 00:52:17 +08:00
|
|
|
|
private string _findMyMouseBackgroundColor;
|
|
|
|
|
private string _findMyMouseSpotlightColor;
|
|
|
|
|
private int _findMyMouseOverlayOpacity;
|
|
|
|
|
private int _findMyMouseSpotlightRadius;
|
|
|
|
|
private int _findMyMouseAnimationDurationMs;
|
|
|
|
|
private int _findMyMouseSpotlightInitialZoom;
|
2022-02-15 02:22:05 +08:00
|
|
|
|
private string _findMyMouseExcludedApps;
|
2021-11-22 21:31:31 +08:00
|
|
|
|
|
|
|
|
|
private bool _isMouseHighlighterEnabled;
|
|
|
|
|
private string _highlighterLeftButtonClickColor;
|
|
|
|
|
private string _highlighterRightButtonClickColor;
|
|
|
|
|
private int _highlighterOpacity;
|
|
|
|
|
private int _highlighterRadius;
|
|
|
|
|
private int _highlightFadeDelayMs;
|
|
|
|
|
private int _highlightFadeDurationMs;
|
2022-01-24 21:29:16 +08:00
|
|
|
|
|
2022-01-26 22:01:24 +08:00
|
|
|
|
private bool _isMousePointerCrosshairsEnabled;
|
|
|
|
|
private string _mousePointerCrosshairsColor;
|
|
|
|
|
private int _mousePointerCrosshairsOpacity;
|
|
|
|
|
private int _mousePointerCrosshairsRadius;
|
|
|
|
|
private int _mousePointerCrosshairsThickness;
|
|
|
|
|
private string _mousePointerCrosshairsBorderColor;
|
|
|
|
|
private int _mousePointerCrosshairsBorderSize;
|
2021-10-22 20:30:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|