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
- FileAuthorizationModule.cs
- FamilyMapCollection.cs
- LocalServiceSecuritySettings.cs
- _NegotiateClient.cs
- DocumentPageView.cs
- PointCollection.cs
- Rules.cs
- DiscreteKeyFrames.cs
- WebScriptClientGenerator.cs
- ImageListStreamer.cs
- UnsafeNativeMethodsTablet.cs
- CallContext.cs
- Drawing.cs
- SqlReorderer.cs
- DesignerHelpers.cs
- AppSettings.cs
- HttpBrowserCapabilitiesBase.cs
- MessageQueue.cs
- WebBrowser.cs
- XmlIlGenerator.cs
- X509Extension.cs
- ArrowControl.xaml.cs
- RoutedEventHandlerInfo.cs
- DataListItem.cs
- TraceSection.cs
- MissingMemberException.cs
- StorageAssociationTypeMapping.cs
- ThousandthOfEmRealDoubles.cs
- DataGridToolTip.cs
- PaintEvent.cs
- ConcatQueryOperator.cs
- StructureChangedEventArgs.cs
- UInt32Storage.cs
- SqlErrorCollection.cs
- DiscoveryInnerClientManaged11.cs
- Evaluator.cs
- JoinSymbol.cs
- DataBindEngine.cs
- OdbcConnectionOpen.cs
- SamlSerializer.cs
- MouseEventArgs.cs
- AsymmetricSignatureFormatter.cs
- SendKeys.cs
- BindingBase.cs
- IssuedTokenClientBehaviorsElementCollection.cs
- HostedNamedPipeTransportManager.cs
- DbgUtil.cs
- NotCondition.cs
- EncryptedKeyIdentifierClause.cs
- StylusEventArgs.cs
- TextOnlyOutput.cs
- CodeRegionDirective.cs
- BuildProviderAppliesToAttribute.cs
- NavigationEventArgs.cs
- DefaultValueTypeConverter.cs
- ToolStripScrollButton.cs
- DaylightTime.cs
- TiffBitmapDecoder.cs
- LifetimeManager.cs
- XPathEmptyIterator.cs
- WSSecureConversationFeb2005.cs
- StreamInfo.cs
- Int32.cs
- UrlPath.cs
- PeerNearMe.cs
- DeclarativeCatalogPartDesigner.cs
- ContainerAction.cs
- SafeNativeMethods.cs
- ScriptRegistrationManager.cs
- CodeEventReferenceExpression.cs
- BuiltInPermissionSets.cs
- WindowsSolidBrush.cs
- ClientOptions.cs
- Empty.cs
- XmlSchemaFacet.cs
- OperationContractAttribute.cs
- RowsCopiedEventArgs.cs
- DataObjectPastingEventArgs.cs
- HtmlMeta.cs
- Utils.cs
- MultiSelectRootGridEntry.cs
- AssemblyLoader.cs
- XmlCompatibilityReader.cs
- EvidenceBase.cs
- SchemaAttDef.cs
- NetPipeSection.cs
- IPEndPointCollection.cs
- Queue.cs
- TextTreeTextElementNode.cs
- NamespaceInfo.cs
- SelectionProviderWrapper.cs
- ResourceContainerWrapper.cs
- MouseButtonEventArgs.cs
- X509Chain.cs
- ChannelFactory.cs
- StorageFunctionMapping.cs
- BigInt.cs
- BindingList.cs
- XmlNamespaceMapping.cs
- ToolStripDropDownClosedEventArgs.cs