Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- IFlowDocumentViewer.cs
- BrowserCapabilitiesFactory35.cs
- UnsafeNativeMethodsPenimc.cs
- SqlDataSourceView.cs
- BindingsCollection.cs
- StaticSiteMapProvider.cs
- PropertyValueUIItem.cs
- WinEventTracker.cs
- CompressStream.cs
- OneOf.cs
- StringHelper.cs
- xml.cs
- RefExpr.cs
- WpfWebRequestHelper.cs
- TextCollapsingProperties.cs
- MessageQueueInstaller.cs
- RtfControls.cs
- SqlDataReader.cs
- GraphicsState.cs
- EntityCommandDefinition.cs
- DataSourceCacheDurationConverter.cs
- ResourceFallbackManager.cs
- MulticastIPAddressInformationCollection.cs
- EtwTrace.cs
- WindowInteractionStateTracker.cs
- oledbmetadatacolumnnames.cs
- DataGridTablesFactory.cs
- DataGridState.cs
- RealProxy.cs
- PropertyEmitterBase.cs
- XpsSerializationManagerAsync.cs
- SafeMarshalContext.cs
- Rectangle.cs
- WebServiceEnumData.cs
- IsolatedStorageSecurityState.cs
- GcHandle.cs
- RegexCode.cs
- ExceptionCollection.cs
- XPathScanner.cs
- Transform.cs
- SqlDataAdapter.cs
- URLString.cs
- ClientApiGenerator.cs
- GetRecipientRequest.cs
- HTMLTagNameToTypeMapper.cs
- SafeArrayTypeMismatchException.cs
- HtmlInputButton.cs
- WorkflowRuntime.cs
- ThumbAutomationPeer.cs
- ClientCultureInfo.cs
- SecurityException.cs
- FileDataSourceCache.cs
- DataKey.cs
- DateTimeStorage.cs
- ControlAdapter.cs
- Type.cs
- StringComparer.cs
- SoapIncludeAttribute.cs
- Light.cs
- WorkflowCommandExtensionItem.cs
- HighlightComponent.cs
- SecureUICommand.cs
- SafeEventHandle.cs
- XmlSchemaNotation.cs
- ClaimComparer.cs
- EventToken.cs
- WorkflowOperationErrorHandler.cs
- ArraySubsetEnumerator.cs
- ButtonChrome.cs
- WrappingXamlSchemaContext.cs
- ConfigurationSectionCollection.cs
- IPHostEntry.cs
- DataContract.cs
- BinaryFormatterSinks.cs
- Stacktrace.cs
- RadioButtonBaseAdapter.cs
- ValueOfAction.cs
- WmlImageAdapter.cs
- DbConnectionPoolGroupProviderInfo.cs
- DataBindingExpressionBuilder.cs
- CompilerResults.cs
- XmlQuerySequence.cs
- IProducerConsumerCollection.cs
- TemplatedWizardStep.cs
- WrappedIUnknown.cs
- TargetPerspective.cs
- StringKeyFrameCollection.cs
- TableParaClient.cs
- RequestResizeEvent.cs
- _DynamicWinsockMethods.cs
- XmlDataSourceNodeDescriptor.cs
- MulticastOption.cs
- hresults.cs
- CodeCastExpression.cs
- UserControlParser.cs
- MethodAccessException.cs
- CanonicalXml.cs
- Clipboard.cs
- SamlAttributeStatement.cs
- ApplicationProxyInternal.cs