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
- MailWebEventProvider.cs
- UniqueID.cs
- HtmlAnchor.cs
- Directory.cs
- Mouse.cs
- IItemContainerGenerator.cs
- StringConcat.cs
- LicenseException.cs
- TagPrefixCollection.cs
- SystemIcons.cs
- SEHException.cs
- Point3DAnimationUsingKeyFrames.cs
- IIS7UserPrincipal.cs
- SessionEndingEventArgs.cs
- BaseComponentEditor.cs
- Graph.cs
- DataObject.cs
- ToolboxComponentsCreatingEventArgs.cs
- AmbientProperties.cs
- PostBackTrigger.cs
- StateFinalizationDesigner.cs
- XmlSchemaSimpleContent.cs
- SqlDataSourceEnumerator.cs
- EventDescriptor.cs
- LinkTarget.cs
- KeyToListMap.cs
- RootProfilePropertySettingsCollection.cs
- ValueTable.cs
- HtmlTableRowCollection.cs
- ConfigurationManagerHelperFactory.cs
- FontStyles.cs
- AvtEvent.cs
- AssemblyGen.cs
- CheckBox.cs
- DataControlField.cs
- SeparatorAutomationPeer.cs
- _TimerThread.cs
- ComNativeDescriptor.cs
- WebPartRestoreVerb.cs
- Models.cs
- Hex.cs
- HScrollBar.cs
- EntityDesignerDataSourceView.cs
- SwitchElementsCollection.cs
- LayoutEditorPart.cs
- DataMemberAttribute.cs
- VariableExpressionConverter.cs
- DefinitionBase.cs
- FormsAuthenticationCredentials.cs
- LocalizeDesigner.cs
- ValidationEventArgs.cs
- EntityDataSourceView.cs
- CalendarDay.cs
- QueryContinueDragEventArgs.cs
- StructuredCompositeActivityDesigner.cs
- SettingsPropertyWrongTypeException.cs
- HtmlInputSubmit.cs
- TitleStyle.cs
- SchemaImporterExtensionElement.cs
- Style.cs
- ExpandedWrapper.cs
- ResourceLoader.cs
- DataGridCaption.cs
- OrderedDictionary.cs
- TickBar.cs
- templategroup.cs
- GridViewCommandEventArgs.cs
- StateFinalizationActivity.cs
- FontStretches.cs
- ConsoleTraceListener.cs
- DataBindEngine.cs
- PenContext.cs
- BitmapSource.cs
- Pair.cs
- ConstantExpression.cs
- ClientUrlResolverWrapper.cs
- StoreUtilities.cs
- ResourceSet.cs
- ConfigurationLockCollection.cs
- MetadataItem.cs
- SortedList.cs
- ResourcePermissionBaseEntry.cs
- PlaceHolder.cs
- DatePickerAutomationPeer.cs
- SoapIncludeAttribute.cs
- MsmqInputChannelListener.cs
- PersonalizationAdministration.cs
- Size3DConverter.cs
- FormatException.cs
- Rfc2898DeriveBytes.cs
- DialogWindow.cs
- Process.cs
- ZipIOLocalFileHeader.cs
- ListViewCommandEventArgs.cs
- RoleGroupCollection.cs
- VerificationAttribute.cs
- StaticExtensionConverter.cs
- ClusterRegistryConfigurationProvider.cs
- LazyLoadBehavior.cs
- EnumerableValidator.cs