Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- ReaderContextStackData.cs
- NavigationProperty.cs
- OutOfMemoryException.cs
- FormClosingEvent.cs
- HwndTarget.cs
- OperandQuery.cs
- ProfileBuildProvider.cs
- Internal.cs
- TypedAsyncResult.cs
- PagedDataSource.cs
- Constant.cs
- Int16Converter.cs
- sqlstateclientmanager.cs
- Registry.cs
- InstanceCreationEditor.cs
- RemotingAttributes.cs
- WindowsToolbar.cs
- StackOverflowException.cs
- Certificate.cs
- DrawingCollection.cs
- ActivityDesignerHighlighter.cs
- ListComponentEditorPage.cs
- GeneralTransform3DGroup.cs
- Matrix3D.cs
- ColorIndependentAnimationStorage.cs
- _SslState.cs
- FontFamily.cs
- DataServicePagingProviderWrapper.cs
- CodeNamespaceImport.cs
- ImageAttributes.cs
- DescriptionAttribute.cs
- DefaultClaimSet.cs
- brushes.cs
- AccessDataSource.cs
- RepeaterDataBoundAdapter.cs
- DateTimeConverter2.cs
- LocatorManager.cs
- AssemblyBuilder.cs
- PageAdapter.cs
- ClientFormsIdentity.cs
- ObjectListGeneralPage.cs
- ComplexTypeEmitter.cs
- X509Extension.cs
- ContainerSelectorBehavior.cs
- StylusSystemGestureEventArgs.cs
- CollectionBuilder.cs
- EmptyTextWriter.cs
- XslTransform.cs
- SqlConnectionPoolGroupProviderInfo.cs
- UnsafeNativeMethods.cs
- DesignerActionList.cs
- InfiniteTimeSpanConverter.cs
- HelpProvider.cs
- Subtree.cs
- CredentialManagerDialog.cs
- ValueType.cs
- JournalEntryStack.cs
- TypeInitializationException.cs
- PolicyStatement.cs
- DataGridItemCollection.cs
- TypeInformation.cs
- DelegatingTypeDescriptionProvider.cs
- PageWrapper.cs
- AttributedMetaModel.cs
- ObjectSecurity.cs
- WebPartAddingEventArgs.cs
- Decorator.cs
- _NegotiateClient.cs
- ZipIOLocalFileDataDescriptor.cs
- AnchorEditor.cs
- remotingproxy.cs
- XmlNodeChangedEventManager.cs
- ZoneIdentityPermission.cs
- SqlDataReaderSmi.cs
- DataGridTable.cs
- MappedMetaModel.cs
- SqlComparer.cs
- Typography.cs
- RangeValuePattern.cs
- PngBitmapEncoder.cs
- XmlQueryCardinality.cs
- ListViewContainer.cs
- SizeFConverter.cs
- DaylightTime.cs
- AccessDataSourceView.cs
- MetadataItemEmitter.cs
- TypeInfo.cs
- COM2EnumConverter.cs
- DrawingAttributeSerializer.cs
- PersonalizationState.cs
- DataGridColumnCollection.cs
- ModelItem.cs
- CustomWebEventKey.cs
- UnsafeNativeMethods.cs
- WebPartConnectionsEventArgs.cs
- Timeline.cs
- UnsafeNativeMethods.cs
- AppSettingsSection.cs
- SecurityException.cs
- X509PeerCertificateAuthentication.cs