Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / ImageSourceValueSerializer.cs / 1305600 / 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.InvariantEnglishUS); 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.InvariantEnglishUS); 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
- TaskFactory.cs
- ModelPerspective.cs
- DataObject.cs
- InstanceLockedException.cs
- RepeatInfo.cs
- SimpleType.cs
- ModelProperty.cs
- ADMembershipProvider.cs
- KeyFrames.cs
- WebPartMinimizeVerb.cs
- DataTrigger.cs
- TextTreeInsertElementUndoUnit.cs
- DependencyPropertyDescriptor.cs
- MimeTypePropertyAttribute.cs
- PolicyManager.cs
- X509ThumbprintKeyIdentifierClause.cs
- ProcessHostConfigUtils.cs
- PointUtil.cs
- HealthMonitoringSection.cs
- Internal.cs
- ModuleElement.cs
- ObjectDesignerDataSourceView.cs
- SqlConnectionHelper.cs
- BaseAutoFormat.cs
- LongMinMaxAggregationOperator.cs
- BitmapEffectDrawingContent.cs
- SecurityTokenRequirement.cs
- control.ime.cs
- TreeSet.cs
- MachineSettingsSection.cs
- CodeIndexerExpression.cs
- XmlSerializationReader.cs
- HttpRuntime.cs
- PropertyTabChangedEvent.cs
- Nodes.cs
- PeerCustomResolverSettings.cs
- XmlEncoding.cs
- UInt32.cs
- X509ThumbprintKeyIdentifierClause.cs
- WebPartConnection.cs
- TabPanel.cs
- TextBoxBase.cs
- Win32.cs
- CatalogPartChrome.cs
- BinaryCommonClasses.cs
- latinshape.cs
- WindowsTab.cs
- SQLDateTimeStorage.cs
- OdbcDataReader.cs
- DbTransaction.cs
- CTreeGenerator.cs
- ClientData.cs
- PeerEndPoint.cs
- CodeMemberProperty.cs
- ChtmlPageAdapter.cs
- ZipIOExtraField.cs
- SQLDecimalStorage.cs
- Debug.cs
- OdbcParameterCollection.cs
- WinFormsUtils.cs
- DateTimeFormat.cs
- XmlSchemaInferenceException.cs
- TraceListener.cs
- GlobalizationSection.cs
- UnsafeNativeMethods.cs
- ObsoleteAttribute.cs
- PointHitTestParameters.cs
- XmlValidatingReader.cs
- MarkupCompiler.cs
- PartialClassGenerationTask.cs
- WorkflowInlining.cs
- BatchServiceHost.cs
- AutomationPatternInfo.cs
- RoutedCommand.cs
- CustomBindingElement.cs
- ItemCheckedEvent.cs
- KeyedCollection.cs
- DefaultMergeHelper.cs
- DataStreams.cs
- ElementAction.cs
- ProfileModule.cs
- Constraint.cs
- Image.cs
- SplayTreeNode.cs
- OleDbMetaDataFactory.cs
- SeekStoryboard.cs
- EncoderNLS.cs
- BuilderElements.cs
- JsonFaultDetail.cs
- BitmapEffect.cs
- GCHandleCookieTable.cs
- DragEventArgs.cs
- DataObjectCopyingEventArgs.cs
- Currency.cs
- OrderByBuilder.cs
- SignatureHelper.cs
- GridViewRowPresenterBase.cs
- HttpApplication.cs
- MeshGeometry3D.cs
- RsaSecurityToken.cs