InputReport.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / InputReport.cs / 1305600 / InputReport.cs

                            using System;
using System.Security;
using System.Security.Permissions;
using MS.Internal; 
using MS.Internal.PresentationCore;
using MS.Win32; 
using System.Windows; 

namespace System.Windows.Input 
{
    /// 
    ///     The InputReport is an abstract base class for all input that is
    ///     reported to the InputManager. 
    /// 
    ///  
    ///     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. 
    /// 
    [FriendAccessAllowed]
    internal abstract class InputReport
    { 
        /// 
        ///     Constructs ad instance of the InputReport class. 
        ///  
        /// 
        ///     The type of input that is being reported. 
        /// 
        /// 
        ///     The type of input that is being reported.
        ///  
        /// 
        ///     The mode in which the input is being reported. 
        ///  
        /// 
        ///     The time when the input occured. 
        /// 
        /// 
        ///     This handles critical data in the form of PresentationSource but there are demands on the
        ///     critical data 
        /// 
        [SecurityCritical, SecurityTreatAsSafe] 
        protected InputReport(PresentationSource inputSource, InputType type, InputMode mode, int timestamp) 
        {
            if (inputSource == null) 
                throw new ArgumentNullException("inputSource");

            Validate_InputType( type );
            Validate_InputMode( mode ); 
            _inputSource= new SecurityCriticalData(inputSource);
            _type = type; 
            _mode = mode; 
            _timestamp = timestamp;
        } 

        /// 
        ///     Read-only access to the type of input source that reported input.
        ///  
        /// 
        ///     Critical: This element is treated as critical and is not ok to expose. 
        ///     A link demand exists but that in itself is not adequate to safeguard this. 
        ///     The critical exists to expose users.
        ///  
        public PresentationSource InputSource
        {
            [SecurityCritical]
            get 
            {
                return _inputSource.Value; 
            } 
        }
 
        /// 
        ///     Read-only access to the type of input that was reported.
        /// 
        public InputType Type {get {return _type;}} 

        ///  
        ///     Read-only access to the mode in which the input was reported. 
        /// 
        public InputMode Mode {get {return _mode;}} 

        /// 
        ///     Read-only access to the time when the input occured.
        ///  
        public int Timestamp {get {return _timestamp;}}
 
        ///  
        /// There is a proscription against using Enum.IsDefined().  (it is slow)
        /// so we write these PRIVATE validate routines instead. 
        /// 
        private void Validate_InputMode( InputMode mode )
        {
            switch( mode ) 
            {
                case InputMode.Foreground: 
                case InputMode.Sink: 
                    break;
                default: 
                    throw new  System.ComponentModel.InvalidEnumArgumentException("mode", (int)mode, typeof(InputMode));
            }
        }
 
        /// 
        /// There is a proscription against using Enum.IsDefined().  (it is slow) 
        /// so we write these PRIVATE validate routines instead. 
        /// 
        private void Validate_InputType( InputType type ) 
        {
            switch( type )
            {
                case InputType.Keyboard: 
                case InputType.Mouse:
                case InputType.Stylus: 
                case InputType.Hid: 
                case InputType.Text:
                case InputType.Command: 
                    break;
                default:
                    throw new  System.ComponentModel.InvalidEnumArgumentException("type", (int)type, typeof(InputType));
            } 
        }
 
        private SecurityCriticalData _inputSource; 
        private InputType _type;
        private InputMode _mode; 
        private int _timestamp;
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
 
using System;
using System.Security;
using System.Security.Permissions;
using MS.Internal; 
using MS.Internal.PresentationCore;
using MS.Win32; 
using System.Windows; 

namespace System.Windows.Input 
{
    /// 
    ///     The InputReport is an abstract base class for all input that is
    ///     reported to the InputManager. 
    /// 
    ///  
    ///     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. 
    /// 
    [FriendAccessAllowed]
    internal abstract class InputReport
    { 
        /// 
        ///     Constructs ad instance of the InputReport class. 
        ///  
        /// 
        ///     The type of input that is being reported. 
        /// 
        /// 
        ///     The type of input that is being reported.
        ///  
        /// 
        ///     The mode in which the input is being reported. 
        ///  
        /// 
        ///     The time when the input occured. 
        /// 
        /// 
        ///     This handles critical data in the form of PresentationSource but there are demands on the
        ///     critical data 
        /// 
        [SecurityCritical, SecurityTreatAsSafe] 
        protected InputReport(PresentationSource inputSource, InputType type, InputMode mode, int timestamp) 
        {
            if (inputSource == null) 
                throw new ArgumentNullException("inputSource");

            Validate_InputType( type );
            Validate_InputMode( mode ); 
            _inputSource= new SecurityCriticalData(inputSource);
            _type = type; 
            _mode = mode; 
            _timestamp = timestamp;
        } 

        /// 
        ///     Read-only access to the type of input source that reported input.
        ///  
        /// 
        ///     Critical: This element is treated as critical and is not ok to expose. 
        ///     A link demand exists but that in itself is not adequate to safeguard this. 
        ///     The critical exists to expose users.
        ///  
        public PresentationSource InputSource
        {
            [SecurityCritical]
            get 
            {
                return _inputSource.Value; 
            } 
        }
 
        /// 
        ///     Read-only access to the type of input that was reported.
        /// 
        public InputType Type {get {return _type;}} 

        ///  
        ///     Read-only access to the mode in which the input was reported. 
        /// 
        public InputMode Mode {get {return _mode;}} 

        /// 
        ///     Read-only access to the time when the input occured.
        ///  
        public int Timestamp {get {return _timestamp;}}
 
        ///  
        /// There is a proscription against using Enum.IsDefined().  (it is slow)
        /// so we write these PRIVATE validate routines instead. 
        /// 
        private void Validate_InputMode( InputMode mode )
        {
            switch( mode ) 
            {
                case InputMode.Foreground: 
                case InputMode.Sink: 
                    break;
                default: 
                    throw new  System.ComponentModel.InvalidEnumArgumentException("mode", (int)mode, typeof(InputMode));
            }
        }
 
        /// 
        /// There is a proscription against using Enum.IsDefined().  (it is slow) 
        /// so we write these PRIVATE validate routines instead. 
        /// 
        private void Validate_InputType( InputType type ) 
        {
            switch( type )
            {
                case InputType.Keyboard: 
                case InputType.Mouse:
                case InputType.Stylus: 
                case InputType.Hid: 
                case InputType.Text:
                case InputType.Command: 
                    break;
                default:
                    throw new  System.ComponentModel.InvalidEnumArgumentException("type", (int)type, typeof(InputType));
            } 
        }
 
        private SecurityCriticalData _inputSource; 
        private InputType _type;
        private InputMode _mode; 
        private int _timestamp;
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK