Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / Input / Command / KeyBinding.cs / 1 / KeyBinding.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: The KeyBinding class is used by the developer to create Keyboard Input Bindings // // See spec at : [....]/coreui/Specs/Commanding(new).mht // //* KeyBinding class serves the purpose of Input Bindings for Keyboard Device. // // History: // 06/01/2003 : [....] - Created // 05/01/2004 : chandra - changed to accommodate new design // ( [....]/coreui/Specs/Commanding(new).mht ) //--------------------------------------------------------------------------- using System; using System.Windows.Input; using System.Windows; using System.ComponentModel; using System.Windows.Markup; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// KeyBinding - Implements InputBinding (generic InputGesture-Command map) /// KeyBinding acts like a map for KeyGesture and Commands. /// Most of the logic is in InputBinding and KeyGesture, this only /// facilitates user to add Key/Modifiers directly without going in /// KeyGesture path. Also it provides the KeyGestureTypeConverter /// on the Gesture property to have KeyGesture, like Ctrl+X, Alt+V /// defined in Markup as Gesture="Ctrl+X" working /// public class KeyBinding : InputBinding { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructor ////// Constructor /// public KeyBinding() : base() { } ////// Constructor /// /// Command associated /// KeyGesture associated public KeyBinding(ICommand command, KeyGesture gesture) : base(command, gesture) { } ////// Constructor /// /// /// modifiers /// key public KeyBinding(ICommand command, Key key, ModifierKeys modifiers) : base(command, new KeyGesture(key, modifiers)) { } #endregion Constructor //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// KeyGesture Override, to ensure type-safety and provide a /// TypeConverter for KeyGesture /// [TypeConverter(typeof(KeyGestureConverter))] [ValueSerializer(typeof(KeyGestureValueSerializer))] public override InputGesture Gesture { get { return base.Gesture as KeyGesture; } set { if (value is KeyGesture) { base.Gesture = value; } else { throw new ArgumentException(SR.Get(SRID.InputBinding_ExpectedInputGesture, typeof(KeyGesture))); } } } ////// Modifier /// public ModifierKeys Modifiers { get { lock (_dataLock) { if (null != Gesture) { return ((KeyGesture)Gesture).Modifiers; } return ModifierKeys.None; } } set { lock (_dataLock) { if (null == Gesture) { Gesture = new KeyGesture(Key.None, (ModifierKeys)value, /*validateGesture = */ false); } else { Gesture = new KeyGesture(((KeyGesture)Gesture).Key, value, /*validateGesture = */ false); } } } } ////// Key /// public Key Key { get { lock (_dataLock) { if (null != Gesture) { return ((KeyGesture)Gesture).Key; } return Key.None; } } set { lock (_dataLock) { if (null == Gesture) { Gesture = new KeyGesture((Key)value, ModifierKeys.None, /*validateGesture = */ false); } else { Gesture = new KeyGesture(value, ((KeyGesture)Gesture).Modifiers, /*validateGesture = */ false); } } } } #endregion Public Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ } } // 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
- DictionaryContent.cs
- StateItem.cs
- __Filters.cs
- TypeConverterHelper.cs
- StylusPlugin.cs
- HyperLinkColumn.cs
- NativeMethods.cs
- SqlXmlStorage.cs
- XmlSchemaSimpleContentRestriction.cs
- DeploymentExceptionMapper.cs
- DbConnectionPoolCounters.cs
- CurrentChangingEventManager.cs
- XmlRawWriter.cs
- SqlDataSourceCommandEventArgs.cs
- SafeNativeMethods.cs
- ValidationSummary.cs
- HandlerWithFactory.cs
- SamlSubject.cs
- FixedLineResult.cs
- ItemCollection.cs
- ElementAtQueryOperator.cs
- RegexBoyerMoore.cs
- DrawingContextWalker.cs
- AutomationEvent.cs
- BrushValueSerializer.cs
- GridViewSelectEventArgs.cs
- Point3DCollection.cs
- DbQueryCommandTree.cs
- SpotLight.cs
- XmlSecureResolver.cs
- SystemIPInterfaceProperties.cs
- TableItemProviderWrapper.cs
- TypeSystemProvider.cs
- FrameworkReadOnlyPropertyMetadata.cs
- PageBuildProvider.cs
- translator.cs
- RuntimeArgument.cs
- Int16Storage.cs
- Keyboard.cs
- ADConnectionHelper.cs
- TiffBitmapDecoder.cs
- PersistChildrenAttribute.cs
- EntityDataSourceWrapperCollection.cs
- HttpException.cs
- InputScope.cs
- relpropertyhelper.cs
- PageSetupDialog.cs
- MembershipSection.cs
- DataErrorValidationRule.cs
- HybridCollection.cs
- VariableElement.cs
- DataSourceCacheDurationConverter.cs
- SizeValueSerializer.cs
- BitmapPalette.cs
- AppDomainFactory.cs
- Formatter.cs
- BrowserCapabilitiesFactory.cs
- FilteredReadOnlyMetadataCollection.cs
- StrokeCollection2.cs
- RtfToXamlReader.cs
- ObjectKeyFrameCollection.cs
- StringFormat.cs
- MediaCommands.cs
- WebPartConnectionsDisconnectVerb.cs
- PagedDataSource.cs
- DesignTimeTemplateParser.cs
- PrimitiveType.cs
- BlurBitmapEffect.cs
- DoubleUtil.cs
- RegexMatch.cs
- Timer.cs
- TaskScheduler.cs
- EventRoute.cs
- Double.cs
- WebPartTransformerAttribute.cs
- TakeOrSkipWhileQueryOperator.cs
- ProfileEventArgs.cs
- XPathNodeInfoAtom.cs
- DateTimeFormatInfo.cs
- TextTrailingWordEllipsis.cs
- ArrayWithOffset.cs
- WorkflowNamespace.cs
- CngKeyCreationParameters.cs
- MessageDecoder.cs
- GroupBox.cs
- SqlAliasesReferenced.cs
- Literal.cs
- ServiceHttpModule.cs
- DelegateArgumentReference.cs
- Property.cs
- FormsAuthenticationConfiguration.cs
- CodeDelegateInvokeExpression.cs
- CompositeActivityMarkupSerializer.cs
- EdmToObjectNamespaceMap.cs
- GenericAuthenticationEventArgs.cs
- SQLDouble.cs
- ListControlBuilder.cs
- SqlRemoveConstantOrderBy.cs
- X509Extension.cs
- _StreamFramer.cs