Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DescendentsWalkerBase.cs / 1305600 / 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; } /// /// 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; } /// /// 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
- UpDownEvent.cs
- PersonalizableAttribute.cs
- StateMachineWorkflow.cs
- WebRequest.cs
- BoundsDrawingContextWalker.cs
- HandlerMappingMemo.cs
- WebBrowsableAttribute.cs
- ModifierKeysValueSerializer.cs
- TraceUtils.cs
- GroupBoxDesigner.cs
- Source.cs
- RelatedCurrencyManager.cs
- DataControlLinkButton.cs
- PasswordTextContainer.cs
- DBCSCodePageEncoding.cs
- JapaneseCalendar.cs
- XmlElementAttribute.cs
- ContentFileHelper.cs
- SplitterEvent.cs
- DataService.cs
- ErrorItem.cs
- OracleCommandSet.cs
- Brush.cs
- SqlInfoMessageEvent.cs
- IdnElement.cs
- ContainerParagraph.cs
- Matrix3D.cs
- DrawingContextDrawingContextWalker.cs
- GuidConverter.cs
- RegexMatch.cs
- ProjectedSlot.cs
- LookupNode.cs
- SimpleModelProvider.cs
- TreeView.cs
- TableDetailsCollection.cs
- GenericRootAutomationPeer.cs
- Module.cs
- xmlformatgeneratorstatics.cs
- OleDbTransaction.cs
- ProvideValueServiceProvider.cs
- FreezableCollection.cs
- RSAProtectedConfigurationProvider.cs
- SafeMILHandle.cs
- TextContainerChangedEventArgs.cs
- ManualWorkflowSchedulerService.cs
- ProxyWebPartConnectionCollection.cs
- DocumentXmlWriter.cs
- RepeatBehaviorConverter.cs
- TextParentUndoUnit.cs
- TextProperties.cs
- ImageButton.cs
- StylusLogic.cs
- XmlNodeReader.cs
- PhonemeEventArgs.cs
- GZipStream.cs
- InputLangChangeRequestEvent.cs
- XslVisitor.cs
- PageRequestManager.cs
- DataStreams.cs
- XmlSchemaSimpleContent.cs
- HttpProfileBase.cs
- SvcMapFileLoader.cs
- CommonObjectSecurity.cs
- XmlSchemaSimpleContentExtension.cs
- LayoutTableCell.cs
- DataServices.cs
- WebConfigurationHost.cs
- UnescapedXmlDiagnosticData.cs
- DispatchChannelSink.cs
- SequentialUshortCollection.cs
- PtsCache.cs
- TTSEngineTypes.cs
- PermissionSetTriple.cs
- Exceptions.cs
- RegexRunnerFactory.cs
- ApplicationServicesHostFactory.cs
- TabPage.cs
- SafeTimerHandle.cs
- AncestorChangedEventArgs.cs
- LinkLabelLinkClickedEvent.cs
- ActivationArguments.cs
- RpcCryptoContext.cs
- TrackingMemoryStream.cs
- RouteParameter.cs
- DbXmlEnabledProviderManifest.cs
- SingleResultAttribute.cs
- WindowsToolbar.cs
- HttpCachePolicyWrapper.cs
- TypedElement.cs
- BulletChrome.cs
- PtsContext.cs
- FormParameter.cs
- GridPattern.cs
- ParameterSubsegment.cs
- ShadowGlyph.cs
- PhysicalFontFamily.cs
- PropertyCondition.cs
- TogglePatternIdentifiers.cs
- UnsafeNativeMethods.cs
- AsnEncodedData.cs