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
- DescendantQuery.cs
- HttpResponseWrapper.cs
- TrustManagerPromptUI.cs
- filewebrequest.cs
- UserControlBuildProvider.cs
- XD.cs
- FloatMinMaxAggregationOperator.cs
- TimelineGroup.cs
- XmlDomTextWriter.cs
- ToolTip.cs
- SqlGatherConsumedAliases.cs
- ViewValidator.cs
- WebPartMenu.cs
- ExpressionBuilderCollection.cs
- TdsEnums.cs
- ListenerPerfCounters.cs
- TraceEventCache.cs
- ExtensionWindow.cs
- HandlerFactoryWrapper.cs
- ServiceInstallComponent.cs
- BulletedList.cs
- SystemColors.cs
- DataConnectionHelper.cs
- AlphaSortedEnumConverter.cs
- cryptoapiTransform.cs
- SqlPersistenceProviderFactory.cs
- DuplicateWaitObjectException.cs
- SystemInfo.cs
- ScrollEventArgs.cs
- SqlParameterizer.cs
- TraceProvider.cs
- WriteableBitmap.cs
- CustomCategoryAttribute.cs
- Page.cs
- DataGridItemEventArgs.cs
- BoundColumn.cs
- BufferBuilder.cs
- PathFigureCollectionConverter.cs
- WebConfigurationFileMap.cs
- ThemeDictionaryExtension.cs
- OrderingQueryOperator.cs
- HttpPostServerProtocol.cs
- ConnectionManagementElementCollection.cs
- ShutDownListener.cs
- HWStack.cs
- DataControlField.cs
- TextServicesContext.cs
- SpellCheck.cs
- ItemType.cs
- PropertyEmitter.cs
- BooleanFacetDescriptionElement.cs
- XmlSchemaObjectTable.cs
- DisposableCollectionWrapper.cs
- ProtocolsSection.cs
- TableLayoutStyleCollection.cs
- LineSegment.cs
- ObjectDataSourceEventArgs.cs
- ZipIORawDataFileBlock.cs
- SafeFileMappingHandle.cs
- XsltContext.cs
- Polyline.cs
- ConditionalAttribute.cs
- DataFormats.cs
- ListControlBuilder.cs
- SevenBitStream.cs
- EpmAttributeNameBuilder.cs
- TranslateTransform3D.cs
- UserControlCodeDomTreeGenerator.cs
- mansign.cs
- BrowserDefinition.cs
- XPathScanner.cs
- CheckableControlBaseAdapter.cs
- CredentialCache.cs
- MaskDescriptor.cs
- TraceSource.cs
- _BasicClient.cs
- BinaryNode.cs
- ToolStripGripRenderEventArgs.cs
- InputProcessorProfilesLoader.cs
- VerificationException.cs
- XPathItem.cs
- Point3DAnimation.cs
- SHA256.cs
- RenderData.cs
- ExpandSegmentCollection.cs
- ElementProxy.cs
- PathParser.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- FileLevelControlBuilderAttribute.cs
- XamlReaderHelper.cs
- ConnectionsZone.cs
- CompressedStack.cs
- NonVisualControlAttribute.cs
- Policy.cs
- AdPostCacheSubstitution.cs
- MD5.cs
- TransformProviderWrapper.cs
- ScriptRef.cs
- StylusButton.cs
- TypedCompletedAsyncResult.cs