Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / PreviewKeyDownEventArgs.cs / 1 / PreviewKeyDownEventArgs.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System; ////// /// /// public class PreviewKeyDownEventArgs : EventArgs { private readonly Keys _keyData; private bool _isInputKey; ////// Provides data for the PreviewKeyDownEvent /// ////// /// public PreviewKeyDownEventArgs(Keys keyData) { _keyData = keyData; } ///[To be supplied.] ////// /// public bool Alt { get { return (_keyData & Keys.Alt) == Keys.Alt; } } ////// Gets a value indicating whether the ALT key was pressed. /// ////// /// public bool Control { get { return (_keyData & Keys.Control) == Keys.Control; } } ////// Gets a value indicating whether the CTRL key was pressed. /// ////// /// //subhag : changed the behaviour of the KeyCode as per the new requirements. public Keys KeyCode { [ // Keys is discontiguous so we have to use Enum.IsDefined. SuppressMessage("Microsoft.Performance", "CA1803:AvoidCostlyCallsWherePossible") ] get { Keys keyGenerated = _keyData & Keys.KeyCode; // since Keys can be discontiguous, keeping Enum.IsDefined. if (!Enum.IsDefined(typeof(Keys),(int)keyGenerated)) return Keys.None; else return keyGenerated; } } ////// Gets the keyboard code for a ///or /// event. /// /// /// //subhag : added the KeyValue as per the new requirements. public int KeyValue { get { return (int)(_keyData & Keys.KeyCode); } } ////// Gets the keyboard value for a ///or /// event. /// /// /// public Keys KeyData { get { return _keyData; } } ////// Gets the key data for a ///or /// event. /// /// /// public Keys Modifiers { get { return _keyData & Keys.Modifiers; } } ////// Gets the modifier flags for a ///or event. /// This indicates which modifier keys (CTRL, SHIFT, and/or ALT) were pressed. /// /// /// public bool Shift { get { return (_keyData & Keys.Shift) == Keys.Shift; } } public bool IsInputKey { get { return _isInputKey; } set { _isInputKey = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// Gets /// a value indicating whether the SHIFT key was pressed. /// ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System; ////// /// /// public class PreviewKeyDownEventArgs : EventArgs { private readonly Keys _keyData; private bool _isInputKey; ////// Provides data for the PreviewKeyDownEvent /// ////// /// public PreviewKeyDownEventArgs(Keys keyData) { _keyData = keyData; } ///[To be supplied.] ////// /// public bool Alt { get { return (_keyData & Keys.Alt) == Keys.Alt; } } ////// Gets a value indicating whether the ALT key was pressed. /// ////// /// public bool Control { get { return (_keyData & Keys.Control) == Keys.Control; } } ////// Gets a value indicating whether the CTRL key was pressed. /// ////// /// //subhag : changed the behaviour of the KeyCode as per the new requirements. public Keys KeyCode { [ // Keys is discontiguous so we have to use Enum.IsDefined. SuppressMessage("Microsoft.Performance", "CA1803:AvoidCostlyCallsWherePossible") ] get { Keys keyGenerated = _keyData & Keys.KeyCode; // since Keys can be discontiguous, keeping Enum.IsDefined. if (!Enum.IsDefined(typeof(Keys),(int)keyGenerated)) return Keys.None; else return keyGenerated; } } ////// Gets the keyboard code for a ///or /// event. /// /// /// //subhag : added the KeyValue as per the new requirements. public int KeyValue { get { return (int)(_keyData & Keys.KeyCode); } } ////// Gets the keyboard value for a ///or /// event. /// /// /// public Keys KeyData { get { return _keyData; } } ////// Gets the key data for a ///or /// event. /// /// /// public Keys Modifiers { get { return _keyData & Keys.Modifiers; } } ////// Gets the modifier flags for a ///or event. /// This indicates which modifier keys (CTRL, SHIFT, and/or ALT) were pressed. /// /// /// public bool Shift { get { return (_keyData & Keys.Shift) == Keys.Shift; } } public bool IsInputKey { get { return _isInputKey; } set { _isInputKey = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Gets /// a value indicating whether the SHIFT key was pressed. /// ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebEncodingValidatorAttribute.cs
- StringOutput.cs
- PlatformNotSupportedException.cs
- Geometry3D.cs
- SmiEventSink_Default.cs
- GcSettings.cs
- ToolStripGripRenderEventArgs.cs
- RepeaterCommandEventArgs.cs
- precedingsibling.cs
- ServiceDiscoveryElement.cs
- WebZoneDesigner.cs
- BitmapFrame.cs
- MimeParameters.cs
- DecimalConstantAttribute.cs
- TextBounds.cs
- EventKeyword.cs
- XmlAttributeCollection.cs
- LinqDataSourceDeleteEventArgs.cs
- StreamWithDictionary.cs
- ShaderEffect.cs
- DataColumnMapping.cs
- PersistChildrenAttribute.cs
- OleDbMetaDataFactory.cs
- OneOfTypeConst.cs
- NumericUpDown.cs
- PartialArray.cs
- InsufficientMemoryException.cs
- MenuItem.cs
- DataConnectionHelper.cs
- BookmarkScope.cs
- Triplet.cs
- WSFederationHttpSecurityMode.cs
- HashHelper.cs
- RenderDataDrawingContext.cs
- NCryptNative.cs
- DesignerDataParameter.cs
- EntityClassGenerator.cs
- GlobalEventManager.cs
- ExpressionLink.cs
- XmlSchemaIdentityConstraint.cs
- FormsAuthenticationCredentials.cs
- PointLight.cs
- PolyQuadraticBezierSegment.cs
- SqlConnectionFactory.cs
- uribuilder.cs
- Drawing.cs
- ModuleConfigurationInfo.cs
- WebPartChrome.cs
- BamlBinaryWriter.cs
- HMACSHA256.cs
- StructuralCache.cs
- SystemIPAddressInformation.cs
- ThousandthOfEmRealDoubles.cs
- QueryHandler.cs
- ChannelSinkStacks.cs
- ModelTreeEnumerator.cs
- Table.cs
- PathHelper.cs
- MsdtcClusterUtils.cs
- IndexerNameAttribute.cs
- SourceSwitch.cs
- ToolStripDropDownClosedEventArgs.cs
- BitmapEffectDrawing.cs
- FtpWebRequest.cs
- CallContext.cs
- KeyValuePairs.cs
- StickyNote.cs
- TableHeaderCell.cs
- ScrollProperties.cs
- __Error.cs
- XmlSchemaComplexContentExtension.cs
- UpdatePanel.cs
- IndentedTextWriter.cs
- FixedDocumentPaginator.cs
- FileSystemWatcher.cs
- MouseActionConverter.cs
- SpellCheck.cs
- WebPartManagerInternals.cs
- PageCache.cs
- UIElement3DAutomationPeer.cs
- objectquery_tresulttype.cs
- ModuleBuilderData.cs
- EventDescriptor.cs
- ScriptReferenceEventArgs.cs
- LinearGradientBrush.cs
- TextUtf8RawTextWriter.cs
- MissingMethodException.cs
- ProfileSection.cs
- AbstractExpressions.cs
- DropTarget.cs
- BitmapSizeOptions.cs
- HostedNamedPipeTransportManager.cs
- IPHostEntry.cs
- DateTimeFormat.cs
- CaseStatement.cs
- VariableAction.cs
- GB18030Encoding.cs
- FixedSOMGroup.cs
- TimerTable.cs
- HttpListenerPrefixCollection.cs