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
- sqlser.cs
- IDispatchConstantAttribute.cs
- HttpCookie.cs
- TextContainerHelper.cs
- ZipIORawDataFileBlock.cs
- ComboBoxAutomationPeer.cs
- TextBlock.cs
- LocalValueEnumerator.cs
- DoWorkEventArgs.cs
- SHA384Managed.cs
- XmlWrappingReader.cs
- TerminatorSinks.cs
- HyperLinkField.cs
- DataGridColumnHeader.cs
- PropertyPath.cs
- IndicFontClient.cs
- AmbientLight.cs
- ExtendedPropertyDescriptor.cs
- WinEventQueueItem.cs
- WebPartMinimizeVerb.cs
- DiscoveryExceptionDictionary.cs
- UiaCoreApi.cs
- WindowCollection.cs
- WebPartMenuStyle.cs
- SqlExpander.cs
- FunctionNode.cs
- x509utils.cs
- BitmapEffectGeneralTransform.cs
- Dump.cs
- XPathDescendantIterator.cs
- StorageInfo.cs
- Config.cs
- ChtmlCommandAdapter.cs
- ManagementScope.cs
- AccessorTable.cs
- TaskFormBase.cs
- DesignerTransactionCloseEvent.cs
- ToolboxItem.cs
- TimeSpanConverter.cs
- ComplexPropertyEntry.cs
- MailDefinition.cs
- AmbiguousMatchException.cs
- UntrustedRecipientException.cs
- CopyNodeSetAction.cs
- IISMapPath.cs
- Literal.cs
- SystemParameters.cs
- EntityWrapperFactory.cs
- DbgUtil.cs
- FormsAuthenticationCredentials.cs
- Shape.cs
- WebPartEditorOkVerb.cs
- StylusEventArgs.cs
- SortedDictionary.cs
- HtmlEmptyTagControlBuilder.cs
- CodeTypeOfExpression.cs
- WindowsFormsSectionHandler.cs
- XmlDownloadManager.cs
- MarginsConverter.cs
- Mappings.cs
- X500Name.cs
- SingleAnimationUsingKeyFrames.cs
- IpcManager.cs
- FlagsAttribute.cs
- TextParagraphProperties.cs
- GiveFeedbackEvent.cs
- BlurBitmapEffect.cs
- MsmqIntegrationSecurity.cs
- SafeJobHandle.cs
- ToolStripProgressBar.cs
- ConfigurationValues.cs
- DynamicDataExtensions.cs
- UrlMappingsSection.cs
- ListBindingConverter.cs
- KerberosTicketHashIdentifierClause.cs
- __TransparentProxy.cs
- SqlAliaser.cs
- ServicesUtilities.cs
- WindowsImpersonationContext.cs
- DataObjectCopyingEventArgs.cs
- ColorAnimation.cs
- StringInfo.cs
- MultiBinding.cs
- TdsParserSafeHandles.cs
- VarRemapper.cs
- TrimSurroundingWhitespaceAttribute.cs
- SystemWebExtensionsSectionGroup.cs
- SQLBytes.cs
- exports.cs
- MimeMultiPart.cs
- DefaultBindingPropertyAttribute.cs
- hebrewshape.cs
- SingleObjectCollection.cs
- DataTableReader.cs
- SafeNativeMethods.cs
- DragEvent.cs
- IDQuery.cs
- ResourceDescriptionAttribute.cs
- InternalConfigHost.cs
- NamespaceDecl.cs