Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / 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 chuckj // //----------------------------------------------------------------------- #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
- HTTPRemotingHandler.cs
- XmlChildNodes.cs
- StrokeNode.cs
- PointHitTestResult.cs
- DynamicHyperLink.cs
- PocoPropertyAccessorStrategy.cs
- ExtenderHelpers.cs
- HtmlToClrEventProxy.cs
- CompositionAdorner.cs
- MinimizableAttributeTypeConverter.cs
- SafeBitVector32.cs
- BigInt.cs
- FillRuleValidation.cs
- ImageIndexConverter.cs
- ProcessHost.cs
- Mutex.cs
- UnsafeNativeMethods.cs
- WorkflowFormatterBehavior.cs
- SecurityContext.cs
- BitmapEffectrendercontext.cs
- HtmlImage.cs
- PowerModeChangedEventArgs.cs
- Timer.cs
- CompensationHandlingFilter.cs
- TagNameToTypeMapper.cs
- AvTrace.cs
- httpstaticobjectscollection.cs
- MenuAutomationPeer.cs
- InitializerFacet.cs
- ByteConverter.cs
- StylusPointCollection.cs
- Rule.cs
- messageonlyhwndwrapper.cs
- HtmlInputSubmit.cs
- NotCondition.cs
- BrowserCapabilitiesFactoryBase.cs
- EventData.cs
- TextProperties.cs
- ClientSession.cs
- TemplateBindingExtension.cs
- ExtensionQuery.cs
- Int32CollectionConverter.cs
- ScrollBarAutomationPeer.cs
- PaintValueEventArgs.cs
- ColorDialog.cs
- Trigger.cs
- PasswordRecovery.cs
- PriorityBindingExpression.cs
- DataViewListener.cs
- TextCompositionEventArgs.cs
- PolyQuadraticBezierSegment.cs
- XmlArrayAttribute.cs
- PreloadedPackages.cs
- IndentedTextWriter.cs
- ValueTypeFixupInfo.cs
- HttpGetProtocolImporter.cs
- DataGridSortCommandEventArgs.cs
- MessageQueueCriteria.cs
- ReferencedCollectionType.cs
- WebReferencesBuildProvider.cs
- Effect.cs
- XmlText.cs
- TextElement.cs
- EventItfInfo.cs
- TextRunTypographyProperties.cs
- BoundingRectTracker.cs
- AsyncResult.cs
- MemberPath.cs
- ObjectHandle.cs
- WindowHelperService.cs
- ClientApiGenerator.cs
- Visual3D.cs
- QilIterator.cs
- QilExpression.cs
- ConnectionPoint.cs
- TdsParserHelperClasses.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- LogReservationCollection.cs
- sortedlist.cs
- View.cs
- TreeNodeEventArgs.cs
- ListItem.cs
- LinqDataSourceSelectEventArgs.cs
- TabletCollection.cs
- PerformanceCounter.cs
- CompilerGlobalScopeAttribute.cs
- InvariantComparer.cs
- RemoteWebConfigurationHostStream.cs
- SchemaReference.cs
- CmsInterop.cs
- TextElementEditingBehaviorAttribute.cs
- x509utils.cs
- DiscriminatorMap.cs
- ProtocolInformationReader.cs
- MetafileHeader.cs
- BinaryKeyIdentifierClause.cs
- FamilyTypefaceCollection.cs
- XPathNodeIterator.cs
- AsymmetricAlgorithm.cs
- WindowsGraphicsWrapper.cs