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
- GlyphRunDrawing.cs
- IERequestCache.cs
- SaveFileDialog.cs
- ScriptControl.cs
- TypedMessageConverter.cs
- DependencyObjectValidator.cs
- ReadingWritingEntityEventArgs.cs
- DetailsViewUpdateEventArgs.cs
- TextBlockAutomationPeer.cs
- SystemWebExtensionsSectionGroup.cs
- ToolStripControlHost.cs
- DXD.cs
- ImageFormatConverter.cs
- EntityDesignerBuildProvider.cs
- IODescriptionAttribute.cs
- StorageMappingItemCollection.cs
- Oid.cs
- SQLDouble.cs
- PropertiesTab.cs
- CodeParameterDeclarationExpression.cs
- TraceInternal.cs
- SqlMethods.cs
- UnsafeNetInfoNativeMethods.cs
- XPathDocumentNavigator.cs
- RuntimeCompatibilityAttribute.cs
- Claim.cs
- DragStartedEventArgs.cs
- ApplicationSecurityManager.cs
- EntityParameterCollection.cs
- StylusPointPropertyInfoDefaults.cs
- SortDescriptionCollection.cs
- Themes.cs
- RC2CryptoServiceProvider.cs
- Catch.cs
- GeometryGroup.cs
- ContentType.cs
- MailAddress.cs
- ProgressPage.cs
- Win32KeyboardDevice.cs
- NativeMethods.cs
- AutoGeneratedField.cs
- CompilerState.cs
- CursorEditor.cs
- AddingNewEventArgs.cs
- SessionStateUtil.cs
- DataGridViewColumnTypePicker.cs
- TagPrefixInfo.cs
- AssemblyAttributesGoHere.cs
- InputLanguageCollection.cs
- WebPartEditorOkVerb.cs
- XPathDocumentNavigator.cs
- SqlDataReaderSmi.cs
- ProcessModule.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- StructuralCache.cs
- filewebrequest.cs
- XmlHierarchicalEnumerable.cs
- NamespaceExpr.cs
- BaseCollection.cs
- ListViewHitTestInfo.cs
- SymLanguageType.cs
- ThreadInterruptedException.cs
- RootBuilder.cs
- webclient.cs
- ProcessStartInfo.cs
- TextTreePropertyUndoUnit.cs
- UrlMappingsModule.cs
- Main.cs
- XmlParserContext.cs
- AsyncOperationContext.cs
- LabelAutomationPeer.cs
- RequestQueryParser.cs
- Command.cs
- EntityContainerEntitySet.cs
- SystemTcpConnection.cs
- MemberCollection.cs
- RuleInfoComparer.cs
- SqlGenericUtil.cs
- HttpCacheVary.cs
- RegisteredDisposeScript.cs
- ConstraintEnumerator.cs
- COM2IDispatchConverter.cs
- WeakEventTable.cs
- RsaSecurityKey.cs
- WebPartAuthorizationEventArgs.cs
- recordstatescratchpad.cs
- StopRoutingHandler.cs
- DeviceSpecificDesigner.cs
- FontDialog.cs
- FixedDSBuilder.cs
- RegexCompiler.cs
- WindowPattern.cs
- DBSqlParser.cs
- XPathNodeInfoAtom.cs
- MethodToken.cs
- ListViewEditEventArgs.cs
- SingleAnimationUsingKeyFrames.cs
- PublisherMembershipCondition.cs
- ToolBarButton.cs
- HTTPRemotingHandler.cs