コード例 #1
0
        internal PenContext[] CreateContexts(IntPtr hwnd, PenContexts contexts)
        {
            int c = Count + _deferredTablets.Count;

            PenContext[] ctxs = new PenContext[c];

            int i = 0;

            foreach (TabletDevice tablet in _tablets)
            {
                ctxs[i++] = tablet.CreateContext(hwnd, contexts);
            }

            // DevDiv:1078091
            // We need to re-enable contexts for anything that is marked
            // as a pending disposal.  This is so we continue getting any
            // Wisp messages that might be waiting to come over the shared
            // memory channel.
            foreach (TabletDevice tablet in _deferredTablets)
            {
                ctxs[i++] = tablet.CreateContext(hwnd, contexts);
            }

            return(ctxs);
        }
コード例 #2
0
ファイル: PenContext.cs プロジェクト: sjyanxin/WPFSource
 internal PenContext(IPimcContext pimcContext, IntPtr hwnd, 
                         PenContexts contexts, bool supportInRange, bool isIntegrated,
                         int id, IntPtr commHandle, int tabletDeviceId) 
 { 
     _contexts = contexts;
     _pimcContext = new SecurityCriticalDataClass<IPimcContext>(pimcContext); 
     _id = id;
     _tabletDeviceId = tabletDeviceId;
     _commHandle = new SecurityCriticalData<IntPtr>(commHandle);
     _hwnd = new SecurityCriticalData<IntPtr>(hwnd); 
     _supportInRange = supportInRange;
     _isIntegrated = isIntegrated; 
 } 
コード例 #3
0
 internal PenContext(IPimcContext2 pimcContext, IntPtr hwnd,
                     PenContexts contexts, bool supportInRange, bool isIntegrated,
                     int id, IntPtr commHandle, int tabletDeviceId)
 {
     _contexts       = contexts;
     _pimcContext    = new SecurityCriticalDataClass <IPimcContext2>(pimcContext);
     _id             = id;
     _tabletDeviceId = tabletDeviceId;
     _commHandle     = new SecurityCriticalData <IntPtr>(commHandle);
     _hwnd           = new SecurityCriticalData <IntPtr>(hwnd);
     _supportInRange = supportInRange;
     _isIntegrated   = isIntegrated;
     UpdateScreenMeasurementsPending = false;
 }
コード例 #4
0
        internal PenContext[] CreateContexts(IntPtr hwnd, PenContexts contexts)
        {
            int c = Count;

            PenContext[] ctxs = new PenContext[c];
            int          i    = 0;

            foreach (TabletDevice tablet in _tablets)
            {
                ctxs[i] = tablet.CreateContext(hwnd, contexts);
                i++;
            }
            return(ctxs);
        }
コード例 #5
0
        internal PenContext CreateContext(IntPtr hwnd, PenContexts contexts)
        {
            PenContext penContext;
            bool       supportInRange = (this.TabletHardwareCapabilities & TabletHardwareCapabilities.HardProximity) != 0;
            bool       isIntegrated   = (this.TabletHardwareCapabilities & TabletHardwareCapabilities.Integrated) != 0;

            // Use a PenThread to create a tablet context so we don't cause reentrancy.
            PenContextInfo result = _penThread.WorkerCreateContext(hwnd, _tabletInfo.PimcTablet.Value);

            penContext = new PenContext(result.PimcContext != null ? result.PimcContext.Value : null,
                                        hwnd, contexts,
                                        supportInRange, isIntegrated, result.ContextId,
                                        result.CommHandle != null ? result.CommHandle.Value : IntPtr.Zero,
                                        Id);
            return(penContext);
        }
コード例 #6
0
        private PresentationSource DetermineValidSource(PresentationSource inputSource, StylusPointCollection stylusPoints, PenContexts penContextsOfPoints)
        {
            HwndSource hwndSource = (HwndSource)inputSource;
            
            // See if window has been closed or is invalid
            if (inputSource.CompositionTarget == null || inputSource.CompositionTarget.IsDisposed ||
                hwndSource == null || hwndSource.IsHandleNull)
            {
                PresentationSource newSource = null;
                
                // use capture as fallback first
                if (_stylusCapture != null)
                {
                    DependencyObject containingVisual = InputElement.GetContainingVisual(_stylusCapture as DependencyObject);
                    PresentationSource capturedSource = PresentationSource.CriticalFromVisual(containingVisual);
                    
                    if (capturedSource != null && 
                        capturedSource.CompositionTarget != null &&
                        !capturedSource.CompositionTarget.IsDisposed)
                    {
                        newSource = capturedSource; // Good new source to use!
                    }
                }

                // Now try last screen point hittesting to find a new window/PresetationSource.
                if (newSource == null && stylusPoints != null)
                {
                    Point ptScreen;

                    // If we have the last penContext then we can remap the coordinates properly.
                    // Otherwise we just use the last stylus mouse location to figure out a PresenationSource.
                    if (penContextsOfPoints != null)
                    {
                        ptScreen = _stylusLogic.DeviceUnitsFromMeasureUnits((Point)stylusPoints[0]);
                        // map from window to screen (ie - add the window location).
                        ptScreen.Offset(penContextsOfPoints.DestroyedLocation.X, penContextsOfPoints.DestroyedLocation.Y);
                    }
                    else
                    {
                        ptScreen = _lastMouseScreenLocation;
                    }

                    IntPtr hwndHit = UnsafeNativeMethods.WindowFromPoint((int)ptScreen.X, (int)ptScreen.Y);
                    if (hwndHit != IntPtr.Zero)
                    {
                        HwndSource newHwndSource = HwndSource.CriticalFromHwnd(hwndHit);
                        if (newHwndSource != null && newHwndSource.Dispatcher == Dispatcher)
                        {
                            newSource = newHwndSource;
                        }
                    }
                }

                return newSource;
            }
            else
            {
                return inputSource;
            }
        }
コード例 #7
0
        internal PenContext CreateContext(IntPtr hwnd, PenContexts contexts)
        {
            PenContext penContext;
            bool supportInRange = (this.TabletHardwareCapabilities & TabletHardwareCapabilities.HardProximity) != 0;
            bool isIntegrated = (this.TabletHardwareCapabilities & TabletHardwareCapabilities.Integrated) != 0;

            // Use a PenThread to create a tablet context so we don't cause reentrancy.
            PenContextInfo result = _penThread.WorkerCreateContext(hwnd, _tabletInfo.PimcTablet.Value);

            penContext = new PenContext(result.PimcContext != null ? result.PimcContext.Value : null, 
                                        hwnd, contexts, 
                                        supportInRange, isIntegrated, result.ContextId,
                                        result.CommHandle != null ? result.CommHandle.Value : IntPtr.Zero, 
                                        Id);
            return penContext;
        }
コード例 #8
0
ファイル: TabletCollection.cs プロジェクト: JianwenSun/cc
 internal PenContext[] CreateContexts(IntPtr hwnd, PenContexts contexts)
 {
     int c = Count;
     PenContext[] ctxs = new PenContext[c];
     int i = 0;
     foreach (TabletDevice tablet in _tablets)
     {
         ctxs[i] = tablet.CreateContext(hwnd, contexts);
         i++;
     }
     return ctxs;
 }
コード例 #9
0
ファイル: StylusLogic.cs プロジェクト: sjyanxin/WPFSource
        internal void RegisterHwndForInput(InputManager inputManager, PresentationSource inputSource) 
        {
            HwndSource hwndSource = (HwndSource)inputSource; 
 
            // Query the transform from HwndTarget when the first window is created.
            if (!_transformInitialized) 
            {
                if (hwndSource != null && hwndSource.CompositionTarget != null)
                {
                    _transformToDevice = hwndSource.CompositionTarget.TransformToDevice; 
                    Debug.Assert(_transformToDevice.HasInverse);
                    _transformInitialized = true; 
                } 
            }
 
            // Keep track so we don't bother looking for changes if someone happened to query this before
            // an Avalon window was created where we get TabletAdd/Removed notification.
            bool initializedTablets = (_tabletDeviceCollection == null);
 
            // This causes EnableCore to be called on TabletPC systems which enabled stylus input!
            TabletDeviceCollection tablets = TabletDevices; 
 
            // Make sure that lock() does not cause reentrancy.
            using(Dispatcher.DisableProcessing()) 
            {
                lock (__penContextsLock)
                {
                    if (__penContextsMap.ContainsKey(inputSource)) 
                    {
                        throw new InvalidOperationException(SR.Get(SRID.PenService_WindowAlreadyRegistered)); 
                    } 

                    PenContexts penContexts = new PenContexts(inputManager.StylusLogic, inputSource); 

                    __penContextsMap[inputSource] = penContexts;

                    // If FIRST one set this as the one to manage TabletAdded/Removed notifications. 
                    if (__penContextsMap.Count == 1)
                    { 
                        // Make sure our view of TabletDevices is up to date we didn't just cause it 
                        // to be initialized and we had some real tablet devices.
                        if (!initializedTablets && tablets.Count > 0) 
                        {
                            tablets.UpdateTablets();
                        }
                    } 

                    // Detect if this window is disabled. If so then let the pencontexts know. 
                    int style = UnsafeNativeMethods.GetWindowLong(new HandleRef(this,hwndSource.CriticalHandle), NativeMethods.GWL_STYLE); 
                    if ((style & NativeMethods.WS_DISABLED) != 0)
                    { 
                        penContexts.IsWindowDisabled = true;
                    }

                    if ( _inputEnabled ) 
                        penContexts.Enable();
                } 
            } 
        }