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
- SchemaLookupTable.cs
- ConditionCollection.cs
- AnnotationAdorner.cs
- TreeNodeCollection.cs
- X509Certificate2Collection.cs
- HwndSubclass.cs
- DatagramAdapter.cs
- XmlSchemaComplexType.cs
- XmlWrappingReader.cs
- SoapSchemaExporter.cs
- XmlMembersMapping.cs
- DataPagerFieldItem.cs
- HttpListenerPrefixCollection.cs
- HandlerMappingMemo.cs
- ValidatorCollection.cs
- Binding.cs
- ModifierKeysConverter.cs
- LocalBuilder.cs
- ActivityWithResultWrapper.cs
- DmlSqlGenerator.cs
- TypefaceMap.cs
- EntityContainerEmitter.cs
- DeferredBinaryDeserializerExtension.cs
- AppDomainFactory.cs
- Int32Rect.cs
- Int32RectValueSerializer.cs
- ComAdminWrapper.cs
- BooleanFunctions.cs
- EditorZone.cs
- ListViewSelectEventArgs.cs
- Visual3D.cs
- SQLInt32.cs
- MemoryMappedView.cs
- HttpCookieCollection.cs
- DataGridViewCellCollection.cs
- FunctionDetailsReader.cs
- ConstraintEnumerator.cs
- DataColumnSelectionConverter.cs
- DesignSurfaceServiceContainer.cs
- MemberDomainMap.cs
- XmlNodeChangedEventManager.cs
- TokenBasedSet.cs
- DataSourceCollectionBase.cs
- EntityDataSourceColumn.cs
- WrapPanel.cs
- SoapAttributeAttribute.cs
- FlagsAttribute.cs
- RuntimeConfigurationRecord.cs
- TextPointer.cs
- ActiveXHost.cs
- ValidationHelper.cs
- BindUriHelper.cs
- RemoteWebConfigurationHostStream.cs
- ScalarConstant.cs
- ImmutableAssemblyCacheEntry.cs
- Empty.cs
- CodeDirectoryCompiler.cs
- CorrelationQueryBehavior.cs
- DataSourceListEditor.cs
- OpenTypeLayout.cs
- EntityModelBuildProvider.cs
- BuildProviderInstallComponent.cs
- DbgCompiler.cs
- X509IssuerSerialKeyIdentifierClause.cs
- LambdaCompiler.cs
- ServiceHostingEnvironmentSection.cs
- externdll.cs
- PropertiesTab.cs
- HtmlPageAdapter.cs
- Win32MouseDevice.cs
- Canvas.cs
- TextDecorationLocationValidation.cs
- PropertyDescriptorComparer.cs
- EventMappingSettings.cs
- DataGridViewCellStateChangedEventArgs.cs
- XmlSerializer.cs
- SizeIndependentAnimationStorage.cs
- FixedFindEngine.cs
- DesignConnection.cs
- WebPartConnectVerb.cs
- SwitchCase.cs
- CommonDialog.cs
- TabPanel.cs
- sqlser.cs
- CacheMemory.cs
- KeyToListMap.cs
- IdnMapping.cs
- FontStretches.cs
- PrinterResolution.cs
- PropertyEntry.cs
- XhtmlBasicFormAdapter.cs
- BamlWriter.cs
- FormView.cs
- InstalledFontCollection.cs
- TrackingServices.cs
- RelOps.cs
- DataSourceXmlSerializationAttribute.cs
- DbConnectionPoolCounters.cs
- XmlSchemaSimpleType.cs
- InputProcessorProfilesLoader.cs