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
- InvokeDelegate.cs
- QuaternionRotation3D.cs
- SrgsText.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- XPathAncestorQuery.cs
- PartialTrustVisibleAssembliesSection.cs
- CodeFieldReferenceExpression.cs
- DelegateSerializationHolder.cs
- DefaultAutoFieldGenerator.cs
- MediaPlayer.cs
- RegistryKey.cs
- TraceUtils.cs
- WizardDesigner.cs
- ParentControlDesigner.cs
- InsufficientExecutionStackException.cs
- OdbcEnvironmentHandle.cs
- Or.cs
- FormatConvertedBitmap.cs
- DataGridViewRowHeaderCell.cs
- XmlSchemaAny.cs
- CodeTypeMemberCollection.cs
- MobileTemplatedControlDesigner.cs
- RtfToXamlLexer.cs
- PageTheme.cs
- ProfilePropertyMetadata.cs
- ListenerElementsCollection.cs
- RoleManagerModule.cs
- WinHttpWebProxyFinder.cs
- MULTI_QI.cs
- FrameworkPropertyMetadata.cs
- TextWriterTraceListener.cs
- DiscoveryProxy.cs
- DataContractSerializerElement.cs
- ProgressBarAutomationPeer.cs
- DrawListViewColumnHeaderEventArgs.cs
- BlurBitmapEffect.cs
- DataControlButton.cs
- CursorConverter.cs
- LongTypeConverter.cs
- Memoizer.cs
- MissingFieldException.cs
- ToolBarOverflowPanel.cs
- RangeContentEnumerator.cs
- NamedPipeAppDomainProtocolHandler.cs
- ConfigurationException.cs
- VectorConverter.cs
- TagMapCollection.cs
- ImageSourceValueSerializer.cs
- GridLengthConverter.cs
- Vector3dCollection.cs
- DocumentCollection.cs
- CodeComment.cs
- ReaderWriterLockWrapper.cs
- DriveInfo.cs
- SequentialUshortCollection.cs
- ProjectionPlanCompiler.cs
- MethodExpr.cs
- PolyLineSegment.cs
- SchemaRegistration.cs
- AnnotationComponentManager.cs
- SqlNotificationEventArgs.cs
- ChtmlSelectionListAdapter.cs
- MailMessageEventArgs.cs
- ByeMessageCD1.cs
- CollectionViewSource.cs
- MessagePropertyDescription.cs
- ArgumentException.cs
- CatalogZoneAutoFormat.cs
- RegexCapture.cs
- ObjectParameter.cs
- SqlTypesSchemaImporter.cs
- InstanceKey.cs
- CultureInfoConverter.cs
- CreateUserErrorEventArgs.cs
- BaseDataListComponentEditor.cs
- ControlBuilderAttribute.cs
- PtsPage.cs
- EntityProviderServices.cs
- Route.cs
- MatrixIndependentAnimationStorage.cs
- WebPartPersonalization.cs
- Handle.cs
- DataGridTextColumn.cs
- SafeSystemMetrics.cs
- CompleteWizardStep.cs
- WinInet.cs
- EntityDataSourceWrapperCollection.cs
- Util.cs
- TraceSection.cs
- ChannelManagerHelpers.cs
- FrameworkContentElementAutomationPeer.cs
- IDispatchConstantAttribute.cs
- TimeSpanOrInfiniteValidator.cs
- ListItem.cs
- ContentPresenter.cs
- WebPartZone.cs
- EDesignUtil.cs
- DefaultValueTypeConverter.cs
- DrawItemEvent.cs
- NominalTypeEliminator.cs