Skip to content

Commit

Permalink
Merge pull request #1 from mitchcapper/AllowHoverToggle
Browse files Browse the repository at this point in the history
Added AllowHover option to prevent hover from changing value
  • Loading branch information
BratchedDev committed Oct 15, 2015
2 parents 26b3313 + a884443 commit 2f6181c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Src/Bratched.Tools/RatingControl/RatingControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private void InitDefaultValues()
Margin = new Thickness(0);
Background = new SolidColorBrush(Colors.Transparent);
IsEditable = false;
AllowHover = true;
Value = 0;
}

Expand Down Expand Up @@ -445,8 +446,12 @@ public bool IsEditable
get { return (bool)GetValue(IsEditableProperty); }
set { SetValue(IsEditableProperty, value); }
}
public bool AllowHover {
get { return (bool)GetValue(AllowHoverProperty); }
set { SetValue(AllowHoverProperty, value); }
}



public static readonly DependencyProperty ItemsCountProperty =
DependencyProperty.Register("ItemsCount", typeof(Int32), typeof(RatingControl),
new PropertyMetadata(Int32.MinValue, ItemsCountChanged));
Expand All @@ -461,6 +466,8 @@ public bool IsEditable

public static readonly DependencyProperty IsEditableProperty =
DependencyProperty.Register("IsEditable", typeof(bool), typeof(RatingControl), null);
public static readonly DependencyProperty AllowHoverProperty =
DependencyProperty.Register("AllowHover", typeof(bool), typeof(RatingControl), null);

public static readonly DependencyProperty ItemTemplateProperty =
DependencyProperty.Register("ItemTemplate", typeof(Templates), typeof(RatingControl),
Expand Down Expand Up @@ -551,7 +558,7 @@ private static void DefinitionCyclesChanged(DependencyObject d, DependencyProper
#if NETFX_CORE
private void gridRating_PointerMoved(object sender, PointerRoutedEventArgs e)
{
if (IsEditable && IsEnabled && Visibility==Visibility.Visible && rateItems != null && rateItems.Children.Any())
if (IsEditable && (AllowHover || e.Pointer.IsInContact) && IsEnabled && Visibility==Visibility.Visible && rateItems != null && rateItems.Children.Any())
{
e.Handled = true;
System.Diagnostics.Debug.WriteLine("PointerMoved {0}", DateTime.Now);
Expand All @@ -566,7 +573,7 @@ private void gridRating_PointerMoved(object sender, PointerRoutedEventArgs e)
#if WINDOWS_PHONE
void RatingControl_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
{
if (IsEditable && IsEnabled && Visibility == Visibility.Visible && e != null && e.ManipulationOrigin != null)
if (IsEditable && AllowHover && IsEnabled && Visibility == Visibility.Visible && e != null && e.ManipulationOrigin != null)
{
e.Handled = true;
System.Diagnostics.Debug.WriteLine("ManipulationDelta {0} - {1}", DateTime.Now, e.ManipulationOrigin.X);
Expand Down

0 comments on commit 2f6181c

Please sign in to comment.