Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DescendantBaseQuery.cs
- Internal.cs
- TypedElement.cs
- SmiSettersStream.cs
- SQLInt64.cs
- Debug.cs
- ISFTagAndGuidCache.cs
- IPipelineRuntime.cs
- WebBrowserUriTypeConverter.cs
- DataObject.cs
- XmlSchemaAnnotated.cs
- CacheVirtualItemsEvent.cs
- RawStylusInput.cs
- ServiceReference.cs
- StoragePropertyMapping.cs
- NestedContainer.cs
- ImpersonationContext.cs
- UserControlBuildProvider.cs
- ServiceContractGenerator.cs
- HttpCacheVaryByContentEncodings.cs
- WebRequestModuleElement.cs
- WindowsImpersonationContext.cs
- FormViewPageEventArgs.cs
- CodeDelegateCreateExpression.cs
- MetadataArtifactLoaderFile.cs
- LinqDataSource.cs
- SoapAttributeOverrides.cs
- ToolboxItemCollection.cs
- XmlQueryTypeFactory.cs
- AxisAngleRotation3D.cs
- SoundPlayerAction.cs
- XmlSignatureManifest.cs
- altserialization.cs
- UICuesEvent.cs
- EncodingNLS.cs
- EventLogWatcher.cs
- TypeElement.cs
- ShaperBuffers.cs
- ClearCollection.cs
- Type.cs
- Size3DConverter.cs
- BezierSegment.cs
- CompiledAction.cs
- SessionIDManager.cs
- TextPointerBase.cs
- CheckBoxPopupAdapter.cs
- ClientScriptManager.cs
- CustomErrorCollection.cs
- ConfigurationSectionHelper.cs
- _NtlmClient.cs
- ConnectionStringSettingsCollection.cs
- DependencyProperty.cs
- JournalEntryListConverter.cs
- ButtonFlatAdapter.cs
- ApplySecurityAndSendAsyncResult.cs
- ServiceHostingEnvironment.cs
- SerialStream.cs
- SafeMILHandleMemoryPressure.cs
- TreeChangeInfo.cs
- ImageConverter.cs
- WS2007HttpBindingCollectionElement.cs
- SparseMemoryStream.cs
- GetImportedCardRequest.cs
- GcHandle.cs
- SQLInt32Storage.cs
- FlatButtonAppearance.cs
- MeshGeometry3D.cs
- CellLabel.cs
- SchemaElement.cs
- Timer.cs
- TransportListener.cs
- ItemList.cs
- BitConverter.cs
- LabelTarget.cs
- StrokeSerializer.cs
- FileInfo.cs
- SapiInterop.cs
- DataSpaceManager.cs
- FileDialog_Vista.cs
- UnescapedXmlDiagnosticData.cs
- HtmlTitle.cs
- HtmlValidatorAdapter.cs
- TransformerConfigurationWizardBase.cs
- ComPersistableTypeElementCollection.cs
- DataException.cs
- ToolStripItemCollection.cs
- RootBrowserWindow.cs
- Binding.cs
- SqlUdtInfo.cs
- Automation.cs
- RequestStatusBarUpdateEventArgs.cs
- TcpAppDomainProtocolHandler.cs
- sqlmetadatafactory.cs
- ConcatQueryOperator.cs
- SpellerStatusTable.cs
- SRef.cs
- GenericTextProperties.cs
- DataGridHeaderBorder.cs
- _Win32.cs
- PositiveTimeSpanValidator.cs