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
- ConfigXmlComment.cs
- RichTextBoxAutomationPeer.cs
- DataGridBoolColumn.cs
- List.cs
- AliasGenerator.cs
- ReferencedCollectionType.cs
- MergePropertyDescriptor.cs
- RegexFCD.cs
- QuaternionConverter.cs
- GridSplitter.cs
- XmlDocumentViewSchema.cs
- ColorConverter.cs
- GeometryGroup.cs
- SweepDirectionValidation.cs
- OrderedEnumerableRowCollection.cs
- BufferedOutputStream.cs
- PerfCounters.cs
- Transform3DGroup.cs
- WSTrustFeb2005.cs
- SingleKeyFrameCollection.cs
- BitmapEncoder.cs
- PrivacyNoticeElement.cs
- PerformanceCounterManager.cs
- XmlArrayItemAttribute.cs
- WindowsUpDown.cs
- WorkflowViewService.cs
- Table.cs
- ConnectionPoolManager.cs
- InheritablePropertyChangeInfo.cs
- SmiEventSink_DeferedProcessing.cs
- AllowedAudienceUriElementCollection.cs
- HttpDigestClientCredential.cs
- CellParaClient.cs
- ListViewItemMouseHoverEvent.cs
- ExpressionBuilder.cs
- DecimalAnimationUsingKeyFrames.cs
- ConfigurationException.cs
- LookupNode.cs
- SafeProcessHandle.cs
- TextParaLineResult.cs
- DataTableMapping.cs
- HttpRuntime.cs
- Identifier.cs
- EntitySqlException.cs
- ToolBar.cs
- StringFreezingAttribute.cs
- MessageQueueKey.cs
- Constants.cs
- TextBlockAutomationPeer.cs
- SafeHandles.cs
- baseaxisquery.cs
- StructuralType.cs
- ComponentConverter.cs
- AvTrace.cs
- ADMembershipUser.cs
- Array.cs
- TcpServerChannel.cs
- XmlSchemaSimpleTypeRestriction.cs
- HostingPreferredMapPath.cs
- Vector3DAnimationBase.cs
- MexNamedPipeBindingElement.cs
- BaseServiceProvider.cs
- AutoScrollExpandMessageFilter.cs
- MimeMapping.cs
- StylusButtonCollection.cs
- NeutralResourcesLanguageAttribute.cs
- EntityException.cs
- ServiceDescriptionContext.cs
- SID.cs
- XPathNavigatorReader.cs
- SqlEnums.cs
- WebPartExportVerb.cs
- WebPartActionVerb.cs
- Annotation.cs
- WebDescriptionAttribute.cs
- CustomPopupPlacement.cs
- CacheHelper.cs
- PbrsForward.cs
- SqlAliaser.cs
- XmlSchemaAll.cs
- RoleManagerEventArgs.cs
- PolicyLevel.cs
- ICollection.cs
- AxImporter.cs
- TraceHandler.cs
- IIS7UserPrincipal.cs
- AccessDataSource.cs
- Lasso.cs
- ParameterInfo.cs
- SettingsPropertyIsReadOnlyException.cs
- DbBuffer.cs
- CompilationSection.cs
- ConfigurationValidatorAttribute.cs
- LogStore.cs
- Renderer.cs
- Listbox.cs
- ObjectStateManagerMetadata.cs
- SymbolType.cs
- X509ThumbprintKeyIdentifierClause.cs
- StylusDownEventArgs.cs