Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CommonUI / System / Drawing / Brush.cs / 1 / Brush.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /*************************************************************************\ * * Copyright (c) 1998-1999, Microsoft Corp. All Rights Reserved. * * Module Name: * * Brush.cs * * Abstract: * * COM+ wrapper for GDI+ brush objects * * Revision History: * * 01/11/1999 davidx * Code review. * * 12/15/1998 [....] * Created it. * \**************************************************************************/ 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. // Copyright (c) Microsoft Corporation. All rights reserved./// Releases memory allocated for this ///. ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BufferModeSettings.cs
- UIElement.cs
- DocumentSequenceHighlightLayer.cs
- ContextStaticAttribute.cs
- CompositeCollection.cs
- DataFormat.cs
- CounterSample.cs
- InitiatorSessionSymmetricTransportSecurityProtocol.cs
- EncryptedData.cs
- EnumerableRowCollection.cs
- CachedBitmap.cs
- GroupByExpressionRewriter.cs
- SignatureConfirmations.cs
- Group.cs
- DmlSqlGenerator.cs
- IndexedString.cs
- FontFamilyValueSerializer.cs
- StringResourceManager.cs
- MailWebEventProvider.cs
- GenericWebPart.cs
- ReaderWriterLockWrapper.cs
- MachineKeySection.cs
- SystemColors.cs
- FormatException.cs
- XmlILIndex.cs
- SingleResultAttribute.cs
- EpmTargetPathSegment.cs
- ContextMenuAutomationPeer.cs
- X509Certificate2Collection.cs
- Section.cs
- ControlIdConverter.cs
- ZoneIdentityPermission.cs
- ReferencedType.cs
- BufferedGraphics.cs
- TrackBar.cs
- RetrieveVirtualItemEventArgs.cs
- DbConnectionPoolIdentity.cs
- BindingMemberInfo.cs
- CompatibleComparer.cs
- DesignerDataView.cs
- WebPartsSection.cs
- RenderOptions.cs
- BatchServiceHost.cs
- PointCollectionValueSerializer.cs
- OleDbRowUpdatedEvent.cs
- FontStyleConverter.cs
- SqlNotificationEventArgs.cs
- ReadOnlyNameValueCollection.cs
- ConstrainedGroup.cs
- StrokeCollectionConverter.cs
- ApplicationContext.cs
- xmlglyphRunInfo.cs
- DataBindingList.cs
- TemplatedAdorner.cs
- RootDesignerSerializerAttribute.cs
- WebPartUserCapability.cs
- FrugalMap.cs
- ToolBarButtonClickEvent.cs
- TraceEventCache.cs
- OperationCanceledException.cs
- DatePickerDateValidationErrorEventArgs.cs
- EntityObject.cs
- ActivityMarkupSerializationProvider.cs
- NetCodeGroup.cs
- WindowsFormsSectionHandler.cs
- MdiWindowListItemConverter.cs
- HttpApplication.cs
- columnmapkeybuilder.cs
- HitTestWithGeometryDrawingContextWalker.cs
- Rect3DConverter.cs
- InternalResources.cs
- SafeWaitHandle.cs
- RSAOAEPKeyExchangeFormatter.cs
- TextRangeBase.cs
- ResumeStoryboard.cs
- WebMessageEncoderFactory.cs
- XmlWrappingReader.cs
- DataViewManager.cs
- CapabilitiesUse.cs
- TreeNodeCollection.cs
- ImageConverter.cs
- XmlNavigatorStack.cs
- TargetInvocationException.cs
- PackUriHelper.cs
- ToolboxItemLoader.cs
- TextSpanModifier.cs
- TextChange.cs
- DrawingServices.cs
- ExpressionBinding.cs
- TextUtf8RawTextWriter.cs
- GridViewCellAutomationPeer.cs
- QuestionEventArgs.cs
- ErrorHandler.cs
- GeneralTransform3D.cs
- SqlConnectionPoolGroupProviderInfo.cs
- CreateUserWizard.cs
- MarginsConverter.cs
- CollectionChangeEventArgs.cs
- ClientConvert.cs
- SafeNativeMethodsMilCoreApi.cs