/// <summary> /// Set the enabled gestures. /// This method is called from the internal SetEnabledGestures method. /// </summary> private int SetEnabledGestures(MS.Win32.Recognizer.ContextSafeHandle recContext, ApplicationGesture[] enabledGestures) { Debug.Assert(recContext != null && !recContext.IsInvalid); // NOTICE-2005/01/11-WAYNEZEN, // The following usage was copied from drivers\tablet\recognition\ink\core\twister\src\wispapis.c // SetEnabledUnicodeRanges // Set ranges of gestures enabled in this recognition context // The behavior of this function is the following: // (a) (A part of) One of the requested ranges lies outside // gesture interval---currently [GESTURE_NULL, GESTURE_NULL + 255) // return E_UNEXPECTED and keep the previously set ranges // (b) All requested ranges are within the gesture interval but // some of them are not supported: // return S_TRUNCATED and set those requested gestures that are // supported (possibly an empty set) // (c) All requested gestures are supported // return S_OK and set all requested gestures. // Note: An easy way to set all supported gestures as enabled is to use // SetEnabledUnicodeRanges() with one range=(GESTURE_NULL,255). // Enabel gestures uint cRanges = (uint)(enabledGestures.Length); MS.Win32.Recognizer.CHARACTER_RANGE[] charRanges = new MS.Win32.Recognizer.CHARACTER_RANGE[cRanges]; if (cRanges == 1 && enabledGestures[0] == ApplicationGesture.AllGestures) { charRanges[0].cChars = MAX_GESTURE_COUNT; charRanges[0].wcLow = GESTURE_NULL; } else { for (int i = 0; i < cRanges; i++) { charRanges[i].cChars = 1; charRanges[i].wcLow = (ushort)(enabledGestures[i]); } } int hr = MS.Win32.Recognizer.UnsafeNativeMethods.SetEnabledUnicodeRanges(recContext, cRanges, charRanges); return(hr); }
private int SetEnabledGestures(MS.Win32.Recognizer.ContextSafeHandle recContext, ApplicationGesture[] enabledGestures) { Debug.Assert(recContext != null && !recContext.IsInvalid); // NOTICE-2005/01/11-WAYNEZEN, // The following usage was copied from drivers\tablet\recognition\ink\core\twister\src\wispapis.c // SetEnabledUnicodeRanges // Set ranges of gestures enabled in this recognition context // The behavior of this function is the following: // (a) (A part of) One of the requested ranges lies outside // gesture interval---currently [GESTURE_NULL, GESTURE_NULL + 255) // return E_UNEXPECTED and keep the previously set ranges // (b) All requested ranges are within the gesture interval but // some of them are not supported: // return S_TRUNCATED and set those requested gestures that are // supported (possibly an empty set) // (c) All requested gestures are supported // return S_OK and set all requested gestures. // Note: An easy way to set all supported gestures as enabled is to use // SetEnabledUnicodeRanges() with one range=(GESTURE_NULL,255). // Enabel gestures uint cRanges = (uint)( enabledGestures.Length ); MS.Win32.Recognizer.CHARACTER_RANGE[] charRanges = new MS.Win32.Recognizer.CHARACTER_RANGE[cRanges]; if ( cRanges == 1 && enabledGestures[0] == ApplicationGesture.AllGestures ) { charRanges[0].cChars = MAX_GESTURE_COUNT; charRanges[0].wcLow = GESTURE_NULL; } else { for ( int i = 0; i < cRanges; i++ ) { charRanges[i].cChars = 1; charRanges[i].wcLow = (ushort)( enabledGestures[i] ); } } int hr = MS.Win32.Recognizer.UnsafeNativeMethods.SetEnabledUnicodeRanges(recContext, cRanges, charRanges); return hr; }