Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Documents / AdornerDecorator.cs / 1 / AdornerDecorator.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description:
// AdornerDecorator class.
// See spec at: http://avalon/uis/Specs/AdornerLayer%20Spec.htm
//
// History:
// 1/29/2004 psarrett: Created
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace System.Windows.Documents
{
///
/// This AdornerDecorator does not hookup its child in the logical tree. It's being
/// used by PopupRoot and FixedDocument.
///
internal class NonLogicalAdornerDecorator : AdornerDecorator
{
public override UIElement Child
{
get
{
return IntChild;
}
set
{
if (IntChild != value)
{
this.RemoveVisualChild(IntChild);
this.RemoveVisualChild(AdornerLayer);
IntChild = value;
if(value != null)
{
this.AddVisualChild(value);
this.AddVisualChild(AdornerLayer);
}
InvalidateMeasure();
}
}
}
}
///
/// Object which allows elements beneath it in the visual tree to be adorned.
/// AdornerDecorator has two children.
/// The first child is the parent of the rest of the visual tree below the AdornerDecorator.
/// The second child is the AdornerLayer on which adorners are rendered.
///
/// AdornerDecorator is intended to be used as part of an object's Style.
///
public class AdornerDecorator : Decorator
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructor
///
public AdornerDecorator() : base()
{
_adornerLayer = new AdornerLayer();
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
///
/// AdornerLayer on which adorners are rendered.
///
public AdornerLayer AdornerLayer
{
get
{
return _adornerLayer;
}
}
#endregion Public Properties
//-----------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
#region Protected Methods
///
/// Measurement override. Implement your size-to-content logic here.
///
///
/// Sizing constraint.
///
protected override Size MeasureOverride(Size constraint)
{
Size desiredSize = base.MeasureOverride(constraint);
if (VisualTreeHelper.GetParent(_adornerLayer) != null)
{
// We don't really care about the size of the AdornerLayer-- we'll
// always just make the AdornerDecorator the full desiredSize. But
// we need to measure it anyway, to make sure Adorners render.
_adornerLayer.Measure(constraint);
}
return desiredSize;
}
///
/// Override for
///
/// The size reserved for this element by the parent
/// The actual ink area of the element, typically the same as finalSize
protected override Size ArrangeOverride(Size finalSize)
{
Size inkSize = base.ArrangeOverride(finalSize);
if (VisualTreeHelper.GetParent(_adornerLayer) != null)
{
_adornerLayer.Arrange(new Rect(finalSize));
}
return (inkSize);
}
///
/// Gets or sets the child of the AdornerDecorator.
///
public override UIElement Child
{
get
{
return base.Child;
}
set
{
Visual old = base.Child;
if (old == value)
{
return;
}
if (value == null)
{
base.Child = null;
RemoveVisualChild(_adornerLayer);
}
else
{
base.Child = value;
AddVisualChild(_adornerLayer);
}
}
}
///
/// Returns the Visual children count.
///
protected override int VisualChildrenCount
{
get
{
if (base.Child != null)
{
return 2; // One for the child and one for the adorner layer.
}
else
{
return 0;
}
}
}
///
/// Returns the child at the specified index.
///
protected override Visual GetVisualChild(int index)
{
if (base.Child == null)
{
throw new ArgumentOutOfRangeException("index", index, SR.Get(SRID.Visual_ArgumentOutOfRange));
}
else
{
switch (index)
{
case 0:
return base.Child;
case 1:
return _adornerLayer;
default:
throw new ArgumentOutOfRangeException("index", index, SR.Get(SRID.Visual_ArgumentOutOfRange));
}
}
}
#endregion Protected Methods
//-----------------------------------------------------
//
// Private Members
//
//-----------------------------------------------------
#region Private Members
//
// This property
// 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject
// 2. This is a performance optimization
//
internal override int EffectiveValuesInitialSize
{
get { return 6; }
}
readonly AdornerLayer _adornerLayer;
#endregion Private Members
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description:
// AdornerDecorator class.
// See spec at: http://avalon/uis/Specs/AdornerLayer%20Spec.htm
//
// History:
// 1/29/2004 psarrett: Created
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace System.Windows.Documents
{
///
/// This AdornerDecorator does not hookup its child in the logical tree. It's being
/// used by PopupRoot and FixedDocument.
///
internal class NonLogicalAdornerDecorator : AdornerDecorator
{
public override UIElement Child
{
get
{
return IntChild;
}
set
{
if (IntChild != value)
{
this.RemoveVisualChild(IntChild);
this.RemoveVisualChild(AdornerLayer);
IntChild = value;
if(value != null)
{
this.AddVisualChild(value);
this.AddVisualChild(AdornerLayer);
}
InvalidateMeasure();
}
}
}
}
///
/// Object which allows elements beneath it in the visual tree to be adorned.
/// AdornerDecorator has two children.
/// The first child is the parent of the rest of the visual tree below the AdornerDecorator.
/// The second child is the AdornerLayer on which adorners are rendered.
///
/// AdornerDecorator is intended to be used as part of an object's Style.
///
public class AdornerDecorator : Decorator
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructor
///
public AdornerDecorator() : base()
{
_adornerLayer = new AdornerLayer();
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
///
/// AdornerLayer on which adorners are rendered.
///
public AdornerLayer AdornerLayer
{
get
{
return _adornerLayer;
}
}
#endregion Public Properties
//-----------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
#region Protected Methods
///
/// Measurement override. Implement your size-to-content logic here.
///
///
/// Sizing constraint.
///
protected override Size MeasureOverride(Size constraint)
{
Size desiredSize = base.MeasureOverride(constraint);
if (VisualTreeHelper.GetParent(_adornerLayer) != null)
{
// We don't really care about the size of the AdornerLayer-- we'll
// always just make the AdornerDecorator the full desiredSize. But
// we need to measure it anyway, to make sure Adorners render.
_adornerLayer.Measure(constraint);
}
return desiredSize;
}
///
/// Override for
///
/// The size reserved for this element by the parent
/// The actual ink area of the element, typically the same as finalSize
protected override Size ArrangeOverride(Size finalSize)
{
Size inkSize = base.ArrangeOverride(finalSize);
if (VisualTreeHelper.GetParent(_adornerLayer) != null)
{
_adornerLayer.Arrange(new Rect(finalSize));
}
return (inkSize);
}
///
/// Gets or sets the child of the AdornerDecorator.
///
public override UIElement Child
{
get
{
return base.Child;
}
set
{
Visual old = base.Child;
if (old == value)
{
return;
}
if (value == null)
{
base.Child = null;
RemoveVisualChild(_adornerLayer);
}
else
{
base.Child = value;
AddVisualChild(_adornerLayer);
}
}
}
///
/// Returns the Visual children count.
///
protected override int VisualChildrenCount
{
get
{
if (base.Child != null)
{
return 2; // One for the child and one for the adorner layer.
}
else
{
return 0;
}
}
}
///
/// Returns the child at the specified index.
///
protected override Visual GetVisualChild(int index)
{
if (base.Child == null)
{
throw new ArgumentOutOfRangeException("index", index, SR.Get(SRID.Visual_ArgumentOutOfRange));
}
else
{
switch (index)
{
case 0:
return base.Child;
case 1:
return _adornerLayer;
default:
throw new ArgumentOutOfRangeException("index", index, SR.Get(SRID.Visual_ArgumentOutOfRange));
}
}
}
#endregion Protected Methods
//-----------------------------------------------------
//
// Private Members
//
//-----------------------------------------------------
#region Private Members
//
// This property
// 1. Finds the correct initial size for the _effectiveValues store on the current DependencyObject
// 2. This is a performance optimization
//
internal override int EffectiveValuesInitialSize
{
get { return 6; }
}
readonly AdornerLayer _adornerLayer;
#endregion Private Members
}
}
// 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
- GridViewAutoFormat.cs
- PipelineComponent.cs
- Compiler.cs
- ProcessManager.cs
- Point4DValueSerializer.cs
- XmlQueryCardinality.cs
- PerspectiveCamera.cs
- TextDecorationCollectionConverter.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ListenDesigner.cs
- SHA256.cs
- LoadedOrUnloadedOperation.cs
- HttpPostClientProtocol.cs
- OperationResponse.cs
- HierarchicalDataBoundControl.cs
- BitVector32.cs
- SoapClientProtocol.cs
- Semaphore.cs
- ClosureBinding.cs
- Vector3DAnimation.cs
- ExpanderAutomationPeer.cs
- DragDeltaEventArgs.cs
- ButtonColumn.cs
- HiddenField.cs
- UnsafeNativeMethods.cs
- EventMappingSettingsCollection.cs
- SByteConverter.cs
- XmlBindingWorker.cs
- CurrencyWrapper.cs
- IOThreadTimer.cs
- printdlgexmarshaler.cs
- RegisteredExpandoAttribute.cs
- safesecurityhelperavalon.cs
- ToolStripGrip.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- WindowsFormsLinkLabel.cs
- Stack.cs
- ComponentDispatcherThread.cs
- RowUpdatingEventArgs.cs
- CurrentChangedEventManager.cs
- ToolStripArrowRenderEventArgs.cs
- EventLogPropertySelector.cs
- OpenFileDialog.cs
- FixedSOMTextRun.cs
- FormViewActionList.cs
- VersionedStream.cs
- AdornerPresentationContext.cs
- _AutoWebProxyScriptHelper.cs
- ProcessHostFactoryHelper.cs
- XmlCompatibilityReader.cs
- mda.cs
- Pen.cs
- WebPartDescription.cs
- ToolStripContentPanelRenderEventArgs.cs
- Rectangle.cs
- wgx_exports.cs
- MetadataArtifactLoader.cs
- SharedPerformanceCounter.cs
- Zone.cs
- AssemblyFilter.cs
- Scene3D.cs
- MimeMapping.cs
- DeviceContext.cs
- XmlParserContext.cs
- IsolatedStorageException.cs
- MessageFormatterConverter.cs
- InternalResources.cs
- RequestQueue.cs
- ValueChangedEventManager.cs
- DecoderExceptionFallback.cs
- ReliableSessionBindingElement.cs
- LogFlushAsyncResult.cs
- ConnectionOrientedTransportManager.cs
- SecurityPolicySection.cs
- ClientSettings.cs
- CheckedPointers.cs
- ItemChangedEventArgs.cs
- ConnectorDragDropGlyph.cs
- MergeFailedEvent.cs
- HttpChannelBindingToken.cs
- UnsafeNativeMethodsTablet.cs
- Geometry3D.cs
- AttributeTable.cs
- PngBitmapEncoder.cs
- HtmlElement.cs
- GridItem.cs
- Canvas.cs
- DBSchemaRow.cs
- Accessible.cs
- BaseDataListActionList.cs
- HostedElements.cs
- ErrorRuntimeConfig.cs
- XmlWellformedWriterHelpers.cs
- indexingfiltermarshaler.cs
- ExpressionsCollectionEditor.cs
- WebPartEditorCancelVerb.cs
- ByteStreamGeometryContext.cs
- Helper.cs
- VisualBrush.cs
- HeaderedContentControl.cs