Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TypefaceMap.cs
- XmlLoader.cs
- SmtpAuthenticationManager.cs
- NumericExpr.cs
- MouseCaptureWithinProperty.cs
- ProfilePropertySettingsCollection.cs
- ScriptComponentDescriptor.cs
- Clipboard.cs
- FontStretchConverter.cs
- HashSetEqualityComparer.cs
- HttpWebRequestElement.cs
- _ListenerAsyncResult.cs
- RepeatButton.cs
- WebPartZoneBase.cs
- EventSourceCreationData.cs
- BindingMAnagerBase.cs
- EncryptedData.cs
- WindowsUpDown.cs
- RelationalExpressions.cs
- SoapRpcServiceAttribute.cs
- MenuAdapter.cs
- Line.cs
- BaseDataBoundControl.cs
- ImageCodecInfo.cs
- KernelTypeValidation.cs
- PageOutputColor.cs
- SystemUnicastIPAddressInformation.cs
- CodeObjectCreateExpression.cs
- ScriptControlManager.cs
- FigureParagraph.cs
- SoapIgnoreAttribute.cs
- HttpRequestCacheValidator.cs
- WhitespaceRuleReader.cs
- CompilerScope.Storage.cs
- SqlStream.cs
- ExpressionReplacer.cs
- TypeBrowserDialog.cs
- TraceFilter.cs
- Verify.cs
- DayRenderEvent.cs
- AvtEvent.cs
- StreamInfo.cs
- ProfileService.cs
- Color.cs
- DataControlFieldCollection.cs
- TypeInfo.cs
- PropertyConverter.cs
- ElementFactory.cs
- XPathAxisIterator.cs
- AjaxFrameworkAssemblyAttribute.cs
- SystemIPGlobalStatistics.cs
- ProviderUtil.cs
- SchemaType.cs
- UnsafeNativeMethodsPenimc.cs
- GraphicsContext.cs
- CompositeTypefaceMetrics.cs
- SqlDataSourceEnumerator.cs
- TemplateField.cs
- SimpleHandlerBuildProvider.cs
- KeyGesture.cs
- XmlEventCache.cs
- ExcludePathInfo.cs
- TextServicesCompartmentContext.cs
- InputMethod.cs
- PropertyGrid.cs
- ParseElement.cs
- XmlCDATASection.cs
- StylusTip.cs
- ContourSegment.cs
- RealProxy.cs
- ThrowHelper.cs
- CompilerGlobalScopeAttribute.cs
- SecurityTokenSerializer.cs
- SimpleTypesSurrogate.cs
- ResetableIterator.cs
- TextWriter.cs
- TraceXPathNavigator.cs
- TransformationRules.cs
- DataGridViewRowPostPaintEventArgs.cs
- GridViewColumnCollection.cs
- Exceptions.cs
- DependencyPropertyHelper.cs
- TdsEnums.cs
- DemultiplexingDispatchMessageFormatter.cs
- PackageDigitalSignatureManager.cs
- SystemIPInterfaceProperties.cs
- FieldNameLookup.cs
- DataGridViewCellStyleConverter.cs
- SweepDirectionValidation.cs
- WebServicesDescriptionAttribute.cs
- followingquery.cs
- OptionUsage.cs
- CellLabel.cs
- DrawingImage.cs
- DrawListViewColumnHeaderEventArgs.cs
- DesignTimeTemplateParser.cs
- ConfigPathUtility.cs
- LabelEditEvent.cs
- SoapCommonClasses.cs
- SQLStringStorage.cs