Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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;
///
///
///
///
/// Provides data for the PreviewKeyDownEvent
///
///
public class PreviewKeyDownEventArgs : EventArgs {
private readonly Keys _keyData;
private bool _isInputKey;
///
///
/// [To be supplied.]
///
public PreviewKeyDownEventArgs(Keys keyData) {
_keyData = keyData;
}
///
///
///
/// Gets a value indicating whether the ALT key was pressed.
///
///
public bool Alt {
get {
return (_keyData & Keys.Alt) == Keys.Alt;
}
}
///
///
///
/// Gets a value indicating whether the CTRL key was pressed.
///
///
public bool Control {
get {
return (_keyData & Keys.Control) == Keys.Control;
}
}
///
///
///
/// Gets the keyboard code for a or
/// event.
///
///
//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 value for a or
/// event.
///
///
//subhag : added the KeyValue as per the new requirements.
public int KeyValue {
get {
return (int)(_keyData & Keys.KeyCode);
}
}
///
///
///
/// Gets the key data for a or
/// event.
///
///
public Keys KeyData {
get {
return _keyData;
}
}
///
///
///
/// Gets the modifier flags for a or event.
/// This indicates which modifier keys (CTRL, SHIFT, and/or ALT) were pressed.
///
///
public Keys Modifiers {
get {
return _keyData & Keys.Modifiers;
}
}
///
///
///
/// Gets
/// a value indicating whether the SHIFT key was 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.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigXmlText.cs
- ColumnBinding.cs
- PropertyDescriptorGridEntry.cs
- MethodToken.cs
- SmtpCommands.cs
- XamlTemplateSerializer.cs
- ExpressionLexer.cs
- PieceNameHelper.cs
- TypedCompletedAsyncResult.cs
- ImageAutomationPeer.cs
- Positioning.cs
- WebService.cs
- PatternMatchRules.cs
- ToolStripKeyboardHandlingService.cs
- SystemIcmpV6Statistics.cs
- RequestBringIntoViewEventArgs.cs
- DispatcherObject.cs
- Translator.cs
- Form.cs
- Evaluator.cs
- BufferBuilder.cs
- FindCriteriaApril2005.cs
- TokenizerHelper.cs
- InternalEnumValidatorAttribute.cs
- ToolStripGrip.cs
- GraphicsContainer.cs
- WebPartConnectionsEventArgs.cs
- XmlUrlResolver.cs
- EventDescriptor.cs
- SpeechEvent.cs
- TargetPerspective.cs
- MailMessage.cs
- UriSectionData.cs
- XmlDocumentSchema.cs
- datacache.cs
- UIElement3D.cs
- XmlWellformedWriterHelpers.cs
- DataControlField.cs
- OperationInvokerBehavior.cs
- SoapEnumAttribute.cs
- UnSafeCharBuffer.cs
- Geometry3D.cs
- FindProgressChangedEventArgs.cs
- FileUpload.cs
- Stopwatch.cs
- CookieParameter.cs
- HtmlPhoneCallAdapter.cs
- Literal.cs
- TextCompositionManager.cs
- IUnknownConstantAttribute.cs
- MenuCommands.cs
- EmptyWithCancelationCheckWorkItem.cs
- XmlSchemaRedefine.cs
- SafeFileMappingHandle.cs
- ClientProxyGenerator.cs
- PageContent.cs
- SecuritySessionSecurityTokenProvider.cs
- FrameworkContextData.cs
- AlignmentYValidation.cs
- DataPagerFieldItem.cs
- OleDbConnection.cs
- SafeCryptContextHandle.cs
- Divide.cs
- PropertyChangedEventArgs.cs
- SoapReflectionImporter.cs
- EventArgs.cs
- ItemsChangedEventArgs.cs
- StatusBarItemAutomationPeer.cs
- TransportOutputChannel.cs
- UpdateManifestForBrowserApplication.cs
- SocketManager.cs
- XmlSigningNodeWriter.cs
- AttributeCollection.cs
- MasterPage.cs
- ScrollBarAutomationPeer.cs
- ISSmlParser.cs
- WebHttpBindingCollectionElement.cs
- HashHelper.cs
- BamlTreeMap.cs
- StringFunctions.cs
- Vector3DAnimationBase.cs
- XsdBuildProvider.cs
- Utils.cs
- ReliableReplySessionChannel.cs
- SerializationStore.cs
- DragCompletedEventArgs.cs
- FrugalMap.cs
- CompilerTypeWithParams.cs
- SchemaTableColumn.cs
- PropertyEmitterBase.cs
- TransformerConfigurationWizardBase.cs
- AndAlso.cs
- DataColumnCollection.cs
- Rectangle.cs
- ZipIOLocalFileDataDescriptor.cs
- MD5CryptoServiceProvider.cs
- controlskin.cs
- ForwardPositionQuery.cs
- XmlSchemaSimpleContentExtension.cs
- Model3D.cs