Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / DescendentsWalkerBase.cs / 1 / 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;
internal const int MAX_TREE_DEPTH = 250;
}
///
/// 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;
internal const int MAX_TREE_DEPTH = 250;
}
///
/// 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
- DecoderNLS.cs
- RbTree.cs
- IntranetCredentialPolicy.cs
- querybuilder.cs
- InstanceLockedException.cs
- BoundField.cs
- WebPartDescriptionCollection.cs
- XamlHostingSectionGroup.cs
- CustomErrorCollection.cs
- SequenceDesignerAccessibleObject.cs
- DynamicDataResources.Designer.cs
- sqlcontext.cs
- PropertyGridCommands.cs
- VersionedStream.cs
- SourceFileInfo.cs
- FrameworkContentElementAutomationPeer.cs
- ContentTextAutomationPeer.cs
- RadioButtonRenderer.cs
- HandleTable.cs
- ProxyManager.cs
- ClrProviderManifest.cs
- RelationshipEnd.cs
- NullableFloatMinMaxAggregationOperator.cs
- WebConfigurationHostFileChange.cs
- Dictionary.cs
- DragStartedEventArgs.cs
- IEnumerable.cs
- InputLanguage.cs
- HttpCapabilitiesSectionHandler.cs
- AuthStoreRoleProvider.cs
- MembershipValidatePasswordEventArgs.cs
- ListDictionaryInternal.cs
- HScrollProperties.cs
- CssClassPropertyAttribute.cs
- SemaphoreSecurity.cs
- InitiatorServiceModelSecurityTokenRequirement.cs
- ControlPropertyNameConverter.cs
- BulletChrome.cs
- AxHost.cs
- WsdlBuildProvider.cs
- SyndicationDeserializer.cs
- DataProviderNameConverter.cs
- FormsAuthenticationCredentials.cs
- Properties.cs
- ButtonFlatAdapter.cs
- TemplatedMailWebEventProvider.cs
- InputProcessorProfiles.cs
- EntitySetDataBindingList.cs
- TdsValueSetter.cs
- _ProxyRegBlob.cs
- SelectionPatternIdentifiers.cs
- EmptyStringExpandableObjectConverter.cs
- PermissionListSet.cs
- ToggleButtonAutomationPeer.cs
- _ShellExpression.cs
- CharEntityEncoderFallback.cs
- MembershipSection.cs
- SystemIPv4InterfaceProperties.cs
- DotAtomReader.cs
- RtfControlWordInfo.cs
- AutoResetEvent.cs
- BackgroundWorker.cs
- CorrelationTokenInvalidatedHandler.cs
- Int32Collection.cs
- LocatorPartList.cs
- OdbcConnectionStringbuilder.cs
- ObjectSet.cs
- CurrencyWrapper.cs
- Soap12ProtocolImporter.cs
- TemplateBindingExtension.cs
- ProjectionPlan.cs
- NamespaceExpr.cs
- regiisutil.cs
- RegexMatchCollection.cs
- DependencyPropertyAttribute.cs
- WindowsFormsSectionHandler.cs
- ItemAutomationPeer.cs
- BackgroundWorker.cs
- XamlGridLengthSerializer.cs
- SecureConversationServiceCredential.cs
- CompressEmulationStream.cs
- TypedDataSourceCodeGenerator.cs
- DbExpressionVisitor_TResultType.cs
- InputScopeAttribute.cs
- CollectionViewSource.cs
- XmlSerializableWriter.cs
- WebPartManager.cs
- BaseServiceProvider.cs
- DesignerVerb.cs
- StringUtil.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- XmlCharCheckingWriter.cs
- MulticastNotSupportedException.cs
- ToolStripDesignerAvailabilityAttribute.cs
- BulletChrome.cs
- CorrelationQuery.cs
- InternalPermissions.cs
- TextLine.cs
- TreeNodeBinding.cs
- TypeSemantics.cs