Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / Command / KeyGestureValueSerializer.cs / 1305600 / KeyGestureValueSerializer.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: KeyGestureValueSerializer - Serializes a KeyGesture // to and from a string // // // History: // 08/04/2005 : Chuck Jazdzewski - Created // //--------------------------------------------------------------------------- using System; using System.ComponentModel; // for TypeConverter using System.Globalization; // for CultureInfo using System.Windows; using System.Windows.Input; using System.Windows.Markup; #pragma warning disable 1634, 1691 // suppressing PreSharp warnings namespace System.Windows.Input { ////// KeyGestureValueSerializer - Converter class for serializing a KeyGesture /// public class KeyGestureValueSerializer : ValueSerializer { ////// CanConvertFromString() /// /// /// ////// public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } /// /// CanConvertToString() /// /// /// ////// public override bool CanConvertToString(object value, IValueSerializerContext context) { KeyGesture keyGesture = value as KeyGesture; #pragma warning disable 6506 return (keyGesture != null) && ModifierKeysConverter.IsDefinedModifierKeys(keyGesture.Modifiers) && KeyGestureConverter.IsDefinedKey(keyGesture.Key); #pragma warning restore 6506 } /// /// ConvertFromString() /// /// /// ///public override object ConvertFromString(string value, IValueSerializerContext context) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(KeyGesture)); if (converter != null) return converter.ConvertFromString(value); else return base.ConvertFromString(value, context); } /// /// ConvertToString() /// /// /// ///public override string ConvertToString(object value, IValueSerializerContext context) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(KeyGesture)); if (converter != null) return converter.ConvertToInvariantString(value); else return base.ConvertToString(value, context); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // // Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: KeyGestureValueSerializer - Serializes a KeyGesture // to and from a string // // // History: // 08/04/2005 : Chuck Jazdzewski - Created // //--------------------------------------------------------------------------- using System; using System.ComponentModel; // for TypeConverter using System.Globalization; // for CultureInfo using System.Windows; using System.Windows.Input; using System.Windows.Markup; #pragma warning disable 1634, 1691 // suppressing PreSharp warnings namespace System.Windows.Input { ////// KeyGestureValueSerializer - Converter class for serializing a KeyGesture /// public class KeyGestureValueSerializer : ValueSerializer { ////// CanConvertFromString() /// /// /// ////// public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } /// /// CanConvertToString() /// /// /// ////// public override bool CanConvertToString(object value, IValueSerializerContext context) { KeyGesture keyGesture = value as KeyGesture; #pragma warning disable 6506 return (keyGesture != null) && ModifierKeysConverter.IsDefinedModifierKeys(keyGesture.Modifiers) && KeyGestureConverter.IsDefinedKey(keyGesture.Key); #pragma warning restore 6506 } /// /// ConvertFromString() /// /// /// ///public override object ConvertFromString(string value, IValueSerializerContext context) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(KeyGesture)); if (converter != null) return converter.ConvertFromString(value); else return base.ConvertFromString(value, context); } /// /// ConvertToString() /// /// /// ///public override string ConvertToString(object value, IValueSerializerContext context) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(KeyGesture)); if (converter != null) return converter.ConvertToInvariantString(value); else return base.ConvertToString(value, context); } } } // 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
- SupportingTokenParameters.cs
- XmlAttributes.cs
- FixedFindEngine.cs
- Timer.cs
- BinHexEncoder.cs
- ValueUtilsSmi.cs
- MouseGesture.cs
- BasicBrowserDialog.designer.cs
- FixedDocumentPaginator.cs
- TypeElementCollection.cs
- ConfigurationManagerHelperFactory.cs
- SignedXml.cs
- PropertyChangeTracker.cs
- DesigntimeLicenseContext.cs
- StartFileNameEditor.cs
- StringComparer.cs
- CmsInterop.cs
- SoapEnvelopeProcessingElement.cs
- NetworkInformationException.cs
- SqlUtils.cs
- XmlCharCheckingReader.cs
- StrictAndMessageFilter.cs
- HttpServerVarsCollection.cs
- ConfigsHelper.cs
- ListViewSelectEventArgs.cs
- ToolStripPanelSelectionBehavior.cs
- CompilerGlobalScopeAttribute.cs
- path.cs
- DataFieldEditor.cs
- PenContexts.cs
- UpdatePanelControlTrigger.cs
- NullEntityWrapper.cs
- cache.cs
- HMACSHA384.cs
- Util.cs
- ComponentRenameEvent.cs
- OdbcConnectionOpen.cs
- Cursor.cs
- ResumeStoryboard.cs
- TextShapeableCharacters.cs
- PropertyValueChangedEvent.cs
- CodeDefaultValueExpression.cs
- RemoteWebConfigurationHostServer.cs
- ValidatedControlConverter.cs
- TypeDependencyAttribute.cs
- ToolConsole.cs
- HostedTcpTransportManager.cs
- OleDbFactory.cs
- CompiledAction.cs
- LinkLabel.cs
- SqlDataSourceSelectingEventArgs.cs
- InteropBitmapSource.cs
- DaylightTime.cs
- EntityContainerEntitySet.cs
- Base64Decoder.cs
- AppDomainProtocolHandler.cs
- HandledEventArgs.cs
- EventDrivenDesigner.cs
- WindowsRegion.cs
- FontSourceCollection.cs
- HistoryEventArgs.cs
- ProxyAttribute.cs
- ComAwareEventInfo.cs
- HttpTransportManager.cs
- _AutoWebProxyScriptWrapper.cs
- SettingsProviderCollection.cs
- WebBrowser.cs
- IImplicitResourceProvider.cs
- IIS7WorkerRequest.cs
- SqlRetyper.cs
- TranslateTransform.cs
- PointLightBase.cs
- RepeaterCommandEventArgs.cs
- LinearGradientBrush.cs
- AuthStoreRoleProvider.cs
- StylusPointProperties.cs
- JsonDeserializer.cs
- ComEventsMethod.cs
- WorkflowRuntimeServicesBehavior.cs
- SelectionBorderGlyph.cs
- FormsIdentity.cs
- HttpListener.cs
- DeferrableContent.cs
- AnnotationAuthorChangedEventArgs.cs
- Automation.cs
- DateTimePickerDesigner.cs
- SafeRightsManagementSessionHandle.cs
- BoundPropertyEntry.cs
- _Win32.cs
- NonSerializedAttribute.cs
- TextRangeEditLists.cs
- Transform3DCollection.cs
- JsonSerializer.cs
- DataGridViewColumnHeaderCell.cs
- TypeUsage.cs
- XmlMembersMapping.cs
- UiaCoreTypesApi.cs
- XmlSerializerFactory.cs
- TrustSection.cs
- ValueTypeFixupInfo.cs