Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / PreviewKeyDownEventArgs.cs / 1305376 / 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
- Parser.cs
- GetKeyedHashRequest.cs
- ColorKeyFrameCollection.cs
- DataGridViewRowCancelEventArgs.cs
- SchemaImporterExtensionsSection.cs
- EventEntry.cs
- LinearKeyFrames.cs
- UInt64Storage.cs
- NetworkStream.cs
- PersonalizablePropertyEntry.cs
- DrawingBrush.cs
- FixedSOMPageConstructor.cs
- WebServiceHost.cs
- Transform3D.cs
- RuleRefElement.cs
- VerticalAlignConverter.cs
- SelectedDatesCollection.cs
- SiteMapNodeItemEventArgs.cs
- DLinqAssociationProvider.cs
- TextParagraph.cs
- TagPrefixCollection.cs
- RTLAwareMessageBox.cs
- IpcServerChannel.cs
- WebPartZoneAutoFormat.cs
- StrongNameUtility.cs
- ViewService.cs
- ResourceManager.cs
- MappingException.cs
- FontDialog.cs
- PersonalizationAdministration.cs
- ApplicationSecurityInfo.cs
- EvidenceTypeDescriptor.cs
- CodeGotoStatement.cs
- MessageDecoder.cs
- RelationshipType.cs
- XmlSchemaInfo.cs
- EnvelopedPkcs7.cs
- IncrementalReadDecoders.cs
- KeyNotFoundException.cs
- ShaderEffect.cs
- PackUriHelper.cs
- XsdDuration.cs
- DataTemplate.cs
- BitmapEffect.cs
- OleDbInfoMessageEvent.cs
- TreeNodeBindingCollection.cs
- TypeUtil.cs
- TypeInfo.cs
- HttpRequestCacheValidator.cs
- ConsumerConnectionPoint.cs
- ZipIOLocalFileDataDescriptor.cs
- OdbcConnectionFactory.cs
- CommandManager.cs
- __ComObject.cs
- ResumeStoryboard.cs
- DataMisalignedException.cs
- mda.cs
- BindUriHelper.cs
- BrowserCapabilitiesCodeGenerator.cs
- TimeSpan.cs
- DataGridViewCheckBoxColumn.cs
- Int32AnimationBase.cs
- ObjectStateFormatter.cs
- TableRowCollection.cs
- HelpKeywordAttribute.cs
- PanelDesigner.cs
- TextStore.cs
- AmbientValueAttribute.cs
- App.cs
- BinaryConverter.cs
- XamlReader.cs
- UpdateProgress.cs
- MailMessageEventArgs.cs
- Quaternion.cs
- TextSimpleMarkerProperties.cs
- DynamicDiscoSearcher.cs
- DecoderReplacementFallback.cs
- TimeoutValidationAttribute.cs
- WindowsAuthenticationEventArgs.cs
- SqlDataSourceSelectingEventArgs.cs
- StringFunctions.cs
- RepeaterItem.cs
- OdbcPermission.cs
- FragmentQueryProcessor.cs
- XmlTypeAttribute.cs
- CompoundFileReference.cs
- UDPClient.cs
- SamlAdvice.cs
- CompareInfo.cs
- PresentationSource.cs
- EdgeProfileValidation.cs
- SendMessageContent.cs
- AuthenticationSection.cs
- HttpHandlersSection.cs
- SineEase.cs
- InputEventArgs.cs
- RoutedEventArgs.cs
- DecimalKeyFrameCollection.cs
- Crypto.cs
- SoundPlayer.cs