Identifying a Mouse
With the MultiPoint Mouse SDK, you can identify which mouse clicked a button and then display that mouse pointer ID on the button.
To identify the mouse that clicked the button
-
Get an instance of the button that was clicked.
-
Cast the “sender” object to a MultipointButton, as follows:
MultipointButton btn = (MultipointButton)sender; -
To see information about the mouse device that was clicked, cast the RoutedEventArgs to a MultipointMouseEventArgs as follows:
MultipointMouseEventArgs multipointargs = e as MultipointMouseEventArgs;The as operator is used here to prevent InvalidCastExceptions if the cast fails.
-
Test that multipointargs is not null before you perform the required action, as follows:
if (multipointargs != null) { // perform required action } -
To determine which mouse was clicked, view the Id property in the DeviceInfo object. You can output this information to the button as follows:
mpButton.Content = String.Format("Mouse #{0} Clicked me", multipointargs.DeviceInfo.Id);