Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Brush.cs / 1305376 / 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; using System.Security; using System.Security.Permissions; /** * 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) { SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); permission.Demand(); SetNativeBrushInternal(brush); } internal void SetNativeBrushInternal(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 { [System.Runtime.TargetedPatchingOptOutAttribute("Performance critical to inline across NGen image boundaries")] 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; using System.Security; using System.Security.Permissions; /** * 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) { SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); permission.Demand(); SetNativeBrushInternal(brush); } internal void SetNativeBrushInternal(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 { [System.Runtime.TargetedPatchingOptOutAttribute("Performance critical to inline across NGen image boundaries")] 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewRowErrorTextNeededEventArgs.cs
- EncoderNLS.cs
- EditorBrowsableAttribute.cs
- Calendar.cs
- Select.cs
- PropertyConverter.cs
- StylusOverProperty.cs
- ObjectQueryState.cs
- ConfigXmlText.cs
- ExportException.cs
- DbFunctionCommandTree.cs
- DataPointer.cs
- OletxCommittableTransaction.cs
- HttpWebRequest.cs
- PrinterUnitConvert.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- ZipPackagePart.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- ExtendedPropertyDescriptor.cs
- VisualStyleTypesAndProperties.cs
- CommandValueSerializer.cs
- ActivationWorker.cs
- Identifier.cs
- ServiceHostingEnvironment.cs
- TaskHelper.cs
- TextParentUndoUnit.cs
- LockedHandleGlyph.cs
- PriorityQueue.cs
- X509AsymmetricSecurityKey.cs
- shaper.cs
- ToolBarPanel.cs
- SafeEventHandle.cs
- FixedDocumentPaginator.cs
- PrintDialogException.cs
- InvalidateEvent.cs
- MouseEvent.cs
- PropertyPathConverter.cs
- TextWriterTraceListener.cs
- WebPartConnectionsEventArgs.cs
- Command.cs
- UIntPtr.cs
- SelectedGridItemChangedEvent.cs
- ObjectListItemCollection.cs
- HuffmanTree.cs
- AssemblyBuilderData.cs
- SrgsRuleRef.cs
- DynamicPropertyHolder.cs
- BinarySerializer.cs
- UnsupportedPolicyOptionsException.cs
- DiscoveryClientProtocol.cs
- SplashScreenNativeMethods.cs
- SessionEndingCancelEventArgs.cs
- RC2.cs
- FixedSOMLineCollection.cs
- Sql8ConformanceChecker.cs
- __Error.cs
- FixedSOMImage.cs
- ExtensionMethods.cs
- OutputScopeManager.cs
- DataList.cs
- ButtonChrome.cs
- ActiveXHost.cs
- Int16.cs
- BufferModesCollection.cs
- ReferentialConstraint.cs
- SimpleFieldTemplateUserControl.cs
- KeyEvent.cs
- OperatorExpressions.cs
- StylusPlugInCollection.cs
- AlphabeticalEnumConverter.cs
- Form.cs
- FieldReference.cs
- DateTimeOffset.cs
- XPathSelfQuery.cs
- StrongNameUtility.cs
- Marshal.cs
- RelationshipConverter.cs
- DownloadProgressEventArgs.cs
- TrustLevel.cs
- MarkupCompiler.cs
- XmlArrayAttribute.cs
- KeySpline.cs
- TextRangeEditTables.cs
- SelectionHighlightInfo.cs
- WebPartDisplayMode.cs
- UnknownWrapper.cs
- ExceptionList.cs
- CssStyleCollection.cs
- TypeKeyValue.cs
- XamlToRtfParser.cs
- CounterSampleCalculator.cs
- Expressions.cs
- MethodBuilderInstantiation.cs
- PolicyChain.cs
- ToolTip.cs
- InstanceCreationEditor.cs
- SessionEndingCancelEventArgs.cs
- DataGridViewComboBoxColumn.cs
- UriParserTemplates.cs
- TextOutput.cs