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
- TemplateBuilder.cs
- SHA512Managed.cs
- UpdatePanelControlTrigger.cs
- DesignerSerializationOptionsAttribute.cs
- SafeRightsManagementSessionHandle.cs
- XmlAttributeOverrides.cs
- BrowserDefinition.cs
- X509UI.cs
- ClosableStream.cs
- DataBoundControlAdapter.cs
- UIElementParagraph.cs
- RecognizeCompletedEventArgs.cs
- Constraint.cs
- HistoryEventArgs.cs
- ParameterRefs.cs
- MenuItem.cs
- DataObject.cs
- SoapClientMessage.cs
- NameValueSectionHandler.cs
- TextStore.cs
- PasswordPropertyTextAttribute.cs
- FixedHyperLink.cs
- TemplateBindingExtension.cs
- ApplicationException.cs
- SqlProfileProvider.cs
- Tuple.cs
- InsufficientMemoryException.cs
- ListViewItem.cs
- NegationPusher.cs
- FunctionQuery.cs
- SmtpDigestAuthenticationModule.cs
- IsolatedStorageSecurityState.cs
- X509SubjectKeyIdentifierClause.cs
- MailSettingsSection.cs
- FixedPage.cs
- PackWebRequest.cs
- CmsUtils.cs
- ActivityExecutionFilter.cs
- TypedReference.cs
- ProvidersHelper.cs
- QfeChecker.cs
- ModuleConfigurationInfo.cs
- UserControlAutomationPeer.cs
- OleDbConnectionInternal.cs
- CapabilitiesUse.cs
- HttpResponse.cs
- ObjectConverter.cs
- CodeComment.cs
- RestHandler.cs
- MenuScrollingVisibilityConverter.cs
- FigureParagraph.cs
- ConfigXmlAttribute.cs
- SqlSupersetValidator.cs
- XsltLoader.cs
- PkcsUtils.cs
- CheckBox.cs
- LocalServiceSecuritySettings.cs
- ActivityValidator.cs
- PathFigureCollectionConverter.cs
- GatewayDefinition.cs
- _BasicClient.cs
- RijndaelManaged.cs
- TextEncodedRawTextWriter.cs
- WebContext.cs
- CodeMethodInvokeExpression.cs
- ToolStripOverflow.cs
- GenericWebPart.cs
- CreateUserErrorEventArgs.cs
- ControlBuilderAttribute.cs
- HtmlElementEventArgs.cs
- MatrixCamera.cs
- ScrollBar.cs
- TextChangedEventArgs.cs
- XmlQualifiedNameTest.cs
- ExceptionWrapper.cs
- mediaeventshelper.cs
- TreeNodeStyle.cs
- ImageListStreamer.cs
- PnrpPeerResolverBindingElement.cs
- WebPageTraceListener.cs
- StyleSelector.cs
- FormsAuthenticationConfiguration.cs
- StringCollection.cs
- PageBreakRecord.cs
- StrokeRenderer.cs
- DateTimeUtil.cs
- DataGridState.cs
- InternalControlCollection.cs
- WebResourceUtil.cs
- Style.cs
- SingleResultAttribute.cs
- StringUtil.cs
- HttpFileCollectionBase.cs
- PassportIdentity.cs
- FixedPageProcessor.cs
- FunctionCommandText.cs
- Interlocked.cs
- ComponentChangingEvent.cs
- QueueProcessor.cs
- PrintEvent.cs