Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / Imaging / UnmanagedBitmapWrapper.cs / 1 / UnmanagedBitmapWrapper.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation. All Rights Reserved. // // File: UnmanagedBitmapWrapper.cs // //----------------------------------------------------------------------------- using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using MS.Internal; using MS.Win32.PresentationCore; using System.Security; using System.Security.Permissions; using System.Diagnostics; using System.Windows.Media; using System.Globalization; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using MS.Internal.PresentationCore; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; namespace System.Windows.Media.Imaging { internal sealed class UnmanagedBitmapWrapper : System.Windows.Media.Imaging.BitmapSource { ////// Critical - calls critical code method BitmapSource.UpdateCachedSettings /// TreatAsSafe - all inputs are checked /// [SecurityCritical, SecurityTreatAsSafe] public UnmanagedBitmapWrapper(BitmapSourceSafeMILHandle bitmapSource) : base(true) { _bitmapInit.BeginInit(); bitmapSource.CalculateSize(); WicSourceHandle = bitmapSource; _bitmapInit.EndInit(); UpdateCachedSettings(); } #region Protected Methods ////// Critical - eventually access'es critical resources (_wicSource) /// TreatAsSafe - all inputs are checked /// [SecurityCritical, SecurityTreatAsSafe] internal UnmanagedBitmapWrapper(bool initialize) : base(true) { // Call BeginInit and EndInit if initialize is true. if (initialize) { _bitmapInit.BeginInit(); _bitmapInit.EndInit(); } } ////// Critical - calls critical code method BitmapSource.UpdateCachedSettings /// TreatAsSafe - all inputs are checked /// [SecurityCritical, SecurityTreatAsSafe] internal void UpdateBitmapSource(BitmapSource bitmapSource, DUCE.Channel channel) { WicSourceHandle = bitmapSource.WicSourceHandle; UpdateCachedSettings(); _needsUpdate = true; UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ ); } ////// Implementation of protected override Freezable CreateInstanceCore() { return new UnmanagedBitmapWrapper(false); } private void CopyCommon(UnmanagedBitmapWrapper sourceBitmap) { _bitmapInit.BeginInit(); _bitmapInit.EndInit(); } ///Freezable.CreateInstanceCore . ////// Implementation of protected override void CloneCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.CloneCore(sourceFreezable); CopyCommon(sourceBitmap); } ///Freezable.CloneCore . ////// Implementation of protected override void CloneCurrentValueCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(sourceBitmap); } ///Freezable.CloneCurrentValueCore . ////// Implementation of protected override void GetAsFrozenCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmap); } ///Freezable.GetAsFrozenCore . ////// Implementation of protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmap); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation. All Rights Reserved. // // File: UnmanagedBitmapWrapper.cs // //----------------------------------------------------------------------------- using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using MS.Internal; using MS.Win32.PresentationCore; using System.Security; using System.Security.Permissions; using System.Diagnostics; using System.Windows.Media; using System.Globalization; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using MS.Internal.PresentationCore; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; namespace System.Windows.Media.Imaging { internal sealed class UnmanagedBitmapWrapper : System.Windows.Media.Imaging.BitmapSource { ///Freezable.GetCurrentValueAsFrozenCore . ////// Critical - calls critical code method BitmapSource.UpdateCachedSettings /// TreatAsSafe - all inputs are checked /// [SecurityCritical, SecurityTreatAsSafe] public UnmanagedBitmapWrapper(BitmapSourceSafeMILHandle bitmapSource) : base(true) { _bitmapInit.BeginInit(); bitmapSource.CalculateSize(); WicSourceHandle = bitmapSource; _bitmapInit.EndInit(); UpdateCachedSettings(); } #region Protected Methods ////// Critical - eventually access'es critical resources (_wicSource) /// TreatAsSafe - all inputs are checked /// [SecurityCritical, SecurityTreatAsSafe] internal UnmanagedBitmapWrapper(bool initialize) : base(true) { // Call BeginInit and EndInit if initialize is true. if (initialize) { _bitmapInit.BeginInit(); _bitmapInit.EndInit(); } } ////// Critical - calls critical code method BitmapSource.UpdateCachedSettings /// TreatAsSafe - all inputs are checked /// [SecurityCritical, SecurityTreatAsSafe] internal void UpdateBitmapSource(BitmapSource bitmapSource, DUCE.Channel channel) { WicSourceHandle = bitmapSource.WicSourceHandle; UpdateCachedSettings(); _needsUpdate = true; UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ ); } ////// Implementation of protected override Freezable CreateInstanceCore() { return new UnmanagedBitmapWrapper(false); } private void CopyCommon(UnmanagedBitmapWrapper sourceBitmap) { _bitmapInit.BeginInit(); _bitmapInit.EndInit(); } ///Freezable.CreateInstanceCore . ////// Implementation of protected override void CloneCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.CloneCore(sourceFreezable); CopyCommon(sourceBitmap); } ///Freezable.CloneCore . ////// Implementation of protected override void CloneCurrentValueCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(sourceBitmap); } ///Freezable.CloneCurrentValueCore . ////// Implementation of protected override void GetAsFrozenCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmap); } ///Freezable.GetAsFrozenCore . ////// Implementation of protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { UnmanagedBitmapWrapper sourceBitmap = (UnmanagedBitmapWrapper)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmap); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.Freezable.GetCurrentValueAsFrozenCore . ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridComponentEditor.cs
- BufferModeSettings.cs
- Site.cs
- CanonicalFormWriter.cs
- SimpleExpression.cs
- HtmlElementCollection.cs
- ExpressionBindings.cs
- RepeaterItem.cs
- InputProcessorProfilesLoader.cs
- IUnknownConstantAttribute.cs
- XmlDocumentFieldSchema.cs
- ResourceExpression.cs
- CursorEditor.cs
- DependencyPropertyConverter.cs
- DynamicControlParameter.cs
- HttpModuleCollection.cs
- TypeEnumerableViewSchema.cs
- BamlLocalizableResource.cs
- TickBar.cs
- WebExceptionStatus.cs
- QueryComponents.cs
- EventArgs.cs
- LocalizeDesigner.cs
- Char.cs
- ExecutionContext.cs
- CheckBox.cs
- CustomAttributeFormatException.cs
- ItemList.cs
- XmlElementCollection.cs
- ImageMapEventArgs.cs
- BooleanAnimationBase.cs
- OleDbDataReader.cs
- TextUtf8RawTextWriter.cs
- MenuEventArgs.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- ServiceBehaviorElement.cs
- AnnotationAdorner.cs
- FocusWithinProperty.cs
- TextElementEnumerator.cs
- SamlSerializer.cs
- GroupStyle.cs
- MediaSystem.cs
- Util.cs
- StorageEntityTypeMapping.cs
- WsatStrings.cs
- HttpWebRequestElement.cs
- SchemaContext.cs
- MaskPropertyEditor.cs
- DataGridViewSelectedCellCollection.cs
- Int32.cs
- ImmutablePropertyDescriptorGridEntry.cs
- RestHandler.cs
- DetailsViewRow.cs
- DataServiceConfiguration.cs
- Binding.cs
- XmlCharCheckingWriter.cs
- ScrollData.cs
- RubberbandSelector.cs
- InvokeProviderWrapper.cs
- mediapermission.cs
- OleDbInfoMessageEvent.cs
- Converter.cs
- CheckBoxStandardAdapter.cs
- DrawingCollection.cs
- ClientConvert.cs
- SQLByteStorage.cs
- UnsafeNativeMethods.cs
- DecoderFallback.cs
- OdbcErrorCollection.cs
- CompressionTracing.cs
- FormsAuthenticationUserCollection.cs
- AssemblyNameUtility.cs
- SqlDependency.cs
- FlowDocumentPageViewerAutomationPeer.cs
- EntityDataSourceView.cs
- TableSectionStyle.cs
- TextServicesCompartment.cs
- DataSourceView.cs
- QuaternionAnimationUsingKeyFrames.cs
- SetIterators.cs
- Matrix3DStack.cs
- ListViewSelectEventArgs.cs
- SafeNativeMemoryHandle.cs
- XmlElementAttribute.cs
- DebuggerAttributes.cs
- CompiledQueryCacheEntry.cs
- BitmapScalingModeValidation.cs
- XamlSerializationHelper.cs
- ListControl.cs
- CriticalHandle.cs
- PathGeometry.cs
- EncodingTable.cs
- ToolStripRenderEventArgs.cs
- BufferBuilder.cs
- DataGridCaption.cs
- InvalidateEvent.cs
- NavigationFailedEventArgs.cs
- sqlnorm.cs
- TextCompositionManager.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs