Code:
/ FX-1434 / FX-1434 / 1.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
*/
///
///
///
/// 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.
///
///
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.
///
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;
}
}
///
///
///
/// Deletes this .
///
///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(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
*/
///
///
///
/// Releases memory allocated for this .
///
///
~Brush()
{
Dispose(false);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlRetyper.cs
- PreservationFileWriter.cs
- TreeViewBindingsEditor.cs
- QilScopedVisitor.cs
- TableRowCollection.cs
- Image.cs
- ThicknessKeyFrameCollection.cs
- RtfToken.cs
- MarginCollapsingState.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- AppDomainFactory.cs
- Stack.cs
- CodeGroup.cs
- FormViewInsertEventArgs.cs
- RepeatButton.cs
- RadioButton.cs
- WpfKnownTypeInvoker.cs
- EventLogger.cs
- ViewEventArgs.cs
- DataGridCell.cs
- PerformanceCounterLib.cs
- HttpPostProtocolReflector.cs
- ContourSegment.cs
- Options.cs
- Transactions.cs
- dsa.cs
- SimpleMailWebEventProvider.cs
- SizeAnimation.cs
- MatrixTransform.cs
- QueryParameter.cs
- log.cs
- HotSpot.cs
- JavaScriptSerializer.cs
- ResourceDescriptionAttribute.cs
- WorkflowElementDialog.cs
- MenuItemBindingCollection.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- ParallelActivityDesigner.cs
- UnaryQueryOperator.cs
- PtsHost.cs
- MatrixUtil.cs
- DbResourceAllocator.cs
- ObjectConverter.cs
- ElementProxy.cs
- WebServiceErrorEvent.cs
- unitconverter.cs
- DictionaryEntry.cs
- SmiRequestExecutor.cs
- Composition.cs
- SingleObjectCollection.cs
- UInt32Storage.cs
- DrawingServices.cs
- DBConnection.cs
- PropertyPath.cs
- Merger.cs
- WebPartsPersonalizationAuthorization.cs
- WebPartAddingEventArgs.cs
- WindowsSysHeader.cs
- _FtpControlStream.cs
- safesecurityhelperavalon.cs
- ArraySegment.cs
- CompilerState.cs
- CounterSetInstanceCounterDataSet.cs
- PageEventArgs.cs
- PrinterResolution.cs
- XslVisitor.cs
- MediaElement.cs
- TypeConverterAttribute.cs
- LinkGrep.cs
- CuspData.cs
- ModelUIElement3D.cs
- AuthorizationRuleCollection.cs
- OdbcCommandBuilder.cs
- CompileXomlTask.cs
- MemberJoinTreeNode.cs
- EncodingInfo.cs
- StickyNoteContentControl.cs
- ImageListStreamer.cs
- odbcmetadatacollectionnames.cs
- ExpressionBindings.cs
- DataServiceException.cs
- MetabaseSettingsIis7.cs
- SurrogateEncoder.cs
- DetailsViewPageEventArgs.cs
- NonSerializedAttribute.cs
- TypeDescriptionProvider.cs
- GACMembershipCondition.cs
- PasswordRecovery.cs
- ContextMarshalException.cs
- SynchronizationValidator.cs
- ConnectionInterfaceCollection.cs
- ReflectionTypeLoadException.cs
- ParameterBuilder.cs
- DBAsyncResult.cs
- DataFormats.cs
- EmbossBitmapEffect.cs
- LinkLabelLinkClickedEvent.cs
- MULTI_QI.cs
- UInt64.cs
- VectorAnimation.cs