Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- HierarchicalDataSourceConverter.cs
- SiteMapNodeItemEventArgs.cs
- HtmlButton.cs
- XamlSerializationHelper.cs
- ILGenerator.cs
- DataGridViewCellStyle.cs
- CannotUnloadAppDomainException.cs
- SslStreamSecurityBindingElement.cs
- FileUtil.cs
- GetReadStreamResult.cs
- LineGeometry.cs
- FacetDescriptionElement.cs
- Ray3DHitTestResult.cs
- XmlHierarchicalEnumerable.cs
- BindingEntityInfo.cs
- ScriptReference.cs
- WsatServiceAddress.cs
- BaseCAMarshaler.cs
- ElementNotEnabledException.cs
- XamlPathDataSerializer.cs
- GlyphRunDrawing.cs
- ListChangedEventArgs.cs
- CFGGrammar.cs
- TdsRecordBufferSetter.cs
- BasicExpandProvider.cs
- StateMachineWorkflowInstance.cs
- MappingMetadataHelper.cs
- Root.cs
- HwndSubclass.cs
- ServiceNameCollection.cs
- HtmlUtf8RawTextWriter.cs
- TableRowGroup.cs
- PaginationProgressEventArgs.cs
- ProtocolsInstallComponent.cs
- StylusPointDescription.cs
- basenumberconverter.cs
- TransactionInterop.cs
- RemotingService.cs
- SingleObjectCollection.cs
- VectorValueSerializer.cs
- AlphaSortedEnumConverter.cs
- LambdaCompiler.Address.cs
- XmlSchemaImport.cs
- Native.cs
- TableRowCollection.cs
- GridViewUpdateEventArgs.cs
- MessageLogTraceRecord.cs
- WebBrowserUriTypeConverter.cs
- ListViewPagedDataSource.cs
- TypeHelpers.cs
- X509Certificate2.cs
- SnapshotChangeTrackingStrategy.cs
- ReferenceEqualityComparer.cs
- AddingNewEventArgs.cs
- TcpConnectionPoolSettingsElement.cs
- ClientRoleProvider.cs
- DatePickerDateValidationErrorEventArgs.cs
- WasHttpHandlersInstallComponent.cs
- TypedReference.cs
- DbParameterHelper.cs
- SystemIcmpV6Statistics.cs
- UserControlBuildProvider.cs
- OleDbPermission.cs
- SqlConnectionHelper.cs
- StopStoryboard.cs
- MappedMetaModel.cs
- BehaviorEditorPart.cs
- IIS7UserPrincipal.cs
- AttributeCollection.cs
- SizeF.cs
- HybridDictionary.cs
- XmlSiteMapProvider.cs
- ColorInterpolationModeValidation.cs
- TableLayoutPanelCodeDomSerializer.cs
- FocusWithinProperty.cs
- CodeObjectCreateExpression.cs
- _HeaderInfoTable.cs
- HandlerBase.cs
- QilFunction.cs
- XmlSchemaAppInfo.cs
- PoisonMessageException.cs
- Brush.cs
- SqlClientPermission.cs
- _TransmitFileOverlappedAsyncResult.cs
- RecognizedAudio.cs
- LinqDataSourceValidationException.cs
- _UriSyntax.cs
- XamlBuildProvider.cs
- DetectEofStream.cs
- FocusWithinProperty.cs
- SiteMapNode.cs
- BasicExpressionVisitor.cs
- CopyEncoder.cs
- Rect.cs
- TextServicesCompartment.cs
- DbConnectionPoolIdentity.cs
- PointCollectionValueSerializer.cs
- TextRunTypographyProperties.cs
- LinqDataSourceUpdateEventArgs.cs
- Transform.cs