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
- AppDomainUnloadedException.cs
- ThaiBuddhistCalendar.cs
- TaskFileService.cs
- FileSystemInfo.cs
- FileLogRecord.cs
- ArrangedElementCollection.cs
- SoapSchemaImporter.cs
- AbstractSvcMapFileLoader.cs
- JournalEntryStack.cs
- MailFileEditor.cs
- WsatEtwTraceListener.cs
- ResourceAssociationSet.cs
- SessionStateUtil.cs
- SqlDataSourceView.cs
- ServerValidateEventArgs.cs
- DataGridColumnHeaderAutomationPeer.cs
- ActivationServices.cs
- OrderedDictionary.cs
- XmlCharCheckingReader.cs
- Matrix3DStack.cs
- SystemNetHelpers.cs
- DataGridViewHeaderCell.cs
- FieldNameLookup.cs
- XhtmlBasicCommandAdapter.cs
- ScriptRegistrationManager.cs
- ControlParameter.cs
- EmissiveMaterial.cs
- DataGridRelationshipRow.cs
- _HTTPDateParse.cs
- Misc.cs
- StoreAnnotationsMap.cs
- TypeElement.cs
- UpdatePanelControlTrigger.cs
- SystemMulticastIPAddressInformation.cs
- _FixedSizeReader.cs
- WebMessageEncoderFactory.cs
- BinaryObjectInfo.cs
- BuiltInExpr.cs
- DbXmlEnabledProviderManifest.cs
- Rights.cs
- PassportAuthenticationEventArgs.cs
- DataGridViewCellStyle.cs
- HMACSHA512.cs
- CopyNamespacesAction.cs
- ToggleButton.cs
- RoleService.cs
- VisualCollection.cs
- DispatcherSynchronizationContext.cs
- FrameworkReadOnlyPropertyMetadata.cs
- UrlPath.cs
- ValueChangedEventManager.cs
- BitmapEffectState.cs
- TimeSpanSecondsConverter.cs
- TableHeaderCell.cs
- AmbientProperties.cs
- CompressionTracing.cs
- SyndicationSerializer.cs
- TypeBuilderInstantiation.cs
- DesignSurfaceEvent.cs
- SizeAnimationUsingKeyFrames.cs
- ContextMenuStripGroup.cs
- FixedDSBuilder.cs
- _FixedSizeReader.cs
- WindowsScrollBarBits.cs
- SrgsRuleRef.cs
- SecureUICommand.cs
- CmsInterop.cs
- XmlSerializationReader.cs
- ConfigurationLoaderException.cs
- ObjectDataSourceEventArgs.cs
- ItemCheckEvent.cs
- FormsAuthenticationCredentials.cs
- SocketPermission.cs
- IPipelineRuntime.cs
- ProfileManager.cs
- WorkflowControlEndpoint.cs
- X509CertificateRecipientClientCredential.cs
- LinqDataSourceUpdateEventArgs.cs
- MessageBox.cs
- InternalEnumValidatorAttribute.cs
- Point3DAnimationUsingKeyFrames.cs
- TabletCollection.cs
- ArraySortHelper.cs
- X500Name.cs
- Underline.cs
- XmlSchemaInclude.cs
- ExitEventArgs.cs
- RootNamespaceAttribute.cs
- GridViewColumn.cs
- CursorInteropHelper.cs
- CompiledRegexRunnerFactory.cs
- HyperLink.cs
- AttachedPropertiesService.cs
- WebPartConnectionsCloseVerb.cs
- DetailsViewUpdateEventArgs.cs
- RemotingClientProxy.cs
- OrderedEnumerableRowCollection.cs
- ToolStripOverflowButton.cs
- CompositeCollectionView.cs
- ResXBuildProvider.cs