Skip to content

Commit

Permalink
New pointer events handler API
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Dec 21, 2018
1 parent 639fce8 commit baf520f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
14 changes: 14 additions & 0 deletions UICompositionAnimations/Helpers/PointerEvents/PointerHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Windows.Devices.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
Expand Down Expand Up @@ -63,6 +64,19 @@ public static ControlAttachedHandlersInfo ManageLightsPointerStates([NotNull] th
});
}

/// <summary>
/// Adds an event handler to the specified <see cref="RoutedEvent"/> events of the input <see cref="UIElement"/>
/// </summary>
/// <param name="control">The <see cref="UIElement"/> to monitor</param>
/// <param name="action">An <see cref="Action"/> to call every time a <see cref="RoutedEvent"/> is raised. The <see cref="bool"/> parameter indicates whether the pointer is moving to or from the control</param>
/// <param name="events">The list of <see cref="RoutedEvent"/> to monitor</param>
[NotNull]
public static ControlAttachedHandlersInfo ManageControlPointerStates([NotNull] this UIElement control, [NotNull] Action<PointerDeviceType, bool> action, [NotNull] params (RoutedEvent Event, bool State)[] events)
{
if (events.Length == 0) throw new ArgumentException("The list of events can't be empty", nameof(events));
return new ControlAttachedHandlersInfo(control, events.ToDictionary(t => t.Event, t => t.State).Select(p => AddHandler(control, p.Key, p.Value, null, action)).ToArray());
}

// Private method that adds a custom handler to the target event and control
[NotNull]
private static PointerHandlerInfo AddHandler([NotNull] UIElement element, [NotNull] RoutedEvent @event, bool state, [CanBeNull] Func<PointerDeviceType, bool> predicate, [NotNull] Action<PointerDeviceType, bool> action)
Expand Down
6 changes: 3 additions & 3 deletions UICompositionAnimations/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.0.0")]
[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyInformationalVersion("3.0.1")]
[assembly: ComVisible(false)]

4 changes: 2 additions & 2 deletions UICompositionAnimations/UICompositionAnimations.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package>
<metadata>
<id>UICompositionAnimations</id>
<version>3.0.0</version>
<version>3.0.1</version>
<title>UICompositionAnimations</title>
<description>A wrapper UWP PCL to work with Windows.UI.Composition and XAML animations, and Win2D effects</description>
<authors>Sergio Pedri</authors>
<owners>Sergio Pedri</owners>
<projectUrl>https://github.com/Sergio0694/UICompositionAnimations</projectUrl>
<licenseUrl>https://github.com/Sergio0694/UICompositionAnimations/blob/master/LICENSE.md</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>Retargeted to support SDK 17134, new APIs and code refactoring</releaseNotes>
<releaseNotes>Added new pointer events handling APIs</releaseNotes>
<copyright>Copyright © 2018</copyright>
<tags>uwp composition animations xaml csharp windows winrt universal app ui win2d graphics</tags>
<dependencies>
Expand Down

0 comments on commit baf520f

Please sign in to comment.