Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DescendentsWalkerBase.cs / 1305600 / DescendentsWalkerBase.cs
using System;
using System.Collections;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using MS.Utility;
namespace System.Windows
{
///
/// This is a base class to the DescendentsWalker. It is factored out so that
/// FrameworkContextData can store and retrieve it from context local storage
/// in a type agnostic manner.
///
internal class DescendentsWalkerBase
{
#region Construction
protected DescendentsWalkerBase(TreeWalkPriority priority)
{
_startNode = null;
_priority = priority;
_recursionDepth = 0;
_nodes = new FrugalStructList();
}
#endregion Construction
internal bool WasVisited(DependencyObject d)
{
DependencyObject ancestor = d;
while ((ancestor != _startNode) && (ancestor != null))
{
DependencyObject logicalParent;
if (FrameworkElement.DType.IsInstanceOfType(ancestor))
{
FrameworkElement fe = ancestor as FrameworkElement;
logicalParent = fe.Parent;
// FrameworkElement
DependencyObject dependencyObjectParent = VisualTreeHelper.GetParent(fe);
if (dependencyObjectParent != null && logicalParent != null && dependencyObjectParent != logicalParent)
{
return _nodes.Contains(ancestor);
}
// Follow visual tree if not null otherwise we follow logical tree
if (dependencyObjectParent != null)
{
ancestor = dependencyObjectParent;
continue;
}
}
else
{
// FrameworkContentElement
FrameworkContentElement ancestorFCE = ancestor as FrameworkContentElement;
logicalParent = (ancestorFCE != null) ? ancestorFCE.Parent : null;
}
ancestor = logicalParent;
}
return (ancestor != null);
}
internal DependencyObject _startNode;
internal TreeWalkPriority _priority;
internal FrugalStructList _nodes;
internal int _recursionDepth;
}
///
/// Enum specifying whether visual tree needs
/// to be travesed first or the logical tree
///
internal enum TreeWalkPriority
{
///
/// Traverse Logical Tree first
///
LogicalTree,
///
/// Traverse Visual Tree first
///
VisualTree
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Collections;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using MS.Utility;
namespace System.Windows
{
///
/// This is a base class to the DescendentsWalker. It is factored out so that
/// FrameworkContextData can store and retrieve it from context local storage
/// in a type agnostic manner.
///
internal class DescendentsWalkerBase
{
#region Construction
protected DescendentsWalkerBase(TreeWalkPriority priority)
{
_startNode = null;
_priority = priority;
_recursionDepth = 0;
_nodes = new FrugalStructList();
}
#endregion Construction
internal bool WasVisited(DependencyObject d)
{
DependencyObject ancestor = d;
while ((ancestor != _startNode) && (ancestor != null))
{
DependencyObject logicalParent;
if (FrameworkElement.DType.IsInstanceOfType(ancestor))
{
FrameworkElement fe = ancestor as FrameworkElement;
logicalParent = fe.Parent;
// FrameworkElement
DependencyObject dependencyObjectParent = VisualTreeHelper.GetParent(fe);
if (dependencyObjectParent != null && logicalParent != null && dependencyObjectParent != logicalParent)
{
return _nodes.Contains(ancestor);
}
// Follow visual tree if not null otherwise we follow logical tree
if (dependencyObjectParent != null)
{
ancestor = dependencyObjectParent;
continue;
}
}
else
{
// FrameworkContentElement
FrameworkContentElement ancestorFCE = ancestor as FrameworkContentElement;
logicalParent = (ancestorFCE != null) ? ancestorFCE.Parent : null;
}
ancestor = logicalParent;
}
return (ancestor != null);
}
internal DependencyObject _startNode;
internal TreeWalkPriority _priority;
internal FrugalStructList _nodes;
internal int _recursionDepth;
}
///
/// Enum specifying whether visual tree needs
/// to be travesed first or the logical tree
///
internal enum TreeWalkPriority
{
///
/// Traverse Logical Tree first
///
LogicalTree,
///
/// Traverse Visual Tree first
///
VisualTree
}
}
// 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
- AttachedPropertyBrowsableAttribute.cs
- DetailsViewDesigner.cs
- WindowManager.cs
- RayHitTestParameters.cs
- MarshalByValueComponent.cs
- EntityStoreSchemaFilterEntry.cs
- UnconditionalPolicy.cs
- CompilationLock.cs
- ClassicBorderDecorator.cs
- Authorization.cs
- IBuiltInEvidence.cs
- PolicyValidationException.cs
- ManifestBasedResourceGroveler.cs
- RotateTransform.cs
- SettingsSavedEventArgs.cs
- ElementMarkupObject.cs
- BlockUIContainer.cs
- SystemFonts.cs
- AlternateView.cs
- _WinHttpWebProxyDataBuilder.cs
- InvokeAction.cs
- DesignerSerializerAttribute.cs
- IdnElement.cs
- BlurBitmapEffect.cs
- DataGridState.cs
- EntityDataSourceSelectingEventArgs.cs
- FontEditor.cs
- Debug.cs
- XmlSchemaNotation.cs
- ResourceDictionaryCollection.cs
- LicenseContext.cs
- HttpModulesInstallComponent.cs
- MexTcpBindingCollectionElement.cs
- FileReservationCollection.cs
- TextServicesDisplayAttribute.cs
- AutomationAttributeInfo.cs
- AnnotationMap.cs
- StringAttributeCollection.cs
- Html32TextWriter.cs
- HttpPostLocalhostServerProtocol.cs
- FieldNameLookup.cs
- Application.cs
- StylusCollection.cs
- EnumerableRowCollectionExtensions.cs
- ListItem.cs
- CompoundFileIOPermission.cs
- ExpressionConverter.cs
- XmlUrlResolver.cs
- BinaryCommonClasses.cs
- FormatException.cs
- XmlILIndex.cs
- DataGridViewBand.cs
- BitmapEffectInputConnector.cs
- CachingHintValidation.cs
- Point4DConverter.cs
- CollaborationHelperFunctions.cs
- StringArrayConverter.cs
- Visitor.cs
- WeakReference.cs
- ToolStripRenderEventArgs.cs
- SpeechEvent.cs
- TemplatePropertyEntry.cs
- localization.cs
- X509CertificateClaimSet.cs
- WebPart.cs
- PathFigureCollection.cs
- EndpointDispatcher.cs
- ButtonColumn.cs
- BuildManagerHost.cs
- XPathSingletonIterator.cs
- RedistVersionInfo.cs
- DesignerActionItemCollection.cs
- DateTimeFormatInfoScanner.cs
- DataGridViewComboBoxColumn.cs
- ContainerVisual.cs
- EndpointDispatcher.cs
- MatrixAnimationUsingPath.cs
- PropertyExpression.cs
- StreamInfo.cs
- UInt64Converter.cs
- CloseCryptoHandleRequest.cs
- Matrix.cs
- DataProtection.cs
- GeometryCombineModeValidation.cs
- Gdiplus.cs
- WorkflowWebService.cs
- FixedSOMGroup.cs
- PropertyEmitter.cs
- WindowsMenu.cs
- WebUtil.cs
- NullableBoolConverter.cs
- SoapElementAttribute.cs
- Base64Encoding.cs
- QueueProcessor.cs
- DataGridViewRowsRemovedEventArgs.cs
- HttpChannelHelper.cs
- AssociationSetEnd.cs
- ClassHandlersStore.cs
- ComboBox.cs
- DecimalKeyFrameCollection.cs