Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / ImageSourceValueSerializer.cs / 1305600 / 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.InvariantEnglishUS); 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.InvariantEnglishUS); 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
- BatchStream.cs
- DirectoryGroupQuery.cs
- JumpItem.cs
- HttpChannelHelper.cs
- DefaultParameterValueAttribute.cs
- Quaternion.cs
- PersonalizablePropertyEntry.cs
- TypeUsageBuilder.cs
- PropertySegmentSerializationProvider.cs
- UnmanagedBitmapWrapper.cs
- Pointer.cs
- FileUtil.cs
- StructuralComparisons.cs
- SpellerInterop.cs
- CodeAttributeDeclarationCollection.cs
- DynamicRenderer.cs
- ExpressionBuilder.cs
- HitTestWithPointDrawingContextWalker.cs
- TransformConverter.cs
- TimeoutException.cs
- FillErrorEventArgs.cs
- WMICapabilities.cs
- TextTreeNode.cs
- MD5.cs
- BitmapScalingModeValidation.cs
- DbConnectionPoolIdentity.cs
- Rect3DConverter.cs
- DialogDivider.cs
- ModifierKeysValueSerializer.cs
- Int64Storage.cs
- DbConnectionOptions.cs
- XPathMultyIterator.cs
- LinqDataSourceSelectEventArgs.cs
- PropertyPath.cs
- XmlSerializerNamespaces.cs
- DecoderFallbackWithFailureFlag.cs
- Delegate.cs
- BaseAddressPrefixFilterElement.cs
- Style.cs
- RequestUriProcessor.cs
- RelationshipEndMember.cs
- SecurityException.cs
- MergeFilterQuery.cs
- PasswordPropertyTextAttribute.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- WinInet.cs
- XmlSecureResolver.cs
- RawStylusInputReport.cs
- ContextProperty.cs
- ISAPIRuntime.cs
- NamedPipeHostedTransportConfiguration.cs
- QueueAccessMode.cs
- wmiprovider.cs
- DateTimeHelper.cs
- Padding.cs
- ExpressionBinding.cs
- DataGridTextBox.cs
- XPathSingletonIterator.cs
- TypeInfo.cs
- SqlConnectionStringBuilder.cs
- HostProtectionPermission.cs
- UserValidatedEventArgs.cs
- Storyboard.cs
- entityreference_tresulttype.cs
- BitStack.cs
- HttpException.cs
- LowerCaseStringConverter.cs
- IISUnsafeMethods.cs
- ActivityMarkupSerializer.cs
- Expressions.cs
- typedescriptorpermission.cs
- _PooledStream.cs
- Rect3D.cs
- SerializationInfoEnumerator.cs
- TabOrder.cs
- TextRangeBase.cs
- Solver.cs
- IListConverters.cs
- Substitution.cs
- BlurBitmapEffect.cs
- Application.cs
- ArrayList.cs
- CompilationUtil.cs
- DataServiceQueryProvider.cs
- EncryptedXml.cs
- GenericUI.cs
- WebSysDescriptionAttribute.cs
- WebPartConnectionsDisconnectVerb.cs
- SecureEnvironment.cs
- ListGeneralPage.cs
- HelpEvent.cs
- DataServiceQuery.cs
- Simplifier.cs
- DbConvert.cs
- PageSettings.cs
- GreenMethods.cs
- MouseWheelEventArgs.cs
- RuntimeHandles.cs
- httpstaticobjectscollection.cs
- activationcontext.cs