Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ManifestBasedResourceGroveler.cs
- DefaultValueAttribute.cs
- MetadataStore.cs
- NativeActivity.cs
- ListBase.cs
- RepeatInfo.cs
- HttpUnhandledOperationInvoker.cs
- IsolatedStorageException.cs
- SafeNativeMethodsMilCoreApi.cs
- TransportManager.cs
- SmiTypedGetterSetter.cs
- Signature.cs
- SqlFactory.cs
- ApplyHostConfigurationBehavior.cs
- DataControlButton.cs
- ParagraphResult.cs
- DialogResultConverter.cs
- ConfigsHelper.cs
- StyleXamlTreeBuilder.cs
- ServiceBehaviorElementCollection.cs
- ReferencedType.cs
- UniformGrid.cs
- DescendantQuery.cs
- ImageButton.cs
- EntityProviderServices.cs
- CodeDomComponentSerializationService.cs
- ArgumentValidation.cs
- KeyInstance.cs
- DebugInfo.cs
- HtmlInputReset.cs
- NullNotAllowedCollection.cs
- Trigger.cs
- SqlEnums.cs
- DataGridViewRowConverter.cs
- LayoutSettings.cs
- SelectionProcessor.cs
- XmlEncoding.cs
- EntityConnectionStringBuilder.cs
- ConnectivityStatus.cs
- InputLanguageEventArgs.cs
- SingleAnimation.cs
- RuleInfoComparer.cs
- UndoEngine.cs
- Baml2006KnownTypes.cs
- RewritingSimplifier.cs
- DesignTimeVisibleAttribute.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- InputReport.cs
- EventData.cs
- TdsRecordBufferSetter.cs
- SerialPinChanges.cs
- QueryException.cs
- ipaddressinformationcollection.cs
- DynamicDataResources.Designer.cs
- CompilerInfo.cs
- ISO2022Encoding.cs
- CompoundFileStorageReference.cs
- GPStream.cs
- LocalizableAttribute.cs
- DesigntimeLicenseContext.cs
- TextModifierScope.cs
- GridView.cs
- RegistryPermission.cs
- IsolatedStorageFileStream.cs
- ReliableMessagingHelpers.cs
- DateTime.cs
- KnownBoxes.cs
- ListViewAutomationPeer.cs
- DecimalConverter.cs
- HtmlEmptyTagControlBuilder.cs
- RelationshipEnd.cs
- ColumnBinding.cs
- Attributes.cs
- TrackingRecord.cs
- PasswordBox.cs
- EncoderFallback.cs
- Command.cs
- ListViewGroupConverter.cs
- ConfigurationSchemaErrors.cs
- ValidationHelper.cs
- TriggerCollection.cs
- ItemCheckEvent.cs
- DbConnectionPoolOptions.cs
- TimeZoneInfo.cs
- SafeLocalAllocation.cs
- SchemaDeclBase.cs
- DbTransaction.cs
- WebPartVerbsEventArgs.cs
- CustomLineCap.cs
- CollectionConverter.cs
- X509CertificateTrustedIssuerElement.cs
- BmpBitmapDecoder.cs
- ObjectContextServiceProvider.cs
- CodeAccessPermission.cs
- FileLevelControlBuilderAttribute.cs
- XmlConverter.cs
- SiblingIterators.cs
- WindowsListViewGroupSubsetLink.cs
- RayMeshGeometry3DHitTestResult.cs
- IdentifierService.cs