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
- CriticalExceptions.cs
- WSSecureConversationDec2005.cs
- GeneralTransform.cs
- StringFreezingAttribute.cs
- filewebresponse.cs
- DependencyStoreSurrogate.cs
- ConversionContext.cs
- StylusPointPropertyInfo.cs
- SchemaType.cs
- CopyOnWriteList.cs
- JoinElimination.cs
- SendMailErrorEventArgs.cs
- EntityDataSourceSelectingEventArgs.cs
- securitycriticaldata.cs
- StdValidatorsAndConverters.cs
- SmtpCommands.cs
- DeferredSelectedIndexReference.cs
- InnerItemCollectionView.cs
- CompiledAction.cs
- TextRangeProviderWrapper.cs
- PersonalizableAttribute.cs
- FrameworkTemplate.cs
- CultureTable.cs
- SystemIPInterfaceStatistics.cs
- DbDeleteCommandTree.cs
- SchemaNotation.cs
- ping.cs
- FormsAuthenticationTicket.cs
- LateBoundBitmapDecoder.cs
- DescendantBaseQuery.cs
- QueryResponse.cs
- DataGridViewToolTip.cs
- Calendar.cs
- SystemColors.cs
- ResXFileRef.cs
- ListSortDescriptionCollection.cs
- Substitution.cs
- CopyNamespacesAction.cs
- FixedSOMElement.cs
- RbTree.cs
- ReadonlyMessageFilter.cs
- JoinTreeSlot.cs
- RenderDataDrawingContext.cs
- ConvertEvent.cs
- AuthenticatedStream.cs
- ProtectedProviderSettings.cs
- XmlFormatExtensionPointAttribute.cs
- Queue.cs
- CodeTypeMember.cs
- LinearKeyFrames.cs
- MarkupObject.cs
- securitycriticaldataformultiplegetandset.cs
- CalendarDay.cs
- MonthChangedEventArgs.cs
- Utility.cs
- XslException.cs
- mansign.cs
- TextDecorationCollectionConverter.cs
- FormViewModeEventArgs.cs
- Util.cs
- WhiteSpaceTrimStringConverter.cs
- MimeParameters.cs
- OptimalBreakSession.cs
- Renderer.cs
- GestureRecognizer.cs
- Ray3DHitTestResult.cs
- ProviderMetadataCachedInformation.cs
- MailWebEventProvider.cs
- StringDictionaryWithComparer.cs
- ResourceReferenceKeyNotFoundException.cs
- DataGridTable.cs
- mda.cs
- DesignerUtility.cs
- DockProviderWrapper.cs
- TrackingDataItem.cs
- HtmlControlPersistable.cs
- SingletonChannelAcceptor.cs
- storepermission.cs
- SecurityRuntime.cs
- WebPermission.cs
- Button.cs
- AsyncMethodInvoker.cs
- StackSpiller.Bindings.cs
- ParameterCollection.cs
- MultipartIdentifier.cs
- OleDbCommand.cs
- LinqDataSourceUpdateEventArgs.cs
- ProtocolsSection.cs
- MouseDevice.cs
- SymmetricAlgorithm.cs
- XmlSortKey.cs
- UnsafeNativeMethods.cs
- StorageRoot.cs
- SemanticBasicElement.cs
- GlobalizationSection.cs
- CfgParser.cs
- DataSysAttribute.cs
- Pen.cs
- HtmlShim.cs
- ToolStripSplitStackLayout.cs