Adding or Removing a Mouse

You can add support to your application to add or remove a mouse device when your application is running. The MultiPoint Mouse SDK exposes events that are raised when devices are added and removed that you can use to assign different pointers to each mouse device that is connected.

To Handle a New Mouse

  1. Declare a handler for the device arrival event. This should be declared when the application is initialized, either in the constructor or in the Window.Loaded event handler for the main application window. For example:

    MultipointSdk.Instance.DeviceArrivalEvent += 
        MultipointDeviceArrivalEvent;
    
  2. Set up the event handler function to trigger the following event:

    private void MultipointDeviceArrivalEvent(object sender, DeviceNotifyEventArgs e)
    {
        // add code to handle the arrival of the device here
    }
    
  3. Assign a pointer to the new mouse device. For example:

    e.DeviceInfo.DeviceVisual.CursorBitmap = bitmap;

For a complete example of how to manage pointers and assign them to new mouse devices, see the sample located at Microsoft.Multipoint.Sdk.Samples.Common\CursorAssignments.cs.

You can handle the removal of a mouse device in your code by using the DeviceRemoveCompleteEvent handler. However, the SDK automatically removes the mouse and its associated pointer when the mouse is disconnected. If you do not want to perform any custom operations when a mouse device is removed, you can safely omit this step.