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
- XamlSerializationHelper.cs
- XmlCharacterData.cs
- QuaternionRotation3D.cs
- TextBox.cs
- SymbolEqualComparer.cs
- DataServices.cs
- Int32CollectionValueSerializer.cs
- XsdDuration.cs
- ApplicationInterop.cs
- IgnoreSectionHandler.cs
- WebPartConnectionsEventArgs.cs
- SessionIDManager.cs
- HttpStreams.cs
- FixedPageAutomationPeer.cs
- SendParametersContent.cs
- EventListener.cs
- CapiNative.cs
- EmptyImpersonationContext.cs
- HttpResponse.cs
- CompilerTypeWithParams.cs
- DrawingServices.cs
- DateTimeValueSerializerContext.cs
- ObjectSelectorEditor.cs
- DataGridViewTopLeftHeaderCell.cs
- DataServiceRequest.cs
- AgileSafeNativeMemoryHandle.cs
- XPathDocumentNavigator.cs
- InkCanvasSelection.cs
- FormView.cs
- BindingBase.cs
- CacheForPrimitiveTypes.cs
- FixedPageStructure.cs
- CornerRadiusConverter.cs
- RightsManagementPermission.cs
- ProxyAttribute.cs
- FragmentNavigationEventArgs.cs
- NumberFormatInfo.cs
- XmlWellformedWriterHelpers.cs
- ImportContext.cs
- MsdtcClusterUtils.cs
- WrappedOptions.cs
- BooleanStorage.cs
- ObjectItemCollection.cs
- CodeGenerator.cs
- CaseCqlBlock.cs
- CmsInterop.cs
- Grid.cs
- HandlerFactoryCache.cs
- MulticastOption.cs
- WindowPatternIdentifiers.cs
- MaskedTextBoxTextEditorDropDown.cs
- DbDataSourceEnumerator.cs
- StrokeSerializer.cs
- ProviderBase.cs
- WorkerRequest.cs
- QilUnary.cs
- IgnoreFileBuildProvider.cs
- DesignTimeHTMLTextWriter.cs
- Typeface.cs
- Listbox.cs
- SpecularMaterial.cs
- EmptyElement.cs
- cookie.cs
- ProfileBuildProvider.cs
- TrackingProfileManager.cs
- RectangleConverter.cs
- TextUtf8RawTextWriter.cs
- OdbcErrorCollection.cs
- BuildDependencySet.cs
- EntityDataSourceStatementEditorForm.cs
- ResourcesGenerator.cs
- XmlSchemaAnyAttribute.cs
- Context.cs
- SecurityDescriptor.cs
- TextBoxAutoCompleteSourceConverter.cs
- TraceUtils.cs
- GPRECT.cs
- XmlDictionaryWriter.cs
- IsolatedStorageFilePermission.cs
- SByteConverter.cs
- InputLanguageEventArgs.cs
- CookieProtection.cs
- COM2IDispatchConverter.cs
- MethodBuilder.cs
- PropertyValueUIItem.cs
- MimeTypeAttribute.cs
- DataGridViewCellValidatingEventArgs.cs
- DoubleAnimationUsingKeyFrames.cs
- UpWmlMobileTextWriter.cs
- ExpressionBuilder.cs
- BindStream.cs
- TrustLevelCollection.cs
- AutomationProperties.cs
- PocoPropertyAccessorStrategy.cs
- SchemaImporterExtensionsSection.cs
- ClientEventManager.cs
- DataGridViewRowHeaderCell.cs
- TextRunCacheImp.cs
- ButtonBase.cs
- ExceptionHandler.cs