Beispiel #1
0
 internal static void ReleaseAllCaptures(IInputElement element)
 {
     if (_activeDevices != null)
     {
         int count = _activeDevices.Count;
         for (int i = 0; i < count; i++)
         {
             TouchDevice device = _activeDevices[i];
             if (device.Captured == element)
             {
                 device.Capture(null);
             }
         }
     }
 }
Beispiel #2
0
 private void OnReevaluateCapture(object sender, DependencyPropertyChangedEventArgs e)
 {
     // IsEnabled, IsVisible, and/or IsHitTestVisible became false
     if (!(bool)e.NewValue)
     {
         if (_reevaluateCapture == null)
         {
             _reevaluateCapture = Dispatcher.BeginInvoke(DispatcherPriority.Input,
                                                         (DispatcherOperationCallback) delegate(object args)
             {
                 TouchDevice thisRef        = (TouchDevice)args;
                 thisRef._reevaluateCapture = null;
                 thisRef.Capture(null);
                 return(null);
             }, this);
         }
     }
 }
        /// <summary>
        ///     Releases capture from the specified touch device.
        /// </summary>
        /// <param name="touchDevice">The device that is captured to this element.</param>
        /// <returns>true if capture was released, false otherwise.</returns>
        public bool ReleaseTouchCapture(TouchDevice touchDevice)
        {
            if (touchDevice == null)
            {
                throw new ArgumentNullException("touchDevice");
            }

            if (touchDevice.Captured == this)
            {
                touchDevice.Capture(null);
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        ///     Captures the specified device to this element.
        /// </summary>
        /// <param name="touchDevice">The touch device to capture.</param>
        /// <returns>True if capture was taken.</returns>
        public bool CaptureTouch(TouchDevice touchDevice)
        {
            if (touchDevice == null)
            {
                throw new ArgumentNullException("touchDevice");
            }

            return touchDevice.Capture(this);
        }