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
- HMACRIPEMD160.cs
- GPStream.cs
- MemoryRecordBuffer.cs
- ToolBarButton.cs
- WebCategoryAttribute.cs
- ProcessThread.cs
- HttpFileCollection.cs
- HtmlTableCellCollection.cs
- Polyline.cs
- OletxTransactionManager.cs
- CryptoStream.cs
- XmlChoiceIdentifierAttribute.cs
- FormattedText.cs
- RepeaterCommandEventArgs.cs
- StreamGeometryContext.cs
- PathFigureCollection.cs
- CodeTypeParameter.cs
- RightsManagementManager.cs
- WebControlParameterProxy.cs
- ImageCodecInfoPrivate.cs
- SmtpException.cs
- OpacityConverter.cs
- AllowedAudienceUriElement.cs
- ResourceExpression.cs
- QuerySettings.cs
- DoubleAnimationUsingPath.cs
- SqlProvider.cs
- SymbolType.cs
- PtsPage.cs
- DriveNotFoundException.cs
- InProcStateClientManager.cs
- MediaElement.cs
- CustomAttributeSerializer.cs
- XmlUtil.cs
- ByteStreamMessageEncodingElement.cs
- _ConnectionGroup.cs
- QilXmlReader.cs
- DictionaryEntry.cs
- PreDigestedSignedInfo.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- HttpClientCertificate.cs
- SoapRpcMethodAttribute.cs
- MergePropertyDescriptor.cs
- SinglePageViewer.cs
- SqlMetaData.cs
- ChtmlTextWriter.cs
- SoapIncludeAttribute.cs
- TypefaceCollection.cs
- GridSplitterAutomationPeer.cs
- ToolStripDropDownButton.cs
- BinaryExpressionHelper.cs
- ReaderContextStackData.cs
- EpmContentSerializerBase.cs
- ExternalCalls.cs
- XmlElementAttributes.cs
- SerializationObjectManager.cs
- TemplateBindingExpression.cs
- XmlDigitalSignatureProcessor.cs
- AttachInfo.cs
- IntegerValidator.cs
- Helpers.cs
- CompositeActivityTypeDescriptorProvider.cs
- RoleGroupCollectionEditor.cs
- DiscoveryServerProtocol.cs
- RawStylusActions.cs
- PointCollectionConverter.cs
- RoleManagerEventArgs.cs
- ExecutionContext.cs
- MatrixTransform.cs
- DocumentViewerConstants.cs
- ThemeDirectoryCompiler.cs
- ReadOnlyCollectionBase.cs
- DataServiceRequest.cs
- MediaElementAutomationPeer.cs
- StringInfo.cs
- TextRangeSerialization.cs
- OutputCacheSettings.cs
- WeakEventTable.cs
- XhtmlBasicTextBoxAdapter.cs
- ColumnTypeConverter.cs
- PerformanceCounterManager.cs
- DataGridViewRowPostPaintEventArgs.cs
- TemplateXamlParser.cs
- AnnotationObservableCollection.cs
- ImplicitInputBrush.cs
- TemplateField.cs
- FontFamilyValueSerializer.cs
- VersionedStream.cs
- DispatcherFrame.cs
- CompoundFileStorageReference.cs
- TransformerInfoCollection.cs
- ButtonStandardAdapter.cs
- ParentUndoUnit.cs
- SystemIPInterfaceStatistics.cs
- ThreadStartException.cs
- PolicyException.cs
- MappingModelBuildProvider.cs
- SpellCheck.cs
- WebScriptServiceHost.cs
- MimeXmlImporter.cs