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
- BaseTemplateParser.cs
- AuthenticatedStream.cs
- HorizontalAlignConverter.cs
- SelectionPatternIdentifiers.cs
- PrintingPermission.cs
- SamlEvidence.cs
- ValidationResult.cs
- InheritanceContextChangedEventManager.cs
- GridViewUpdateEventArgs.cs
- XmlDictionary.cs
- ServiceContractGenerationContext.cs
- SignedInfo.cs
- OdbcConnection.cs
- InkCanvas.cs
- AnnotationHelper.cs
- DrawTreeNodeEventArgs.cs
- DesignerDataView.cs
- ListViewItem.cs
- BitmapFrameDecode.cs
- AttachedPropertyBrowsableAttribute.cs
- ButtonColumn.cs
- HelpPage.cs
- AttributedMetaModel.cs
- AutomationTextAttribute.cs
- WebException.cs
- SmtpReplyReader.cs
- BuildResultCache.cs
- RecommendedAsConfigurableAttribute.cs
- RealizedColumnsBlock.cs
- FormClosingEvent.cs
- ACE.cs
- FlowDocumentPage.cs
- TextReader.cs
- PeerResolver.cs
- CreateUserWizardStep.cs
- SmtpSection.cs
- CompoundFileReference.cs
- WmpBitmapEncoder.cs
- SqlCommandBuilder.cs
- SByte.cs
- SystemNetworkInterface.cs
- DynamicObject.cs
- PropertyEmitterBase.cs
- ListViewItem.cs
- TagPrefixCollection.cs
- ProcessModuleCollection.cs
- BindableTemplateBuilder.cs
- RolePrincipal.cs
- ClientSideQueueItem.cs
- LazyInitializer.cs
- InputLanguageSource.cs
- SRGSCompiler.cs
- TlsnegoTokenAuthenticator.cs
- WebServicesSection.cs
- TextServicesLoader.cs
- CodeCompiler.cs
- SequenceFullException.cs
- DragCompletedEventArgs.cs
- IOException.cs
- WithParamAction.cs
- CommonDialog.cs
- RequiredAttributeAttribute.cs
- ToolStripDropDownItemDesigner.cs
- EventWaitHandleSecurity.cs
- ModifierKeysValueSerializer.cs
- WindowsFont.cs
- SessionEndingCancelEventArgs.cs
- AutomationProperty.cs
- SqlBulkCopyColumnMappingCollection.cs
- CompositeDispatchFormatter.cs
- Transform3DGroup.cs
- RC2CryptoServiceProvider.cs
- WizardStepBase.cs
- SHA256Cng.cs
- ParameterBinding.cs
- BindStream.cs
- CommentAction.cs
- SortedList.cs
- SignedInfo.cs
- TreeSet.cs
- EntityDataSourceColumn.cs
- FormViewDeletedEventArgs.cs
- SecurityElement.cs
- HtmlElementCollection.cs
- SqlCachedBuffer.cs
- Function.cs
- SqlDuplicator.cs
- FrameDimension.cs
- BuildResult.cs
- LongTypeConverter.cs
- NameValueConfigurationElement.cs
- MimeMapping.cs
- OutputCacheProfileCollection.cs
- DrawingImage.cs
- shaperfactory.cs
- Boolean.cs
- XhtmlBasicValidatorAdapter.cs
- PropertyFilter.cs
- BufferedStream2.cs
- Facet.cs