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
- ProcessModelSection.cs
- Thread.cs
- BackStopAuthenticationModule.cs
- ConfigXmlElement.cs
- ObjectAnimationUsingKeyFrames.cs
- AppearanceEditorPart.cs
- UseLicense.cs
- CloseCollectionAsyncResult.cs
- Int64.cs
- EventlogProvider.cs
- DataContractSerializerSection.cs
- CatalogPartCollection.cs
- XMLSyntaxException.cs
- GridPatternIdentifiers.cs
- EntitySetBaseCollection.cs
- NamespaceMapping.cs
- RegexCode.cs
- LockCookie.cs
- FixedBufferAttribute.cs
- TypeUtil.cs
- _UriSyntax.cs
- MouseActionConverter.cs
- ContextMenuStrip.cs
- ListBindingHelper.cs
- Ops.cs
- XmlTextReader.cs
- SqlProviderManifest.cs
- PartialArray.cs
- SystemEvents.cs
- SourceItem.cs
- GradientSpreadMethodValidation.cs
- SafeEventLogWriteHandle.cs
- AccessControlList.cs
- MessageQuerySet.cs
- CodeStatementCollection.cs
- SiteMapPath.cs
- AppDomainInfo.cs
- DispatcherEventArgs.cs
- SqlWorkflowInstanceStore.cs
- WinOEToolBoxItem.cs
- ListBoxItemAutomationPeer.cs
- ListParaClient.cs
- SettingsBindableAttribute.cs
- NotFiniteNumberException.cs
- SchemaObjectWriter.cs
- PathSegmentCollection.cs
- FontInfo.cs
- SqlClientFactory.cs
- GeneralTransform3D.cs
- MultiPartWriter.cs
- CachedFontFamily.cs
- DeflateInput.cs
- SelectedGridItemChangedEvent.cs
- DatatypeImplementation.cs
- SqlBooleanizer.cs
- Scheduling.cs
- Preprocessor.cs
- List.cs
- FrameworkElementFactory.cs
- AssemblyUtil.cs
- CqlIdentifiers.cs
- StyleCollection.cs
- VariantWrapper.cs
- OperationInvokerTrace.cs
- PowerStatus.cs
- TextBox.cs
- PackageStore.cs
- BamlLocalizableResource.cs
- XsltOutput.cs
- BridgeDataRecord.cs
- VisualStyleInformation.cs
- WmfPlaceableFileHeader.cs
- XmlDocument.cs
- wmiprovider.cs
- ArgumentOutOfRangeException.cs
- TriggerAction.cs
- StringConverter.cs
- TypeInitializationException.cs
- ProfilePropertyNameValidator.cs
- FileLevelControlBuilderAttribute.cs
- WebColorConverter.cs
- FixedTextPointer.cs
- NumberFunctions.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ExternalFile.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- CustomCredentialPolicy.cs
- XsltQilFactory.cs
- XamlVector3DCollectionSerializer.cs
- WindowsListViewScroll.cs
- DataViewSetting.cs
- Stroke.cs
- TableHeaderCell.cs
- FormatterServicesNoSerializableCheck.cs
- SizeAnimationClockResource.cs
- RealizedColumnsBlock.cs
- LoginName.cs
- PersonalizableTypeEntry.cs
- CatalogZoneBase.cs
- SubpageParaClient.cs