Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / Drawing.cs / 1305600 / Drawing.cs
//----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Description: Drawing is the base Drawing class that defines the standard
// interface which Drawing's must implement.
//
// History:
// 2003/07/16 : [....] - Created it.
// 2003/07/28 : [....] - Renamed it and hooked it up to the unmanaged code.
// 2004/11/17 : timothyc - Repurposed Drawing from being a Changeable
// implementation that contains render data into the base
// class for the enumerable & modifiable Drawing subclasses.
// 2005/01/26 : timothyc - Made Drawing abstract & removed legacy Drawing
// support, including .Open() & IAddChild.
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Resources;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using System.Windows.Threading;
namespace System.Windows.Media
{
///
/// Base class for the enumerable and modifiable Drawing subclasses.
///
[Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
public abstract partial class Drawing : Animatable, IDrawingContent, DUCE.IResource
{
#region Constructors
///
/// Constructor for Drawing
///
///
/// This constructor is internal to prevent external subclassing.
///
internal Drawing()
{
}
#endregion Constructors
#region Public Properties
///
/// Bounds - the axis-aligned bounds of this Drawing.
///
///
/// Rect - the axis-aligned bounds of this Drawing.
///
public Rect Bounds
{
get
{
ReadPreamble();
return GetBounds();
}
}
#endregion Public Properties
#region Internal Methods
///
/// Calls methods on the DrawingContext that are equivalent to the
/// Drawing with the Drawing's current value.
///
internal abstract void WalkCurrentValue(DrawingContextWalker ctx);
#endregion Internal Methods
///
/// Returns the bounding box occupied by the content
///
///
/// Bounding box occupied by the content
///
Rect IDrawingContent.GetContentBounds(BoundsDrawingContextWalker ctx)
{
Debug.Assert(ctx != null);
WalkCurrentValue(ctx);
return ctx.Bounds;
}
///
/// Forward the current value of the content to the DrawingContextWalker
/// methods.
///
/// DrawingContextWalker to forward content to.
void IDrawingContent.WalkContent(DrawingContextWalker ctx)
{
((Drawing)this).WalkCurrentValue(ctx);
}
///
/// Determines whether or not a point exists within the content
///
/// Point to hit-test for.
///
/// 'true' if the point exists within the content, 'false' otherwise
///
bool IDrawingContent.HitTestPoint(Point point)
{
return DrawingServices.HitTestPoint(this, point);
}
///
/// Hit-tests a geometry against this content
///
/// PathGeometry to hit-test for.
///
/// IntersectionDetail describing the result of the hit-test
///
IntersectionDetail IDrawingContent.HitTestGeometry(PathGeometry geometry)
{
return DrawingServices.HitTestGeometry(this, geometry);
}
///
/// Propagates an event handler to Freezables referenced by
/// the content.
///
/// Event handler to propagate
/// 'true' to add the handler, 'false' to remove it
void IDrawingContent.PropagateChangedHandler(EventHandler handler, bool adding)
{
if (!IsFrozen)
{
if (adding)
{
((Drawing)this).Changed += handler;
}
else
{
((Drawing)this).Changed -= handler;
}
}
}
///
/// GetBounds to calculate the bounds of this drawing.
///
internal Rect GetBounds()
{
BoundsDrawingContextWalker ctx = new BoundsDrawingContextWalker();
WalkCurrentValue(ctx);
return ctx.Bounds;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Description: Drawing is the base Drawing class that defines the standard
// interface which Drawing's must implement.
//
// History:
// 2003/07/16 : [....] - Created it.
// 2003/07/28 : [....] - Renamed it and hooked it up to the unmanaged code.
// 2004/11/17 : timothyc - Repurposed Drawing from being a Changeable
// implementation that contains render data into the base
// class for the enumerable & modifiable Drawing subclasses.
// 2005/01/26 : timothyc - Made Drawing abstract & removed legacy Drawing
// support, including .Open() & IAddChild.
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Resources;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using System.Windows.Threading;
namespace System.Windows.Media
{
///
/// Base class for the enumerable and modifiable Drawing subclasses.
///
[Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
public abstract partial class Drawing : Animatable, IDrawingContent, DUCE.IResource
{
#region Constructors
///
/// Constructor for Drawing
///
///
/// This constructor is internal to prevent external subclassing.
///
internal Drawing()
{
}
#endregion Constructors
#region Public Properties
///
/// Bounds - the axis-aligned bounds of this Drawing.
///
///
/// Rect - the axis-aligned bounds of this Drawing.
///
public Rect Bounds
{
get
{
ReadPreamble();
return GetBounds();
}
}
#endregion Public Properties
#region Internal Methods
///
/// Calls methods on the DrawingContext that are equivalent to the
/// Drawing with the Drawing's current value.
///
internal abstract void WalkCurrentValue(DrawingContextWalker ctx);
#endregion Internal Methods
///
/// Returns the bounding box occupied by the content
///
///
/// Bounding box occupied by the content
///
Rect IDrawingContent.GetContentBounds(BoundsDrawingContextWalker ctx)
{
Debug.Assert(ctx != null);
WalkCurrentValue(ctx);
return ctx.Bounds;
}
///
/// Forward the current value of the content to the DrawingContextWalker
/// methods.
///
/// DrawingContextWalker to forward content to.
void IDrawingContent.WalkContent(DrawingContextWalker ctx)
{
((Drawing)this).WalkCurrentValue(ctx);
}
///
/// Determines whether or not a point exists within the content
///
/// Point to hit-test for.
///
/// 'true' if the point exists within the content, 'false' otherwise
///
bool IDrawingContent.HitTestPoint(Point point)
{
return DrawingServices.HitTestPoint(this, point);
}
///
/// Hit-tests a geometry against this content
///
/// PathGeometry to hit-test for.
///
/// IntersectionDetail describing the result of the hit-test
///
IntersectionDetail IDrawingContent.HitTestGeometry(PathGeometry geometry)
{
return DrawingServices.HitTestGeometry(this, geometry);
}
///
/// Propagates an event handler to Freezables referenced by
/// the content.
///
/// Event handler to propagate
/// 'true' to add the handler, 'false' to remove it
void IDrawingContent.PropagateChangedHandler(EventHandler handler, bool adding)
{
if (!IsFrozen)
{
if (adding)
{
((Drawing)this).Changed += handler;
}
else
{
((Drawing)this).Changed -= handler;
}
}
}
///
/// GetBounds to calculate the bounds of this drawing.
///
internal Rect GetBounds()
{
BoundsDrawingContextWalker ctx = new BoundsDrawingContextWalker();
WalkCurrentValue(ctx);
return ctx.Bounds;
}
}
}
// 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
- SqlReferenceCollection.cs
- CheckedPointers.cs
- FormViewInsertedEventArgs.cs
- TimeSpanMinutesConverter.cs
- DesignSurfaceEvent.cs
- NavigationProgressEventArgs.cs
- SQLChars.cs
- TextHidden.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- FontWeights.cs
- DateTimeOffsetStorage.cs
- ConfigurationLockCollection.cs
- CellConstantDomain.cs
- ScalarType.cs
- XhtmlConformanceSection.cs
- ThousandthOfEmRealDoubles.cs
- CodeGotoStatement.cs
- PenContext.cs
- TextCollapsingProperties.cs
- DeviceContext2.cs
- ServiceActivationException.cs
- ForwardPositionQuery.cs
- WeakReadOnlyCollection.cs
- NonBatchDirectoryCompiler.cs
- ExtractedStateEntry.cs
- HMACSHA384.cs
- ButtonFieldBase.cs
- DPCustomTypeDescriptor.cs
- DataContractAttribute.cs
- WebPartVerb.cs
- HtmlUtf8RawTextWriter.cs
- CookielessHelper.cs
- ExpressionPrinter.cs
- LoginUtil.cs
- ScrollBar.cs
- GeometryCollection.cs
- XmlAttributeCollection.cs
- FileSecurity.cs
- EpmAttributeNameBuilder.cs
- RequestCacheValidator.cs
- SEHException.cs
- RemotingClientProxy.cs
- URI.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- PasswordRecovery.cs
- DataListItemEventArgs.cs
- SqlProviderManifest.cs
- ClientConfigurationSystem.cs
- ConfigurationSection.cs
- OrderPreservingSpoolingTask.cs
- Environment.cs
- DiagnosticEventProvider.cs
- _ListenerAsyncResult.cs
- TreeWalker.cs
- MemberPathMap.cs
- PageCatalogPart.cs
- SoapWriter.cs
- DataGridColumnCollection.cs
- AudioLevelUpdatedEventArgs.cs
- MatrixAnimationBase.cs
- UIElement3D.cs
- XmlSchemaNotation.cs
- XmlSchemaFacet.cs
- DataGridViewTopRowAccessibleObject.cs
- RepeaterItemEventArgs.cs
- DataGridBoolColumn.cs
- PropertyValueChangedEvent.cs
- SqlBuilder.cs
- _Connection.cs
- DataListCommandEventArgs.cs
- XmlNode.cs
- XmlTextReaderImplHelpers.cs
- ConfigXmlElement.cs
- TypeLibConverter.cs
- OracleParameter.cs
- IPAddressCollection.cs
- OdbcCommandBuilder.cs
- BrowsableAttribute.cs
- MailWebEventProvider.cs
- MediaEntryAttribute.cs
- COM2ComponentEditor.cs
- InfoCardRSACryptoProvider.cs
- SafeCryptoHandles.cs
- GenericUriParser.cs
- NativeObjectSecurity.cs
- ExtentCqlBlock.cs
- BStrWrapper.cs
- BrowserCapabilitiesCodeGenerator.cs
- BinaryReader.cs
- COM2PropertyPageUITypeConverter.cs
- SQLInt64.cs
- Mappings.cs
- XmlWellformedWriterHelpers.cs
- Literal.cs
- UnknownWrapper.cs
- ExpressionVisitor.cs
- SemanticResultValue.cs
- ConnectionInterfaceCollection.cs
- DeflateStream.cs
- PageRouteHandler.cs