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
- LicenseProviderAttribute.cs
- HostExecutionContextManager.cs
- BufferedWebEventProvider.cs
- ClearTypeHintValidation.cs
- UnmanagedMemoryStreamWrapper.cs
- ApplicationCommands.cs
- ConditionCollection.cs
- ChannelBuilder.cs
- StateBag.cs
- Brushes.cs
- FamilyMap.cs
- AssertSection.cs
- Operand.cs
- Publisher.cs
- OleDbCommandBuilder.cs
- XhtmlBasicPageAdapter.cs
- BinaryParser.cs
- GACMembershipCondition.cs
- TypedElement.cs
- DataTemplateKey.cs
- FrameworkTextComposition.cs
- WindowPattern.cs
- EventLogPermissionEntryCollection.cs
- Span.cs
- GridViewPageEventArgs.cs
- SortAction.cs
- DefaultBindingPropertyAttribute.cs
- ServiceDescriptionData.cs
- GeneratedContractType.cs
- NativeMethods.cs
- SmiMetaDataProperty.cs
- ObjectToIdCache.cs
- SRGSCompiler.cs
- DbDataReader.cs
- DecimalConverter.cs
- MenuAutomationPeer.cs
- CapabilitiesUse.cs
- OdbcConnectionPoolProviderInfo.cs
- XamlPointCollectionSerializer.cs
- PrinterUnitConvert.cs
- TokenBasedSetEnumerator.cs
- SecurityKeyIdentifier.cs
- UnsettableComboBox.cs
- MobileControlDesigner.cs
- ProcessModelInfo.cs
- Column.cs
- SignatureToken.cs
- Color.cs
- SignatureDescription.cs
- WebUtil.cs
- VectorAnimation.cs
- AliasedSlot.cs
- DragCompletedEventArgs.cs
- SettingsAttributeDictionary.cs
- ObjectDataSourceFilteringEventArgs.cs
- ColorTranslator.cs
- Point.cs
- DataGridViewIntLinkedList.cs
- TypeConverterAttribute.cs
- TabControlAutomationPeer.cs
- WmfPlaceableFileHeader.cs
- DependencyObjectProvider.cs
- ValidationSummary.cs
- NameValuePermission.cs
- CryptoApi.cs
- Screen.cs
- RightsManagementUser.cs
- ConfigurationManagerHelper.cs
- EncryptedPackageFilter.cs
- FontStretches.cs
- ConnectionManagementSection.cs
- BitmapEffect.cs
- ObjectContext.cs
- ListViewItemSelectionChangedEvent.cs
- objectresult_tresulttype.cs
- ContextMenuService.cs
- GlobalEventManager.cs
- FileRecordSequenceHelper.cs
- StyleXamlTreeBuilder.cs
- OpenTypeLayoutCache.cs
- StringUtil.cs
- DeclarativeExpressionConditionDeclaration.cs
- Point3D.cs
- Tag.cs
- XmlILConstructAnalyzer.cs
- StreamResourceInfo.cs
- WebAdminConfigurationHelper.cs
- XmlStrings.cs
- SQLSingle.cs
- InfoCardSymmetricAlgorithm.cs
- StateRuntime.cs
- ServiceDebugBehavior.cs
- GetKeyedHashRequest.cs
- ClosureBinding.cs
- WebHttpBindingCollectionElement.cs
- TextWriter.cs
- SchemaNames.cs
- HealthMonitoringSection.cs
- OuterGlowBitmapEffect.cs
- EntryIndex.cs