Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Input / Stylus / StylusPlugin.cs / 1 / StylusPlugin.cs
// #define TRACE
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Specialized;
using System.Security.Permissions;
using System.Windows.Threading;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using MS.Win32; // for *NativeMethods
namespace System.Windows.Input.StylusPlugIns
{
/////////////////////////////////////////////////////////////////////
///
/// [TBS]
///
public abstract class StylusPlugIn
{
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected StylusPlugIn()
{
}
/////////////////////////////////////////////////////////////////////
// (in Dispatcher)
internal void Added(StylusPlugInCollection plugInCollection)
{
_pic = plugInCollection;
OnAdded();
InvalidateIsActiveForInput(); // Make sure we fire OnIsActivateForInputChanged.
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected virtual void OnAdded()
{
}
/////////////////////////////////////////////////////////////////////
// (in Dispatcher)
internal void Removed()
{
// Make sure we fire OnIsActivateForInputChanged if we need to.
if (_activeForInput)
{
InvalidateIsActiveForInput();
}
OnRemoved();
_pic = null;
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected virtual void OnRemoved()
{
}
/////////////////////////////////////////////////////////////////////
// (in RTI Dispatcher)
internal void StylusEnterLeave(bool isEnter, RawStylusInput rawStylusInput, bool confirmed)
{
// Only fire if plugin is enabled and hooked up to plugincollection.
if (__enabled && _pic != null)
{
if (isEnter)
OnStylusEnter(rawStylusInput, confirmed);
else
OnStylusLeave(rawStylusInput, confirmed);
}
}
/////////////////////////////////////////////////////////////////////
// (in RTI Dispatcher)
internal void RawStylusInput(RawStylusInput rawStylusInput)
{
// Only fire if plugin is enabled and hooked up to plugincollection.
if (__enabled && _pic != null)
{
switch( rawStylusInput.Report.Actions )
{
case RawStylusActions.Down:
OnStylusDown(rawStylusInput);
break;
case RawStylusActions.Move:
OnStylusMove(rawStylusInput);
break;
case RawStylusActions.Up:
OnStylusUp(rawStylusInput);
break;
}
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusEnter(RawStylusInput rawStylusInput, bool confirmed)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusLeave(RawStylusInput rawStylusInput, bool confirmed)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusDown(RawStylusInput rawStylusInput)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusMove(RawStylusInput rawStylusInput)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusUp(RawStylusInput rawStylusInput)
{
}
/////////////////////////////////////////////////////////////////////
// (on app Dispatcher)
internal void FireCustomData(object callbackData,
RawStylusActions action,
bool targetVerified)
{
// Only fire if plugin is enabled and hooked up to plugincollection.
if (__enabled && _pic != null)
{
switch (action)
{
case RawStylusActions.Down:
OnStylusDownProcessed(callbackData, targetVerified);
break;
case RawStylusActions.Move:
OnStylusMoveProcessed(callbackData, targetVerified);
break;
case RawStylusActions.Up:
OnStylusUpProcessed(callbackData, targetVerified);
break;
}
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnStylusDownProcessed(object callbackData, bool targetVerified)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnStylusMoveProcessed(object callbackData, bool targetVerified)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnStylusUpProcessed(object callbackData, bool targetVerified)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - both Dispatchers
///
public UIElement Element
{
get
{
return (_pic != null) ? _pic.Element : null;
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - both Dispatchers
///
public Rect ElementBounds
{
get
{
return (_pic != null) ? _pic.Rect : new Rect();
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - get - both Dispatchers, set Dispatcher
///
public bool Enabled
{
get // both Dispatchers
{
return __enabled;
}
set // on Dispatcher
{
// Verify we are on the proper thread.
if (_pic != null)
{
_pic.Element.VerifyAccess();
}
if (value != __enabled)
{
// If we are currently active for input we need to lock before input before
// changing so we don't get input coming in before event is fired.
if (_pic != null && _pic.IsActiveForInput)
{
// Make sure lock() doesn't cause reentrancy.
using(_pic.Element.Dispatcher.DisableProcessing())
{
lock(_pic.PenContextsSyncRoot)
{
// Make sure we fire the OnEnabledChanged event in the proper order
// depending on whether we are going active or inactive so you don't
// get input events after going inactive or before going active.
__enabled = value;
if (value == false)
{
// Make sure we fire OnIsActivateForInputChanged if we need to.
InvalidateIsActiveForInput();
OnEnabledChanged();
}
else
{
OnEnabledChanged();
InvalidateIsActiveForInput();
}
}
}
}
else
{
__enabled = value;
if (value == false)
{
// Make sure we fire OnIsActivateForInputChanged if we need to.
InvalidateIsActiveForInput();
OnEnabledChanged();
}
else
{
OnEnabledChanged();
InvalidateIsActiveForInput();
}
}
}
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnEnabledChanged()
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - app Dispatcher
///
internal void InvalidateIsActiveForInput()
{
bool newIsActive = (_pic != null) ? (Enabled && _pic.Contains(this) &&
_pic.IsActiveForInput) : false;
if (newIsActive != _activeForInput)
{
_activeForInput = newIsActive;
OnIsActiveForInputChanged();
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - get - both Dispatchers
///
public bool IsActiveForInput
{
get // both Dispatchers
{
return _activeForInput;
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected virtual void OnIsActiveForInputChanged()
{
}
// Enabled state is local to this plugin so we just use volatile versus creating a lock
// around it since we just read it from multiple thread and write from one.
volatile bool __enabled = true;
bool _activeForInput = false;
StylusPlugInCollection _pic = null;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
// #define TRACE
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Specialized;
using System.Security.Permissions;
using System.Windows.Threading;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using MS.Win32; // for *NativeMethods
namespace System.Windows.Input.StylusPlugIns
{
/////////////////////////////////////////////////////////////////////
///
/// [TBS]
///
public abstract class StylusPlugIn
{
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected StylusPlugIn()
{
}
/////////////////////////////////////////////////////////////////////
// (in Dispatcher)
internal void Added(StylusPlugInCollection plugInCollection)
{
_pic = plugInCollection;
OnAdded();
InvalidateIsActiveForInput(); // Make sure we fire OnIsActivateForInputChanged.
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected virtual void OnAdded()
{
}
/////////////////////////////////////////////////////////////////////
// (in Dispatcher)
internal void Removed()
{
// Make sure we fire OnIsActivateForInputChanged if we need to.
if (_activeForInput)
{
InvalidateIsActiveForInput();
}
OnRemoved();
_pic = null;
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected virtual void OnRemoved()
{
}
/////////////////////////////////////////////////////////////////////
// (in RTI Dispatcher)
internal void StylusEnterLeave(bool isEnter, RawStylusInput rawStylusInput, bool confirmed)
{
// Only fire if plugin is enabled and hooked up to plugincollection.
if (__enabled && _pic != null)
{
if (isEnter)
OnStylusEnter(rawStylusInput, confirmed);
else
OnStylusLeave(rawStylusInput, confirmed);
}
}
/////////////////////////////////////////////////////////////////////
// (in RTI Dispatcher)
internal void RawStylusInput(RawStylusInput rawStylusInput)
{
// Only fire if plugin is enabled and hooked up to plugincollection.
if (__enabled && _pic != null)
{
switch( rawStylusInput.Report.Actions )
{
case RawStylusActions.Down:
OnStylusDown(rawStylusInput);
break;
case RawStylusActions.Move:
OnStylusMove(rawStylusInput);
break;
case RawStylusActions.Up:
OnStylusUp(rawStylusInput);
break;
}
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusEnter(RawStylusInput rawStylusInput, bool confirmed)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusLeave(RawStylusInput rawStylusInput, bool confirmed)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusDown(RawStylusInput rawStylusInput)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusMove(RawStylusInput rawStylusInput)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on RTI Dispatcher
///
protected virtual void OnStylusUp(RawStylusInput rawStylusInput)
{
}
/////////////////////////////////////////////////////////////////////
// (on app Dispatcher)
internal void FireCustomData(object callbackData,
RawStylusActions action,
bool targetVerified)
{
// Only fire if plugin is enabled and hooked up to plugincollection.
if (__enabled && _pic != null)
{
switch (action)
{
case RawStylusActions.Down:
OnStylusDownProcessed(callbackData, targetVerified);
break;
case RawStylusActions.Move:
OnStylusMoveProcessed(callbackData, targetVerified);
break;
case RawStylusActions.Up:
OnStylusUpProcessed(callbackData, targetVerified);
break;
}
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnStylusDownProcessed(object callbackData, bool targetVerified)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnStylusMoveProcessed(object callbackData, bool targetVerified)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnStylusUpProcessed(object callbackData, bool targetVerified)
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - both Dispatchers
///
public UIElement Element
{
get
{
return (_pic != null) ? _pic.Element : null;
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - both Dispatchers
///
public Rect ElementBounds
{
get
{
return (_pic != null) ? _pic.Rect : new Rect();
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - get - both Dispatchers, set Dispatcher
///
public bool Enabled
{
get // both Dispatchers
{
return __enabled;
}
set // on Dispatcher
{
// Verify we are on the proper thread.
if (_pic != null)
{
_pic.Element.VerifyAccess();
}
if (value != __enabled)
{
// If we are currently active for input we need to lock before input before
// changing so we don't get input coming in before event is fired.
if (_pic != null && _pic.IsActiveForInput)
{
// Make sure lock() doesn't cause reentrancy.
using(_pic.Element.Dispatcher.DisableProcessing())
{
lock(_pic.PenContextsSyncRoot)
{
// Make sure we fire the OnEnabledChanged event in the proper order
// depending on whether we are going active or inactive so you don't
// get input events after going inactive or before going active.
__enabled = value;
if (value == false)
{
// Make sure we fire OnIsActivateForInputChanged if we need to.
InvalidateIsActiveForInput();
OnEnabledChanged();
}
else
{
OnEnabledChanged();
InvalidateIsActiveForInput();
}
}
}
}
else
{
__enabled = value;
if (value == false)
{
// Make sure we fire OnIsActivateForInputChanged if we need to.
InvalidateIsActiveForInput();
OnEnabledChanged();
}
else
{
OnEnabledChanged();
InvalidateIsActiveForInput();
}
}
}
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on app Dispatcher
///
protected virtual void OnEnabledChanged()
{
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - app Dispatcher
///
internal void InvalidateIsActiveForInput()
{
bool newIsActive = (_pic != null) ? (Enabled && _pic.Contains(this) &&
_pic.IsActiveForInput) : false;
if (newIsActive != _activeForInput)
{
_activeForInput = newIsActive;
OnIsActiveForInputChanged();
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - get - both Dispatchers
///
public bool IsActiveForInput
{
get // both Dispatchers
{
return _activeForInput;
}
}
/////////////////////////////////////////////////////////////////////
///
/// [TBS] - on Dispatcher
///
protected virtual void OnIsActiveForInputChanged()
{
}
// Enabled state is local to this plugin so we just use volatile versus creating a lock
// around it since we just read it from multiple thread and write from one.
volatile bool __enabled = true;
bool _activeForInput = false;
StylusPlugInCollection _pic = null;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BamlRecordHelper.cs
- WebPartZoneAutoFormat.cs
- EntityContainerEntitySet.cs
- MissingSatelliteAssemblyException.cs
- DataRecordInternal.cs
- ShimAsPublicXamlType.cs
- EventLogEntry.cs
- ReachPageContentSerializer.cs
- XmlElementList.cs
- Visitor.cs
- HostUtils.cs
- PersonalizationProvider.cs
- ObjectDataSourceSelectingEventArgs.cs
- NameGenerator.cs
- PagesSection.cs
- MediaPlayerState.cs
- Stylus.cs
- WrappedReader.cs
- Point3DAnimationBase.cs
- DocumentApplication.cs
- HandleExceptionArgs.cs
- ConfigurationStrings.cs
- ColorAnimation.cs
- Comparer.cs
- EnumBuilder.cs
- SqlBulkCopyColumnMapping.cs
- fixedPageContentExtractor.cs
- TypeFieldSchema.cs
- WebPartEditorCancelVerb.cs
- Attributes.cs
- XmlDictionaryReaderQuotas.cs
- TaskHelper.cs
- XPathNodePointer.cs
- WebSysDefaultValueAttribute.cs
- EditingScope.cs
- AdornerHitTestResult.cs
- RIPEMD160.cs
- SingleTagSectionHandler.cs
- ClientTargetSection.cs
- ThreadExceptionEvent.cs
- StatusStrip.cs
- TextServicesDisplayAttribute.cs
- GACMembershipCondition.cs
- VirtualDirectoryMappingCollection.cs
- WebEventCodes.cs
- ColorTranslator.cs
- WindowsStatic.cs
- SelectionProcessor.cs
- regiisutil.cs
- TextMetrics.cs
- Table.cs
- ExpressionList.cs
- TrustLevelCollection.cs
- Visitors.cs
- SQLInt16.cs
- Substitution.cs
- BuildProviderUtils.cs
- BuiltInExpr.cs
- XmlRawWriter.cs
- DataGridPageChangedEventArgs.cs
- ListItem.cs
- TokenizerHelper.cs
- WebPartMinimizeVerb.cs
- SecurityChannel.cs
- ZipQueryOperator.cs
- Claim.cs
- FreezableOperations.cs
- PasswordRecovery.cs
- Menu.cs
- Crc32.cs
- NativeMethods.cs
- PageParserFilter.cs
- SpecularMaterial.cs
- Reference.cs
- HandlerBase.cs
- _OverlappedAsyncResult.cs
- StylusLogic.cs
- BCLDebug.cs
- ImmutablePropertyDescriptorGridEntry.cs
- RuntimeWrappedException.cs
- AudioFormatConverter.cs
- Pool.cs
- OleDbCommandBuilder.cs
- LinkLabelLinkClickedEvent.cs
- HttpValueCollection.cs
- ExternalCalls.cs
- MediaPlayer.cs
- DataPagerFieldItem.cs
- validationstate.cs
- KeyedHashAlgorithm.cs
- NodeFunctions.cs
- ScrollViewerAutomationPeer.cs
- XmlNodeChangedEventManager.cs
- GcSettings.cs
- BaseProcessor.cs
- TimeoutValidationAttribute.cs
- ToolStripItemTextRenderEventArgs.cs
- StickyNoteHelper.cs
- SignedXmlDebugLog.cs
- ArgumentsParser.cs