Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / Stylus / RawStylusInputReport.cs / 1305600 / RawStylusInputReport.cs
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Threading;
using System.Windows.Media;
using System.Windows.Input.StylusPlugIns;
using System.Security;
using System.Security.Permissions;
using MS.Internal.PresentationCore; // SecurityHelper
using MS.Internal;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows.Input
{
/////////////////////////////////////////////////////////////////////////
///
/// The RawStylusInputReport class encapsulates the raw input provided
/// from a stylus.
///
///
/// It is important to note that the InputReport class only contains
/// blittable types. This is required so that the report can be
/// marshalled across application domains.
///
internal class RawStylusInputReport : InputReport
{
/////////////////////////////////////////////////////////////////////
///
/// Constructs an instance of the RawStylusInputReport class.
///
///
/// The mode in which the input is being provided.
///
///
/// The time when the input occured.
///
///
/// The PresentationSource over which the stylus moved.
///
///
/// The PenContext.
///
///
/// The set of actions being reported.
///
///
/// Tablet device id.
///
///
/// Stylus device id.
///
///
/// Raw stylus data.
///
///
/// Critical: This handles critical data in the form of PresentationSource.
/// TreatAsSafe:There are demands on the critical data(PresentationSource)
///
[SecurityCritical,SecurityTreatAsSafe]
internal RawStylusInputReport(
InputMode mode,
int timestamp,
PresentationSource inputSource,
PenContext penContext,
RawStylusActions actions,
int tabletDeviceId,
int stylusDeviceId,
int[] data)
: base(inputSource, InputType.Stylus, mode, timestamp)
{
// Validate parameters
if (!RawStylusActionsHelper.IsValid(actions))
{
throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "actions"));
}
if (data == null && actions != RawStylusActions.InRange)
{
throw new ArgumentNullException("data");
}
_penContext = new SecurityCriticalDataClass(penContext);
_actions = actions;
_tabletDeviceId = tabletDeviceId;
_stylusDeviceId = stylusDeviceId;
_data = data;
_isSynchronize = false;
}
/////////////////////////////////////////////////////////////////////
///
/// Constructs an instance of the RawStylusInputReport class.
///
///
/// The mode in which the input is being provided.
///
///
/// The time when the input occured.
///
///
/// The PresentationSource over which the stylus moved.
///
///
/// The set of actions being reported.
///
///
/// Raw stylus data StylusPointDescription.
///
///
/// Raw stylus data.
///
///
/// Critical: This handles critical data in the form of PresentationSource.
/// TreatAsSafe:There are demands on the critical data(PresentationSource)
///
[SecurityCritical,SecurityTreatAsSafe]
internal RawStylusInputReport(
InputMode mode,
int timestamp,
PresentationSource inputSource,
RawStylusActions actions,
StylusPointDescription mousePointDescription,
int[] mouseData)
: base(inputSource, InputType.Stylus, mode, timestamp)
{
// Validate parameters
if (!RawStylusActionsHelper.IsValid(actions))
{
throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "actions"));
}
if (mouseData == null)
{
throw new ArgumentNullException("mouseData");
}
_penContext = new SecurityCriticalDataClass(null);
_actions = actions;
_tabletDeviceId = 0;
_stylusDeviceId = 0;
_data = mouseData;
_isSynchronize = false;
_mousePointDescription = mousePointDescription;
_isMouseInput = true;
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to the set of actions that were reported.
///
internal RawStylusActions Actions { get { return _actions; } }
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus context id that reported the data.
///
internal int TabletDeviceId { get { return _tabletDeviceId; } }
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus context id that reported the data.
///
///
/// Critical: provides access to critical member _penContext
///
internal PenContext PenContext
{
[SecurityCritical]
get { return _penContext.Value; }
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus context id that reported the data.
///
///
/// Critical: This handles critical data _penContext
/// TreatAsSafe: We're returning safe data
///
internal StylusPointDescription StylusPointDescription
{
[SecurityCritical, SecurityTreatAsSafe]
get { return _isMouseInput ? _mousePointDescription : _penContext.Value.StylusPointDescription; }
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus device id that reported the data.
///
internal int StylusDeviceId { get { return _stylusDeviceId; } }
/////////////////////////////////////////////////////////////////////
internal StylusDevice StylusDevice
{
get { return _stylusDevice; }
set { _stylusDevice = value; }
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to the raw data that was reported.
///
///
/// Critical: Access the critical field - _data
/// TreatAsSafe: No input is taken. It's safe to a clone.
///
[SecurityCritical, SecurityTreatAsSafe]
internal int[] GetRawPacketData()
{
if (_data == null)
return null;
return (int[])_data.Clone();
}
/////////////////////////////////////////////////////////////////////
///
/// Critical: Access the critical field - _data
/// TreatAsSafe: No input is taken. It's safe to return the last tablet point.
///
[SecurityCritical, SecurityTreatAsSafe]
internal Point GetLastTabletPoint()
{
int packetLength = StylusPointDescription.GetInputArrayLengthPerPoint();
int lastXIndex = _data.Length - packetLength;
return new Point(_data[lastXIndex], _data[lastXIndex + 1]);
}
/////////////////////////////////////////////////////////////////////
///
/// Critical - Hands out ref to internal data that can be used to spoof input.
///
internal int[] Data
{
[SecurityCritical]
get { return _data; }
}
/////////////////////////////////////////////////////////////////////
///
/// Critical - Setting property can be used to spoof input.
///
internal RawStylusInput RawStylusInput
{
get { return _rawStylusInput.Value; }
[SecurityCritical]
set { _rawStylusInput.Value = value; }
}
/////////////////////////////////////////////////////////////////////
internal bool Synchronized
{
get { return _isSynchronize; }
set { _isSynchronize = value; }
}
/////////////////////////////////////////////////////////////////////
RawStylusActions _actions;
int _tabletDeviceId;
///
/// Critical: Marked critical to prevent inadvertant spread to transparent code
///
private SecurityCriticalDataClass _penContext;
int _stylusDeviceId;
///
/// Critical to prevent accidental spread to transparent code
///
[SecurityCritical]
int[] _data;
StylusDevice _stylusDevice; // cached value looked up from _stylusDeviceId
SecurityCriticalDataForSet _rawStylusInput;
bool _isSynchronize; // Set from StylusDevice.Synchronize.
bool _isMouseInput; // Special case of mouse input being sent to plugins
StylusPointDescription _mousePointDescription; // layout for mouse points
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Threading;
using System.Windows.Media;
using System.Windows.Input.StylusPlugIns;
using System.Security;
using System.Security.Permissions;
using MS.Internal.PresentationCore; // SecurityHelper
using MS.Internal;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows.Input
{
/////////////////////////////////////////////////////////////////////////
///
/// The RawStylusInputReport class encapsulates the raw input provided
/// from a stylus.
///
///
/// It is important to note that the InputReport class only contains
/// blittable types. This is required so that the report can be
/// marshalled across application domains.
///
internal class RawStylusInputReport : InputReport
{
/////////////////////////////////////////////////////////////////////
///
/// Constructs an instance of the RawStylusInputReport class.
///
///
/// The mode in which the input is being provided.
///
///
/// The time when the input occured.
///
///
/// The PresentationSource over which the stylus moved.
///
///
/// The PenContext.
///
///
/// The set of actions being reported.
///
///
/// Tablet device id.
///
///
/// Stylus device id.
///
///
/// Raw stylus data.
///
///
/// Critical: This handles critical data in the form of PresentationSource.
/// TreatAsSafe:There are demands on the critical data(PresentationSource)
///
[SecurityCritical,SecurityTreatAsSafe]
internal RawStylusInputReport(
InputMode mode,
int timestamp,
PresentationSource inputSource,
PenContext penContext,
RawStylusActions actions,
int tabletDeviceId,
int stylusDeviceId,
int[] data)
: base(inputSource, InputType.Stylus, mode, timestamp)
{
// Validate parameters
if (!RawStylusActionsHelper.IsValid(actions))
{
throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "actions"));
}
if (data == null && actions != RawStylusActions.InRange)
{
throw new ArgumentNullException("data");
}
_penContext = new SecurityCriticalDataClass(penContext);
_actions = actions;
_tabletDeviceId = tabletDeviceId;
_stylusDeviceId = stylusDeviceId;
_data = data;
_isSynchronize = false;
}
/////////////////////////////////////////////////////////////////////
///
/// Constructs an instance of the RawStylusInputReport class.
///
///
/// The mode in which the input is being provided.
///
///
/// The time when the input occured.
///
///
/// The PresentationSource over which the stylus moved.
///
///
/// The set of actions being reported.
///
///
/// Raw stylus data StylusPointDescription.
///
///
/// Raw stylus data.
///
///
/// Critical: This handles critical data in the form of PresentationSource.
/// TreatAsSafe:There are demands on the critical data(PresentationSource)
///
[SecurityCritical,SecurityTreatAsSafe]
internal RawStylusInputReport(
InputMode mode,
int timestamp,
PresentationSource inputSource,
RawStylusActions actions,
StylusPointDescription mousePointDescription,
int[] mouseData)
: base(inputSource, InputType.Stylus, mode, timestamp)
{
// Validate parameters
if (!RawStylusActionsHelper.IsValid(actions))
{
throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "actions"));
}
if (mouseData == null)
{
throw new ArgumentNullException("mouseData");
}
_penContext = new SecurityCriticalDataClass(null);
_actions = actions;
_tabletDeviceId = 0;
_stylusDeviceId = 0;
_data = mouseData;
_isSynchronize = false;
_mousePointDescription = mousePointDescription;
_isMouseInput = true;
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to the set of actions that were reported.
///
internal RawStylusActions Actions { get { return _actions; } }
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus context id that reported the data.
///
internal int TabletDeviceId { get { return _tabletDeviceId; } }
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus context id that reported the data.
///
///
/// Critical: provides access to critical member _penContext
///
internal PenContext PenContext
{
[SecurityCritical]
get { return _penContext.Value; }
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus context id that reported the data.
///
///
/// Critical: This handles critical data _penContext
/// TreatAsSafe: We're returning safe data
///
internal StylusPointDescription StylusPointDescription
{
[SecurityCritical, SecurityTreatAsSafe]
get { return _isMouseInput ? _mousePointDescription : _penContext.Value.StylusPointDescription; }
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to stylus device id that reported the data.
///
internal int StylusDeviceId { get { return _stylusDeviceId; } }
/////////////////////////////////////////////////////////////////////
internal StylusDevice StylusDevice
{
get { return _stylusDevice; }
set { _stylusDevice = value; }
}
/////////////////////////////////////////////////////////////////////
///
/// Read-only access to the raw data that was reported.
///
///
/// Critical: Access the critical field - _data
/// TreatAsSafe: No input is taken. It's safe to a clone.
///
[SecurityCritical, SecurityTreatAsSafe]
internal int[] GetRawPacketData()
{
if (_data == null)
return null;
return (int[])_data.Clone();
}
/////////////////////////////////////////////////////////////////////
///
/// Critical: Access the critical field - _data
/// TreatAsSafe: No input is taken. It's safe to return the last tablet point.
///
[SecurityCritical, SecurityTreatAsSafe]
internal Point GetLastTabletPoint()
{
int packetLength = StylusPointDescription.GetInputArrayLengthPerPoint();
int lastXIndex = _data.Length - packetLength;
return new Point(_data[lastXIndex], _data[lastXIndex + 1]);
}
/////////////////////////////////////////////////////////////////////
///
/// Critical - Hands out ref to internal data that can be used to spoof input.
///
internal int[] Data
{
[SecurityCritical]
get { return _data; }
}
/////////////////////////////////////////////////////////////////////
///
/// Critical - Setting property can be used to spoof input.
///
internal RawStylusInput RawStylusInput
{
get { return _rawStylusInput.Value; }
[SecurityCritical]
set { _rawStylusInput.Value = value; }
}
/////////////////////////////////////////////////////////////////////
internal bool Synchronized
{
get { return _isSynchronize; }
set { _isSynchronize = value; }
}
/////////////////////////////////////////////////////////////////////
RawStylusActions _actions;
int _tabletDeviceId;
///
/// Critical: Marked critical to prevent inadvertant spread to transparent code
///
private SecurityCriticalDataClass _penContext;
int _stylusDeviceId;
///
/// Critical to prevent accidental spread to transparent code
///
[SecurityCritical]
int[] _data;
StylusDevice _stylusDevice; // cached value looked up from _stylusDeviceId
SecurityCriticalDataForSet _rawStylusInput;
bool _isSynchronize; // Set from StylusDevice.Synchronize.
bool _isMouseInput; // Special case of mouse input being sent to plugins
StylusPointDescription _mousePointDescription; // layout for mouse points
}
}
// 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
- OleDbDataReader.cs
- ThousandthOfEmRealDoubles.cs
- TableCellsCollectionEditor.cs
- LineServicesCallbacks.cs
- MsmqHostedTransportConfiguration.cs
- _TLSstream.cs
- CodeExporter.cs
- ReversePositionQuery.cs
- WsdlInspector.cs
- ComboBox.cs
- TableHeaderCell.cs
- AttachedProperty.cs
- VoiceInfo.cs
- PrefixHandle.cs
- XsltContext.cs
- ContentFileHelper.cs
- SQlBooleanStorage.cs
- OneOfConst.cs
- AlternateView.cs
- HtmlTableRowCollection.cs
- GeometryValueSerializer.cs
- FixedTextBuilder.cs
- OleDbDataReader.cs
- AttributeProviderAttribute.cs
- ResourceReader.cs
- PathSegment.cs
- oledbmetadatacolumnnames.cs
- InvalidWMPVersionException.cs
- ReaderContextStackData.cs
- XmlProcessingInstruction.cs
- GridViewRowEventArgs.cs
- ColorMatrix.cs
- RegexCapture.cs
- CollectionBuilder.cs
- Collection.cs
- XmlCompatibilityReader.cs
- DictionaryBase.cs
- CharacterMetrics.cs
- URLIdentityPermission.cs
- CompoundFileIOPermission.cs
- VScrollBar.cs
- BlockUIContainer.cs
- TraceListener.cs
- ToolboxService.cs
- DynamicDataExtensions.cs
- ChainedAsyncResult.cs
- ObjectListCommandCollection.cs
- SecondaryViewProvider.cs
- XmlDocumentFragment.cs
- DataServiceEntityAttribute.cs
- SessionStateModule.cs
- LOSFormatter.cs
- AppSettingsReader.cs
- PnrpPeerResolverElement.cs
- DispatcherProcessingDisabled.cs
- NegatedConstant.cs
- PrePrepareMethodAttribute.cs
- Int32Rect.cs
- TransformedBitmap.cs
- BmpBitmapDecoder.cs
- TextBoxRenderer.cs
- JsonStringDataContract.cs
- DataSourceDescriptorCollection.cs
- HttpInputStream.cs
- ListItemParagraph.cs
- SqlWriter.cs
- WebRequestModuleElement.cs
- SchemaNamespaceManager.cs
- GreenMethods.cs
- ChtmlLinkAdapter.cs
- DefaultWorkflowTransactionService.cs
- ConnectionManager.cs
- HostingEnvironmentSection.cs
- DesignerOptionService.cs
- ItemDragEvent.cs
- DbgCompiler.cs
- _StreamFramer.cs
- PageCache.cs
- RegexFCD.cs
- BamlLocalizableResource.cs
- FloaterParaClient.cs
- CachedBitmap.cs
- WindowsRichEdit.cs
- ObjectItemAttributeAssemblyLoader.cs
- SessionStateContainer.cs
- AutoGeneratedField.cs
- FormViewInsertEventArgs.cs
- DataTableNewRowEvent.cs
- TextWriterEngine.cs
- DataPagerField.cs
- SiteMapNode.cs
- CodeGeneratorOptions.cs
- OpenFileDialog.cs
- WebPartCatalogAddVerb.cs
- AutoResetEvent.cs
- OleDbPropertySetGuid.cs
- ElementAction.cs
- MasterPageBuildProvider.cs
- TemplateNameScope.cs
- DelimitedListTraceListener.cs