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
- XmlEncoding.cs
- MsmqElementBase.cs
- PageRequestManager.cs
- HtmlPhoneCallAdapter.cs
- ComponentCodeDomSerializer.cs
- ImageInfo.cs
- WebPartConnectionsConfigureVerb.cs
- FontStyleConverter.cs
- ImplicitInputBrush.cs
- WebPartConnectVerb.cs
- GridViewRow.cs
- CodeCatchClause.cs
- AsmxEndpointPickerExtension.cs
- ByteConverter.cs
- XamlBrushSerializer.cs
- HtmlLink.cs
- SafeFileHandle.cs
- BinHexDecoder.cs
- ProfileGroupSettingsCollection.cs
- ContentDisposition.cs
- CorrelationService.cs
- TableLayoutCellPaintEventArgs.cs
- ParameterSubsegment.cs
- TextTreeDeleteContentUndoUnit.cs
- ConnectionsZone.cs
- ShapeTypeface.cs
- brushes.cs
- ReadOnlyDictionary.cs
- XmlSiteMapProvider.cs
- ProtocolElement.cs
- XslAst.cs
- XXXOnTypeBuilderInstantiation.cs
- CodeCatchClauseCollection.cs
- SecurityRuntime.cs
- ImageFormat.cs
- BaseTemplateCodeDomTreeGenerator.cs
- PerspectiveCamera.cs
- CngProvider.cs
- ScriptHandlerFactory.cs
- PeerContact.cs
- VisualTarget.cs
- StoreAnnotationsMap.cs
- UnconditionalPolicy.cs
- Marshal.cs
- SymmetricSecurityBindingElement.cs
- SymbolPair.cs
- TypeSystemProvider.cs
- StorageInfo.cs
- SelectingProviderEventArgs.cs
- FieldNameLookup.cs
- DocumentPageView.cs
- OpenTypeLayoutCache.cs
- ServiceNameElementCollection.cs
- CompilationSection.cs
- RowUpdatedEventArgs.cs
- Screen.cs
- EmbeddedMailObjectsCollection.cs
- Certificate.cs
- DataControlFieldTypeEditor.cs
- NTAccount.cs
- SamlDoNotCacheCondition.cs
- PixelFormat.cs
- ButtonBaseAutomationPeer.cs
- IEnumerable.cs
- InvokeGenerator.cs
- AssemblyResourceLoader.cs
- LinkConverter.cs
- Column.cs
- NavigationProperty.cs
- RolePrincipal.cs
- ProviderMetadata.cs
- WindowsBrush.cs
- SendMailErrorEventArgs.cs
- DuplicateDetector.cs
- FrameDimension.cs
- DataBindingHandlerAttribute.cs
- HtmlElementErrorEventArgs.cs
- IsolatedStorage.cs
- UnknownBitmapDecoder.cs
- Matrix3DConverter.cs
- safex509handles.cs
- HostedHttpRequestAsyncResult.cs
- BaseHashHelper.cs
- CodeCastExpression.cs
- ReversePositionQuery.cs
- ObjectConverter.cs
- SizeValueSerializer.cs
- DataBoundControlHelper.cs
- PropVariant.cs
- SQLSingleStorage.cs
- GenericIdentity.cs
- MenuAdapter.cs
- ProxyAttribute.cs
- CompilerTypeWithParams.cs
- UserControl.cs
- Roles.cs
- ImagingCache.cs
- ImageAnimator.cs
- DesignerCategoryAttribute.cs
- SecureConversationDriver.cs