From 854828e4caec301e3424e935e38ec7e3d784cc59 Mon Sep 17 00:00:00 2001 From: Martin Chrzan Date: Sun, 25 Oct 2020 18:00:59 +0100 Subject: [PATCH] Update string color represention when color format changed, but mouse is hovering on top of the same color --- .../ColorPickerUI/Mouse/MouseInfoProvider.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs b/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs index 5dd74771d0..2389c7c268 100644 --- a/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs +++ b/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs @@ -24,6 +24,7 @@ namespace ColorPicker.Mouse private readonly IUserSettings _userSettings; private System.Windows.Point _previousMousePosition = new System.Windows.Point(-1, 1); private Color _previousColor = Color.Transparent; + private bool _colorFormatChanged; [ImportingConstructor] public MouseInfoProvider(AppStateHandler appStateMonitor, IUserSettings userSettings) @@ -40,6 +41,7 @@ namespace ColorPicker.Mouse _mouseHook = new MouseHook(); _userSettings = userSettings; + _userSettings.CopiedColorRepresentation.PropertyChanged += CopiedColorRepresentation_PropertyChanged; } public event EventHandler MouseColorChanged; @@ -73,9 +75,10 @@ namespace ColorPicker.Mouse } var color = GetPixelColor(mousePosition); - if (_previousColor != color) + if (_previousColor != color || _colorFormatChanged) { _previousColor = color; + _colorFormatChanged = false; MouseColorChanged?.Invoke(this, color); } } @@ -137,6 +140,11 @@ namespace ColorPicker.Mouse OnMouseDown?.Invoke(this, p); } + private void CopiedColorRepresentation_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + _colorFormatChanged = true; + } + private void DisposeHook() { if (_timer.IsEnabled)