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 / Media / ImageSourceValueSerializer.cs / 2 / ImageSourceValueSerializer.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ImageSourceValueSerializer.cs // // Contents: Value serializer for ImageSource instances // // Created: 06/21/2005 [....] // //----------------------------------------------------------------------- #pragma warning disable 1634, 1691 // Allow suppression of certain presharp messages using System; using System.Collections.Generic; using System.Globalization; using System.Text; using System.Windows.Markup; using System.Windows.Media.Imaging; namespace System.Windows.Media { ////// Value serializer for Transform instances /// public class ImageSourceValueSerializer : ValueSerializer { ////// Returns true. /// public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } ////// Returns true if the given transform can be converted into a string /// public override bool CanConvertToString(object value, IValueSerializerContext context) { ImageSource imageSource = value as ImageSource; #pragma warning disable 6506 return imageSource != null && imageSource.CanSerializeToString(); #pragma warning restore 6506 } ////// Converts a string into a transform. /// public override object ConvertFromString(string value, IValueSerializerContext context) { if (!string.IsNullOrEmpty(value)) { UriHolder uriHolder = TypeConverterHelper.GetUriFromUriContext(context, value); return BitmapFrame.CreateFromUriOrStream( uriHolder.BaseUri, uriHolder.OriginalUri, null, BitmapCreateOptions.None, BitmapCacheOption.Default, null ); } return base.ConvertFromString(value, context); } ////// Converts a transform into a string. /// public override string ConvertToString(object value, IValueSerializerContext context) { ImageSource imageSource = value as ImageSource; if (imageSource != null) return imageSource.ConvertToString(null, System.Windows.Markup.TypeConverterHelper.EnglishUSCulture); else return base.ConvertToString(value, context); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ImageSourceValueSerializer.cs // // Contents: Value serializer for ImageSource instances // // Created: 06/21/2005 [....] // //----------------------------------------------------------------------- #pragma warning disable 1634, 1691 // Allow suppression of certain presharp messages using System; using System.Collections.Generic; using System.Globalization; using System.Text; using System.Windows.Markup; using System.Windows.Media.Imaging; namespace System.Windows.Media { ////// Value serializer for Transform instances /// public class ImageSourceValueSerializer : ValueSerializer { ////// Returns true. /// public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } ////// Returns true if the given transform can be converted into a string /// public override bool CanConvertToString(object value, IValueSerializerContext context) { ImageSource imageSource = value as ImageSource; #pragma warning disable 6506 return imageSource != null && imageSource.CanSerializeToString(); #pragma warning restore 6506 } ////// Converts a string into a transform. /// public override object ConvertFromString(string value, IValueSerializerContext context) { if (!string.IsNullOrEmpty(value)) { UriHolder uriHolder = TypeConverterHelper.GetUriFromUriContext(context, value); return BitmapFrame.CreateFromUriOrStream( uriHolder.BaseUri, uriHolder.OriginalUri, null, BitmapCreateOptions.None, BitmapCacheOption.Default, null ); } return base.ConvertFromString(value, context); } ////// Converts a transform into a string. /// public override string ConvertToString(object value, IValueSerializerContext context) { ImageSource imageSource = value as ImageSource; if (imageSource != null) return imageSource.ConvertToString(null, System.Windows.Markup.TypeConverterHelper.EnglishUSCulture); 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
- PropertyChangingEventArgs.cs
- WindowsRichEditRange.cs
- TableAdapterManagerMethodGenerator.cs
- Scalars.cs
- SqlWorkflowInstanceStore.cs
- ScrollChangedEventArgs.cs
- CryptoProvider.cs
- TrackingParameters.cs
- Icon.cs
- BitmapImage.cs
- GAC.cs
- Model3D.cs
- IisTraceListener.cs
- CheckPair.cs
- dataprotectionpermission.cs
- ClassHandlersStore.cs
- DefaultObjectMappingItemCollection.cs
- SoapFault.cs
- SizeConverter.cs
- Crypto.cs
- IPEndPoint.cs
- CellParagraph.cs
- OrderByQueryOptionExpression.cs
- FontSizeConverter.cs
- XmlObjectSerializerContext.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- CmsInterop.cs
- embossbitmapeffect.cs
- FlowDocumentView.cs
- TextViewSelectionProcessor.cs
- FunctionCommandText.cs
- RoutingChannelExtension.cs
- XPathNodeInfoAtom.cs
- XPathNodeIterator.cs
- Automation.cs
- HttpContextWrapper.cs
- PixelFormat.cs
- ItemsPresenter.cs
- XomlSerializationHelpers.cs
- ConfigurationManager.cs
- DecimalStorage.cs
- LogReservationCollection.cs
- TaiwanLunisolarCalendar.cs
- TiffBitmapEncoder.cs
- MessageQueueCriteria.cs
- RelOps.cs
- ProxyFragment.cs
- HashHelpers.cs
- TypeInfo.cs
- SecureStringHasher.cs
- UnicodeEncoding.cs
- TraceProvider.cs
- BrowserCapabilitiesCompiler.cs
- SingleObjectCollection.cs
- RowsCopiedEventArgs.cs
- AnnotationElement.cs
- PropertyChangedEventArgs.cs
- DataContext.cs
- TypeConverterValueSerializer.cs
- HostVisual.cs
- HttpCookiesSection.cs
- Vector3DCollectionConverter.cs
- CopyAction.cs
- DbConnectionHelper.cs
- WorkflowServiceBehavior.cs
- SynchronizedKeyedCollection.cs
- ProfileBuildProvider.cs
- DragDrop.cs
- TimeStampChecker.cs
- SafeNativeMethodsOther.cs
- ListDataHelper.cs
- TracedNativeMethods.cs
- BindingMAnagerBase.cs
- TypeInitializationException.cs
- DBNull.cs
- ToolboxItemCollection.cs
- EditingMode.cs
- TagPrefixAttribute.cs
- Int64.cs
- PrintPageEvent.cs
- Context.cs
- Thumb.cs
- ComponentResourceManager.cs
- CryptoKeySecurity.cs
- EdmRelationshipRoleAttribute.cs
- AdapterUtil.cs
- ReferenceConverter.cs
- IdentityReference.cs
- MetafileHeader.cs
- Timer.cs
- XPathNavigatorKeyComparer.cs
- LicenseException.cs
- FontStyles.cs
- QueryExpr.cs
- RegexRunner.cs
- TableItemProviderWrapper.cs
- SizeKeyFrameCollection.cs
- EntityDataSourceConfigureObjectContext.cs
- ConstructorNeedsTagAttribute.cs
- OdbcTransaction.cs