Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CommonUI / System / Drawing / Brush.cs / 1 / Brush.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.ComponentModel; using Microsoft.Win32; using System.Drawing; using System.Drawing.Internal; using System.Globalization; /** * Represent a Brush object */ ////// /// public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable { #if FINALIZATION_WATCH private string allocationSite = Graphics.GetAllocationStack(); #endif // handle to native GDI+ brush object to be used on demand. ////// Classes derrived from this abstract base class define objects used to fill the /// interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths. /// ///private IntPtr nativeBrush; /// /// /// When overriden in a derived class, creates /// an exact copy of this public abstract object Clone(); ///. /// /// Sets the native GDI+ brush reference. /// Note: This method is intended to be used by derived classes only! (internal protected doesn't work as in C++). /// protected internal void SetNativeBrush(IntPtr brush) { Debug.Assert( brush != IntPtr.Zero, "WARNING: Assigning null to the GDI+ native brush object."); Debug.Assert( this.nativeBrush == IntPtr.Zero, "WARNING: Initialized GDI+ native brush object being assigned a new value."); this.nativeBrush = brush; } ////// Gets the GDI+ native object reference. Triggers GDI+ obect initialization. /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] internal IntPtr NativeBrush { get { //Need to comment this line out to allow for checking this.NativePen == IntPtr.Zero. //Debug.Assert(this.nativeBrush != IntPtr.Zero, "this.nativeBrush == null." ); return this.nativeBrush; } } ////// /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ////// Deletes this ///. /// protected virtual void Dispose(bool disposing) { #if FINALIZATION_WATCH if (!disposing && nativeBrush != IntPtr.Zero ) Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite); #endif if (this.nativeBrush != IntPtr.Zero) { try{ #if DEBUG int status = #endif SafeNativeMethods.Gdip.GdipDeleteBrush(new HandleRef(this, this.nativeBrush)); #if DEBUG Debug.Assert(status == SafeNativeMethods.Gdip.Ok, "GDI+ returned an error status: " + status.ToString(CultureInfo.InvariantCulture)); #endif } catch( Exception ex ){ if( ClientUtils.IsSecurityOrCriticalException( ex ) ) { throw; } Debug.Fail( "Exception thrown during Dispose: " + ex.ToString() ); } finally{ this.nativeBrush = IntPtr.Zero; } } } /** * Object cleanup */ /// /// /// ~Brush() { Dispose(false); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// Releases memory allocated for this ///. /// // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing { using System.Runtime.InteropServices; using System.Diagnostics; using System; using System.ComponentModel; using Microsoft.Win32; using System.Drawing; using System.Drawing.Internal; using System.Globalization; /** * Represent a Brush object */ ////// /// public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable { #if FINALIZATION_WATCH private string allocationSite = Graphics.GetAllocationStack(); #endif // handle to native GDI+ brush object to be used on demand. ////// Classes derrived from this abstract base class define objects used to fill the /// interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths. /// ///private IntPtr nativeBrush; /// /// /// When overriden in a derived class, creates /// an exact copy of this public abstract object Clone(); ///. /// /// Sets the native GDI+ brush reference. /// Note: This method is intended to be used by derived classes only! (internal protected doesn't work as in C++). /// protected internal void SetNativeBrush(IntPtr brush) { Debug.Assert( brush != IntPtr.Zero, "WARNING: Assigning null to the GDI+ native brush object."); Debug.Assert( this.nativeBrush == IntPtr.Zero, "WARNING: Initialized GDI+ native brush object being assigned a new value."); this.nativeBrush = brush; } ////// Gets the GDI+ native object reference. Triggers GDI+ obect initialization. /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] internal IntPtr NativeBrush { get { //Need to comment this line out to allow for checking this.NativePen == IntPtr.Zero. //Debug.Assert(this.nativeBrush != IntPtr.Zero, "this.nativeBrush == null." ); return this.nativeBrush; } } ////// /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ////// Deletes this ///. /// protected virtual void Dispose(bool disposing) { #if FINALIZATION_WATCH if (!disposing && nativeBrush != IntPtr.Zero ) Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite); #endif if (this.nativeBrush != IntPtr.Zero) { try{ #if DEBUG int status = #endif SafeNativeMethods.Gdip.GdipDeleteBrush(new HandleRef(this, this.nativeBrush)); #if DEBUG Debug.Assert(status == SafeNativeMethods.Gdip.Ok, "GDI+ returned an error status: " + status.ToString(CultureInfo.InvariantCulture)); #endif } catch( Exception ex ){ if( ClientUtils.IsSecurityOrCriticalException( ex ) ) { throw; } Debug.Fail( "Exception thrown during Dispose: " + ex.ToString() ); } finally{ this.nativeBrush = IntPtr.Zero; } } } /** * Object cleanup */ /// /// /// ~Brush() { Dispose(false); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Releases memory allocated for this ///. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlCharCheckingReader.cs
- EntityViewGenerator.cs
- RenamedEventArgs.cs
- TypeExtension.cs
- path.cs
- DateTimeUtil.cs
- DefaultValueAttribute.cs
- TypeSemantics.cs
- EmptyReadOnlyDictionaryInternal.cs
- TimeZoneNotFoundException.cs
- SingleAnimationUsingKeyFrames.cs
- RemotingServices.cs
- DbSetClause.cs
- Profiler.cs
- TraceSection.cs
- XmlValidatingReader.cs
- XPathItem.cs
- OleDbTransaction.cs
- PanelStyle.cs
- Fonts.cs
- EntityModelBuildProvider.cs
- Part.cs
- DateTimeFormatInfo.cs
- ConfigurationValues.cs
- PopupControlService.cs
- ActivityDesignerAccessibleObject.cs
- DocumentApplicationJournalEntryEventArgs.cs
- TableSectionStyle.cs
- ExpressionBuilderCollection.cs
- SystemResourceHost.cs
- CodeGeneratorOptions.cs
- FormsAuthenticationModule.cs
- LogicalExpressionTypeConverter.cs
- CommandManager.cs
- ComponentResourceKeyConverter.cs
- PlaceHolder.cs
- CompilerGeneratedAttribute.cs
- HtmlInputButton.cs
- OptionalColumn.cs
- Tool.cs
- Underline.cs
- SafeBitVector32.cs
- SafeHandles.cs
- WebReferencesBuildProvider.cs
- CodeDomConfigurationHandler.cs
- Attachment.cs
- ApplicationHost.cs
- OdbcConnectionHandle.cs
- HttpAsyncResult.cs
- EventDescriptorCollection.cs
- SelectedGridItemChangedEvent.cs
- AsymmetricSignatureFormatter.cs
- DayRenderEvent.cs
- SHA1.cs
- StackOverflowException.cs
- QilChoice.cs
- ConfigurationProperty.cs
- AppDomainManager.cs
- BindingListCollectionView.cs
- DataConnectionHelper.cs
- SQLDecimalStorage.cs
- DATA_BLOB.cs
- PartitionerStatic.cs
- GetPolicyDetailsRequest.cs
- DataKeyArray.cs
- GeometryGroup.cs
- HttpChannelListener.cs
- NodeCounter.cs
- HttpWebRequest.cs
- LayoutTable.cs
- ValidationRule.cs
- HistoryEventArgs.cs
- ErrorFormatter.cs
- Int32Converter.cs
- XmlHierarchicalEnumerable.cs
- EntityContainerEmitter.cs
- FrugalMap.cs
- NonParentingControl.cs
- WsdlBuildProvider.cs
- Bidi.cs
- MenuBindingsEditor.cs
- Screen.cs
- RemotingConfigParser.cs
- AffineTransform3D.cs
- DecimalSumAggregationOperator.cs
- XmlDictionary.cs
- GifBitmapEncoder.cs
- StaticResourceExtension.cs
- InputLanguageSource.cs
- CannotUnloadAppDomainException.cs
- DockPanel.cs
- InfoCardCryptoHelper.cs
- AsnEncodedData.cs
- LookupBindingPropertiesAttribute.cs
- DbTypeMap.cs
- Geometry.cs
- PropertyEmitter.cs
- FloatSumAggregationOperator.cs
- HierarchicalDataSourceControl.cs
- ResourcesGenerator.cs