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
- ProgressBarAutomationPeer.cs
- StickyNoteContentControl.cs
- CodeNamespaceImportCollection.cs
- ProcessHostMapPath.cs
- WebDescriptionAttribute.cs
- EntityAdapter.cs
- SocketAddress.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- LinearQuaternionKeyFrame.cs
- GestureRecognizer.cs
- EpmHelper.cs
- EventLogPermissionAttribute.cs
- HtmlInputFile.cs
- coordinatorscratchpad.cs
- IChannel.cs
- ScrollItemProviderWrapper.cs
- ProxyWebPartManager.cs
- VerbConverter.cs
- XmlUtil.cs
- MouseWheelEventArgs.cs
- XmlText.cs
- TableRowGroupCollection.cs
- ParallelTimeline.cs
- Binding.cs
- UserPreferenceChangedEventArgs.cs
- WmpBitmapDecoder.cs
- DrawingCollection.cs
- TypeExtension.cs
- PageContentAsyncResult.cs
- MethodBuilder.cs
- GridView.cs
- PartitionerStatic.cs
- ErrorProvider.cs
- ArrayTypeMismatchException.cs
- RuntimeEnvironment.cs
- TagPrefixAttribute.cs
- CornerRadiusConverter.cs
- SQLChars.cs
- SerializationSectionGroup.cs
- CleanUpVirtualizedItemEventArgs.cs
- EditingCommands.cs
- RepeatBehaviorConverter.cs
- LinearKeyFrames.cs
- DataTableReader.cs
- UriWriter.cs
- Activity.cs
- RepeatBehavior.cs
- ObjectItemConventionAssemblyLoader.cs
- CodeTypeMember.cs
- HtmlTernaryTree.cs
- UnknownWrapper.cs
- Graphics.cs
- PackUriHelper.cs
- EntityDataSourceView.cs
- OdbcConnection.cs
- FontFamilyValueSerializer.cs
- EnumerableRowCollectionExtensions.cs
- SiteMapNodeCollection.cs
- SecurityTokenAuthenticator.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- CompoundFileIOPermission.cs
- Keyboard.cs
- RedistVersionInfo.cs
- DesignerAutoFormatStyle.cs
- brushes.cs
- Symbol.cs
- DynamicQueryableWrapper.cs
- ProxySimple.cs
- HttpHandlerActionCollection.cs
- LogicalExpr.cs
- InputScopeAttribute.cs
- DllNotFoundException.cs
- DropShadowBitmapEffect.cs
- ELinqQueryState.cs
- XmlSerializationReader.cs
- SqlMetaData.cs
- DeviceSpecificChoiceCollection.cs
- XpsPartBase.cs
- WebPartEditorOkVerb.cs
- Configuration.cs
- IdentityValidationException.cs
- ListInitExpression.cs
- _ChunkParse.cs
- SiteMapDataSourceView.cs
- RequestTimeoutManager.cs
- storepermission.cs
- AspCompat.cs
- DbParameterCollectionHelper.cs
- CacheVirtualItemsEvent.cs
- QueryOperationResponseOfT.cs
- Variable.cs
- WebControl.cs
- HealthMonitoringSection.cs
- UnsafeNativeMethods.cs
- DispatchChannelSink.cs
- EventLogWatcher.cs
- FontStyles.cs
- TraceRecord.cs
- ServicesExceptionNotHandledEventArgs.cs
- RecordManager.cs