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
- Queue.cs
- CheckBox.cs
- WindowsFormsSectionHandler.cs
- TransformPatternIdentifiers.cs
- OleDbWrapper.cs
- OpenFileDialog.cs
- StoragePropertyMapping.cs
- ClrProviderManifest.cs
- DataGridCaption.cs
- WebUtil.cs
- OneOfScalarConst.cs
- QilLoop.cs
- OleDbErrorCollection.cs
- Byte.cs
- Border.cs
- Help.cs
- SQLSingleStorage.cs
- CodeAttributeDeclarationCollection.cs
- AssociationSetEnd.cs
- Guid.cs
- RuntimeHelpers.cs
- ProtocolException.cs
- TextCollapsingProperties.cs
- CompilerHelpers.cs
- SelectionItemProviderWrapper.cs
- ScrollContentPresenter.cs
- ExpressionDumper.cs
- TreeNode.cs
- x509utils.cs
- WebHeaderCollection.cs
- HttpModulesSection.cs
- Operator.cs
- DataServiceHost.cs
- MachineKeyConverter.cs
- ConfigurationErrorsException.cs
- TraceListeners.cs
- HandledMouseEvent.cs
- ProcessThreadCollection.cs
- FontEmbeddingManager.cs
- ListViewSortEventArgs.cs
- Canvas.cs
- DataService.cs
- MethodBuilder.cs
- DynamicPropertyHolder.cs
- IntSecurity.cs
- SafeUserTokenHandle.cs
- TripleDES.cs
- AnimationStorage.cs
- ManipulationPivot.cs
- PageCache.cs
- StringBuilder.cs
- TreeViewEvent.cs
- BindingFormattingDialog.cs
- AccessViolationException.cs
- EmptyQuery.cs
- MaterialGroup.cs
- DataErrorValidationRule.cs
- ComboBox.cs
- _ConnectOverlappedAsyncResult.cs
- MatrixCamera.cs
- DesignerAttributeInfo.cs
- CqlParserHelpers.cs
- CodeTypeReferenceExpression.cs
- WrapPanel.cs
- OdbcError.cs
- NameScopePropertyAttribute.cs
- SchemaConstraints.cs
- HandleValueEditor.cs
- AmbientProperties.cs
- DefaultParameterValueAttribute.cs
- HashAlgorithm.cs
- PenThread.cs
- ServicePointManager.cs
- TraceInternal.cs
- AssemblyHash.cs
- ToolStrip.cs
- ObjectStateEntryDbDataRecord.cs
- HttpRawResponse.cs
- Span.cs
- _SecureChannel.cs
- PageTheme.cs
- RadioButton.cs
- SingleAnimationBase.cs
- UpdateInfo.cs
- EventLogRecord.cs
- GroupBoxAutomationPeer.cs
- XmlSchemaSubstitutionGroup.cs
- DeferredElementTreeState.cs
- KerberosTokenFactoryCredential.cs
- ContentWrapperAttribute.cs
- TypeInfo.cs
- GAC.cs
- RecognitionEventArgs.cs
- FileStream.cs
- UrlPath.cs
- SchemaConstraints.cs
- ping.cs
- WinInet.cs
- Dynamic.cs
- ExtentCqlBlock.cs