aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.UI.Controls/ExtendedRadioButton.cs
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-20 20:33:05 -0500
commit767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch)
tree49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.UI.Controls/ExtendedRadioButton.cs
parent845554722efaed872948a9e0f7202e3ef52f1b6e (diff)
Pushing missing changes
Diffstat (limited to 'MediaBrowser.UI.Controls/ExtendedRadioButton.cs')
-rw-r--r--MediaBrowser.UI.Controls/ExtendedRadioButton.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/MediaBrowser.UI.Controls/ExtendedRadioButton.cs b/MediaBrowser.UI.Controls/ExtendedRadioButton.cs
new file mode 100644
index 000000000..82aad7f09
--- /dev/null
+++ b/MediaBrowser.UI.Controls/ExtendedRadioButton.cs
@@ -0,0 +1,49 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace MediaBrowser.UI.Controls
+{
+ /// <summary>
+ /// Extends RadioButton to provide focus on mouse over, and invoke on enter press
+ /// </summary>
+ public class ExtendedRadioButton : RadioButton
+ {
+ private Point? _lastMouseMovePoint;
+
+ /// <summary>
+ /// Handles OnMouseMove to auto-select the item that's being moused over
+ /// </summary>
+ protected override void OnMouseMove(MouseEventArgs e)
+ {
+ base.OnMouseMove(e);
+
+ var window = this.GetWindow();
+
+ // If the cursor is currently hidden, don't bother reacting to it
+ if (Cursor == Cursors.None || window.Cursor == Cursors.None)
+ {
+ return;
+ }
+
+ // Store the last position for comparison purposes
+ // Even if the mouse is not moving this event will fire as elements are showing and hiding
+ var pos = e.GetPosition(window);
+
+ if (!_lastMouseMovePoint.HasValue)
+ {
+ _lastMouseMovePoint = pos;
+ return;
+ }
+
+ if (pos == _lastMouseMovePoint)
+ {
+ return;
+ }
+
+ _lastMouseMovePoint = pos;
+
+ Focus();
+ }
+ }
+}