Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / ImageSourceValueSerializer.cs / 1 / 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, CultureInfo.GetCultureInfo("en-us")); 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, CultureInfo.GetCultureInfo("en-us")); 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
- UniqueConstraint.cs
- OleDbRowUpdatedEvent.cs
- HtmlInputImage.cs
- RotationValidation.cs
- ViewSimplifier.cs
- MemberMaps.cs
- Condition.cs
- WsiProfilesElement.cs
- SelectionHighlightInfo.cs
- TreeNodeBindingCollection.cs
- PriorityQueue.cs
- WebPartMenuStyle.cs
- GridViewUpdateEventArgs.cs
- ChannelToken.cs
- ReachSerializationUtils.cs
- RangeValuePatternIdentifiers.cs
- ParagraphVisual.cs
- DeviceFilterDictionary.cs
- AttributeConverter.cs
- ScrollPatternIdentifiers.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- SimpleHandlerFactory.cs
- CacheMode.cs
- GeometryDrawing.cs
- EntityModelBuildProvider.cs
- DbConnectionPoolIdentity.cs
- ApplicationSecurityInfo.cs
- ListViewUpdateEventArgs.cs
- ProcessDesigner.cs
- MulticastOption.cs
- AppDomainManager.cs
- SQLByte.cs
- ContentValidator.cs
- HitTestParameters.cs
- Literal.cs
- PassportAuthentication.cs
- ProcessHostConfigUtils.cs
- PhysicalAddress.cs
- EntityKey.cs
- XPathSingletonIterator.cs
- OutputWindow.cs
- RulePatternOps.cs
- Int32KeyFrameCollection.cs
- HttpCapabilitiesEvaluator.cs
- OracleRowUpdatedEventArgs.cs
- CalendarSelectionChangedEventArgs.cs
- Triplet.cs
- AbandonedMutexException.cs
- InkCanvasAutomationPeer.cs
- PresentationAppDomainManager.cs
- NativeMethods.cs
- Help.cs
- NameValueCollection.cs
- PageParser.cs
- SchemaNotation.cs
- ResXResourceReader.cs
- SpotLight.cs
- ApplicationSecurityInfo.cs
- CleanUpVirtualizedItemEventArgs.cs
- InkSerializer.cs
- EdmValidator.cs
- InputDevice.cs
- ScriptingRoleServiceSection.cs
- BitStream.cs
- RedistVersionInfo.cs
- ObjectSet.cs
- SudsParser.cs
- XmlDocumentType.cs
- SortedDictionary.cs
- DynamicRendererThreadManager.cs
- NamespaceList.cs
- CollectionViewSource.cs
- Int32AnimationBase.cs
- IntPtr.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- UriExt.cs
- SchemaLookupTable.cs
- HtmlControl.cs
- DynamicQueryStringParameter.cs
- ExtractedStateEntry.cs
- AxisAngleRotation3D.cs
- EmissiveMaterial.cs
- ArrangedElementCollection.cs
- DiscoveryRequestHandler.cs
- AffineTransform3D.cs
- FileUpload.cs
- DefaultValueTypeConverter.cs
- Decorator.cs
- PersonalizableTypeEntry.cs
- JpegBitmapEncoder.cs
- ParameterCollectionEditor.cs
- DbParameterCollectionHelper.cs
- TableColumn.cs
- PriorityRange.cs
- TypefaceCollection.cs
- _NegotiateClient.cs
- ViewStateModeByIdAttribute.cs
- ProgressBarRenderer.cs
- CorrelationScope.cs
- ColumnCollection.cs