Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Input / Command / KeyGestureValueSerializer.cs / 1 / 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
- ServicePointManagerElement.cs
- ScrollableControl.cs
- XmlAttributeProperties.cs
- FormViewPageEventArgs.cs
- Dump.cs
- WasHttpHandlersInstallComponent.cs
- MouseOverProperty.cs
- DataGridViewCellValueEventArgs.cs
- DataRow.cs
- ItemCollection.cs
- ServiceBuildProvider.cs
- MsmqMessageProperty.cs
- FusionWrap.cs
- InputLanguageCollection.cs
- WebControl.cs
- BroadcastEventHelper.cs
- DelegateTypeInfo.cs
- TableAdapterManagerNameHandler.cs
- OneToOneMappingSerializer.cs
- EditorPartCollection.cs
- HtmlInputText.cs
- VisualStyleElement.cs
- Tag.cs
- SizeChangedEventArgs.cs
- ErrorWebPart.cs
- DataListCommandEventArgs.cs
- Avt.cs
- MetafileHeaderWmf.cs
- PropertyChangingEventArgs.cs
- LiteralControl.cs
- SByte.cs
- ReadOnlyHierarchicalDataSourceView.cs
- MenuCommand.cs
- MessageHeaderInfoTraceRecord.cs
- OleDbError.cs
- CLSCompliantAttribute.cs
- FormatConvertedBitmap.cs
- MetricEntry.cs
- HtmlTableCellCollection.cs
- EntityDataSourceStatementEditor.cs
- WindowsToolbar.cs
- ToolStripItemTextRenderEventArgs.cs
- AnimationClockResource.cs
- JsonQueryStringConverter.cs
- PieceDirectory.cs
- BulletedList.cs
- XPathAncestorQuery.cs
- BaseInfoTable.cs
- IChannel.cs
- Effect.cs
- DataRowIndexBuffer.cs
- ExtenderControl.cs
- AddingNewEventArgs.cs
- ThreadSafeList.cs
- SqlConnectionString.cs
- UnionExpr.cs
- PcmConverter.cs
- ZoneButton.cs
- DispatcherExceptionFilterEventArgs.cs
- RC2.cs
- Grant.cs
- Stack.cs
- InputLanguageManager.cs
- RewritingProcessor.cs
- FrameworkElement.cs
- AccessControlEntry.cs
- XmlRawWriter.cs
- ByteStreamMessage.cs
- PropertyEmitterBase.cs
- ParentQuery.cs
- XmlNodeWriter.cs
- AsymmetricKeyExchangeFormatter.cs
- ApplicationFileParser.cs
- ServiceHostingEnvironment.cs
- Emitter.cs
- ColorMap.cs
- DictionaryCustomTypeDescriptor.cs
- mansign.cs
- LateBoundBitmapDecoder.cs
- TextCharacters.cs
- ConnectionsZone.cs
- ScrollChrome.cs
- KnownBoxes.cs
- VisualTreeFlattener.cs
- MachineKeyConverter.cs
- Compensate.cs
- FontSource.cs
- DataGridTable.cs
- WebBrowserContainer.cs
- SubqueryRules.cs
- AttachedPropertyMethodSelector.cs
- RealizationDrawingContextWalker.cs
- CollectionChangeEventArgs.cs
- columnmapkeybuilder.cs
- EnumBuilder.cs
- ScriptResourceDefinition.cs
- RenderData.cs
- LoopExpression.cs
- ScriptDescriptor.cs
- DataGridViewLayoutData.cs