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
- SortedList.cs
- DynamicObjectAccessor.cs
- EntityReference.cs
- ArrayElementGridEntry.cs
- SymbolTable.cs
- Point3DKeyFrameCollection.cs
- LinkTarget.cs
- Model3D.cs
- HyperLinkField.cs
- SoapSchemaImporter.cs
- ToolStripRendererSwitcher.cs
- CodeCastExpression.cs
- EmptyEnumerator.cs
- DrawingAttributesDefaultValueFactory.cs
- LinearGradientBrush.cs
- DataColumnChangeEvent.cs
- WaitHandleCannotBeOpenedException.cs
- ConnectionPointCookie.cs
- OleDbErrorCollection.cs
- UIElementIsland.cs
- WriteableBitmap.cs
- CommandExpr.cs
- ObjectDataProvider.cs
- XmlSubtreeReader.cs
- StructuredTypeEmitter.cs
- HtmlMeta.cs
- PhysicalFontFamily.cs
- BindingManagerDataErrorEventArgs.cs
- PropertyOverridesDialog.cs
- IntranetCredentialPolicy.cs
- Site.cs
- IncrementalCompileAnalyzer.cs
- WorkflowEventArgs.cs
- FrameworkElement.cs
- SqlVisitor.cs
- KeyValueConfigurationCollection.cs
- VariableValue.cs
- CreateDataSourceDialog.cs
- HtmlUtf8RawTextWriter.cs
- DataKeyPropertyAttribute.cs
- PathFigureCollection.cs
- ListenerAdapter.cs
- GridEntry.cs
- AsyncOperation.cs
- ListView.cs
- Transform.cs
- ModuleConfigurationInfo.cs
- DataErrorValidationRule.cs
- JsonSerializer.cs
- EncoderNLS.cs
- Bold.cs
- Metadata.cs
- X509Certificate.cs
- RecommendedAsConfigurableAttribute.cs
- ItemCheckEvent.cs
- Query.cs
- BuildProvidersCompiler.cs
- RequestNavigateEventArgs.cs
- TraceContext.cs
- HashAlgorithm.cs
- ReadOnlyDictionary.cs
- SQLSingleStorage.cs
- MonthChangedEventArgs.cs
- TransactionProtocol.cs
- VisualProxy.cs
- SimpleTypesSurrogate.cs
- SmtpNtlmAuthenticationModule.cs
- CdpEqualityComparer.cs
- SafeLocalMemHandle.cs
- SimpleHandlerFactory.cs
- Repeater.cs
- counter.cs
- ObjRef.cs
- SessionEndedEventArgs.cs
- SoapElementAttribute.cs
- HandlerWithFactory.cs
- BrowserInteropHelper.cs
- AsymmetricKeyExchangeDeformatter.cs
- ScriptModule.cs
- XmlSchemaGroup.cs
- WindowsStatic.cs
- ObjectCache.cs
- ObjectDataSourceEventArgs.cs
- SettingsContext.cs
- ParameterCollection.cs
- DateRangeEvent.cs
- WebScriptEnablingElement.cs
- EnumerableRowCollectionExtensions.cs
- TokenBasedSet.cs
- PngBitmapEncoder.cs
- XsltLibrary.cs
- PagesSection.cs
- HtmlInputSubmit.cs
- SmtpDigestAuthenticationModule.cs
- SafeFileMappingHandle.cs
- ManagedCodeMarkers.cs
- SqlConnectionString.cs
- StringConverter.cs
- DbConnectionHelper.cs
- MergablePropertyAttribute.cs