Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- SqlDataRecord.cs
- ExpandedWrapper.cs
- ParseChildrenAsPropertiesAttribute.cs
- HttpCapabilitiesEvaluator.cs
- LineServicesCallbacks.cs
- CanonicalFontFamilyReference.cs
- regiisutil.cs
- DataPointer.cs
- DocumentsTrace.cs
- HttpListenerException.cs
- ProjectedSlot.cs
- SchemaImporterExtension.cs
- PackagePartCollection.cs
- AsynchronousChannelMergeEnumerator.cs
- HebrewCalendar.cs
- UpdateManifestForBrowserApplication.cs
- CalendarAutoFormatDialog.cs
- SqlXmlStorage.cs
- WinFormsUtils.cs
- WebReferenceCollection.cs
- GridViewItemAutomationPeer.cs
- login.cs
- DataGridViewColumnCollection.cs
- WindowsToolbarItemAsMenuItem.cs
- StrongNameMembershipCondition.cs
- TabletDevice.cs
- ReadOnlyHierarchicalDataSource.cs
- MediaCommands.cs
- XmlSchemaSimpleTypeList.cs
- CacheSection.cs
- OleDbParameterCollection.cs
- ViewUtilities.cs
- TypeBinaryExpression.cs
- XmlSecureResolver.cs
- FormViewPagerRow.cs
- UnsafeNativeMethodsCLR.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- HtmlElementCollection.cs
- AutomationPatternInfo.cs
- WebPartEventArgs.cs
- InternalPermissions.cs
- elementinformation.cs
- Clock.cs
- TargetFrameworkUtil.cs
- BrowsableAttribute.cs
- Block.cs
- SafeProcessHandle.cs
- DecimalKeyFrameCollection.cs
- MimeBasePart.cs
- XmlDocumentFieldSchema.cs
- sqlcontext.cs
- CodeStatementCollection.cs
- GeneralTransformGroup.cs
- JapaneseCalendar.cs
- QueryRelOp.cs
- DataGridView.cs
- WebControl.cs
- UnicodeEncoding.cs
- SmiContext.cs
- VariantWrapper.cs
- SimpleHandlerBuildProvider.cs
- MimeTypeAttribute.cs
- GPPOINT.cs
- StylusDownEventArgs.cs
- HandleInitializationContext.cs
- DesignerSelectionListAdapter.cs
- DataGridViewRowCancelEventArgs.cs
- ProcessHostConfigUtils.cs
- XmlSerializerVersionAttribute.cs
- EndGetFileNameFromUserRequest.cs
- SafeProcessHandle.cs
- Stylesheet.cs
- FacetValueContainer.cs
- BCLDebug.cs
- ToolbarAUtomationPeer.cs
- SqlStatistics.cs
- LinkedList.cs
- ObjectQueryProvider.cs
- DataGridViewUtilities.cs
- CatalogPartCollection.cs
- BrowserCapabilitiesCompiler.cs
- XmlQueryRuntime.cs
- DiscreteKeyFrames.cs
- CookieHandler.cs
- PageHandlerFactory.cs
- DocumentViewerConstants.cs
- SqlCacheDependencySection.cs
- MetafileHeader.cs
- HttpListenerPrefixCollection.cs
- FocusChangedEventArgs.cs
- ChangeInterceptorAttribute.cs
- PathStreamGeometryContext.cs
- UIElement3D.cs
- EdmPropertyAttribute.cs
- OpenFileDialog.cs
- HttpChannelBindingToken.cs
- CommandValueSerializer.cs
- IpcChannelHelper.cs
- KnownColorTable.cs
- _IPv6Address.cs