Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Advanced / HatchBrush.cs / 1305376 / HatchBrush.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Drawing2D {
using System.Runtime.InteropServices;
using System.Diagnostics;
using System;
using System.Drawing;
using System.ComponentModel;
using Microsoft.Win32;
using System.Drawing.Internal;
using System.Runtime.Versioning;
/**
* Represent a HatchBrush brush object
*/
///
///
/// Defines a rectangular brush with a hatch
/// style, a foreground color, and a background color.
///
public sealed class HatchBrush : Brush
{
/**
* Create a new hatch brush object
*/
///
///
///
/// Initializes a new instance of the class with the specified and foreground color.
///
///
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
public HatchBrush(HatchStyle hatchstyle, Color foreColor) :
this(hatchstyle, foreColor, Color.FromArgb( (int) unchecked( (int) 0xff000000) ) )
{
}
///
///
///
/// Initializes a new instance of the class with the specified ,
/// foreground color, and background color.
///
///
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
public HatchBrush(HatchStyle hatchstyle, Color foreColor, Color backColor)
{
IntPtr brush = IntPtr.Zero;
int status = SafeNativeMethods.Gdip.GdipCreateHatchBrush((int) hatchstyle, foreColor.ToArgb(), backColor.ToArgb(), out brush);
if (status != SafeNativeMethods.Gdip.Ok)
throw SafeNativeMethods.Gdip.StatusException(status);
SetNativeBrushInternal(brush);
}
///
/// Constructor to initialize this object from a GDI+ native reference.
///
internal HatchBrush(IntPtr nativeBrush )
{
Debug.Assert( nativeBrush != IntPtr.Zero, "Initializing native brush with null." );
SetNativeBrushInternal( nativeBrush );
}
///
///
/// Creates an exact copy of this .
///
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
public override object Clone()
{
IntPtr cloneBrush = IntPtr.Zero;
int status = SafeNativeMethods.Gdip.GdipCloneBrush(new HandleRef(this, this.NativeBrush), out cloneBrush);
if (status != SafeNativeMethods.Gdip.Ok)
throw SafeNativeMethods.Gdip.StatusException(status);
return new HatchBrush(cloneBrush);
}
/**
* Get hatch brush object attributes
*/
///
///
/// Gets the hatch style of this .
///
public HatchStyle HatchStyle
{
get {
int hatchStyle = 0;
int status = SafeNativeMethods.Gdip.GdipGetHatchStyle(new HandleRef(this, this.NativeBrush), out hatchStyle);
if (status != SafeNativeMethods.Gdip.Ok)
throw SafeNativeMethods.Gdip.StatusException(status);
return (HatchStyle) hatchStyle;
}
}
///
///
/// Gets the color of hatch lines drawn by this
/// .
///
public Color ForegroundColor
{
get {
int forecol;
int status = SafeNativeMethods.Gdip.GdipGetHatchForegroundColor(new HandleRef(this, this.NativeBrush), out forecol);
if (status != SafeNativeMethods.Gdip.Ok)
throw SafeNativeMethods.Gdip.StatusException(status);
return Color.FromArgb(forecol);
}
}
///
///
///
/// Gets the color of spaces between the hatch
/// lines drawn by this .
///
///
public Color BackgroundColor
{
get {
int backcol;
int status = SafeNativeMethods.Gdip.GdipGetHatchBackgroundColor(new HandleRef(this, this.NativeBrush), out backcol);
if (status != SafeNativeMethods.Gdip.Ok)
throw SafeNativeMethods.Gdip.StatusException(status);
return Color.FromArgb(backcol);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RuleSettings.cs
- Subset.cs
- EdgeProfileValidation.cs
- ExtenderHelpers.cs
- FunctionMappingTranslator.cs
- Int32CollectionValueSerializer.cs
- TextEditorMouse.cs
- VariableQuery.cs
- ProtectedConfigurationProviderCollection.cs
- CompositeTypefaceMetrics.cs
- TraceSwitch.cs
- UIElementPropertyUndoUnit.cs
- Form.cs
- DelegateHelpers.Generated.cs
- ObjectConverter.cs
- BitmapEffectInput.cs
- RowToParametersTransformer.cs
- AutomationIdentifierGuids.cs
- HtmlInputPassword.cs
- PackagePart.cs
- MenuItem.cs
- Animatable.cs
- DesigntimeLicenseContextSerializer.cs
- XmlAnyElementAttribute.cs
- CriticalFinalizerObject.cs
- ControlCachePolicy.cs
- DesignerActionHeaderItem.cs
- Timer.cs
- AmbiguousMatchException.cs
- BitmapPalette.cs
- MsmqIntegrationValidationBehavior.cs
- QilXmlWriter.cs
- PeerInputChannel.cs
- AuthenticationService.cs
- XamlStyleSerializer.cs
- ArcSegment.cs
- CodeMemberMethod.cs
- InputScopeAttribute.cs
- QualifiedCellIdBoolean.cs
- XmlReflectionImporter.cs
- SimpleWorkerRequest.cs
- AuthenticateEventArgs.cs
- NamedPipeConnectionPoolSettingsElement.cs
- RightsManagementEncryptedStream.cs
- _BufferOffsetSize.cs
- Bitmap.cs
- XPathPatternParser.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- Utils.cs
- Ppl.cs
- Debug.cs
- StateManagedCollection.cs
- InstanceDescriptor.cs
- StrongNameKeyPair.cs
- XamlStream.cs
- CodeActivityMetadata.cs
- XmlNavigatorFilter.cs
- NativeObjectSecurity.cs
- MailAddressCollection.cs
- ClockController.cs
- ViewCellRelation.cs
- NullableConverter.cs
- XamlContextStack.cs
- UIElement.cs
- WCFServiceClientProxyGenerator.cs
- ELinqQueryState.cs
- MatrixCamera.cs
- filewebresponse.cs
- ThreadStateException.cs
- BitmapMetadataBlob.cs
- SafeRightsManagementEnvironmentHandle.cs
- RestHandler.cs
- ConfigurationProperty.cs
- EventSinkHelperWriter.cs
- Completion.cs
- EncoderParameter.cs
- CommentEmitter.cs
- ToolStripGrip.cs
- PlatformCulture.cs
- ColorAnimationBase.cs
- XmlIncludeAttribute.cs
- ExpressionBindings.cs
- WhitespaceRule.cs
- Int64AnimationBase.cs
- TypedServiceChannelBuilder.cs
- CriticalFinalizerObject.cs
- DrawingContextWalker.cs
- DragDrop.cs
- Size.cs
- DesignerAdRotatorAdapter.cs
- VisualStates.cs
- XmlValidatingReaderImpl.cs
- SchemaEntity.cs
- XmlTextReaderImplHelpers.cs
- XmlSchemaAppInfo.cs
- Light.cs
- SqlTriggerContext.cs
- SoapHeader.cs
- TemplateManager.cs
- EncryptedReference.cs