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
- RMEnrollmentPage3.cs
- Error.cs
- DataViewListener.cs
- OdbcConnectionFactory.cs
- KnownIds.cs
- FormatVersion.cs
- SqlTypeConverter.cs
- Regex.cs
- DataGridViewTextBoxEditingControl.cs
- InternalUserCancelledException.cs
- SettingsBindableAttribute.cs
- ActivityExecutionContext.cs
- ImageConverter.cs
- BindingExpression.cs
- FixedSOMTextRun.cs
- StructuredTypeEmitter.cs
- SelectionListDesigner.cs
- Variable.cs
- Evidence.cs
- StreamSecurityUpgradeAcceptorAsyncResult.cs
- MenuItemBindingCollection.cs
- infer.cs
- NumberFunctions.cs
- ExpandCollapsePatternIdentifiers.cs
- LineGeometry.cs
- PackagePart.cs
- CorrelationInitializer.cs
- UnescapedXmlDiagnosticData.cs
- VisualProxy.cs
- newinstructionaction.cs
- ObjectDataSourceMethodEventArgs.cs
- SpellCheck.cs
- ToolboxItemFilterAttribute.cs
- IFlowDocumentViewer.cs
- PropertyIDSet.cs
- XamlStyleSerializer.cs
- Memoizer.cs
- Win32KeyboardDevice.cs
- GeometryModel3D.cs
- UrlAuthFailedErrorFormatter.cs
- DictionaryGlobals.cs
- NameSpaceExtractor.cs
- ChannelBinding.cs
- FtpRequestCacheValidator.cs
- Matrix3D.cs
- ToolStripArrowRenderEventArgs.cs
- XmlDataSource.cs
- httpstaticobjectscollection.cs
- StringCollection.cs
- SerializerWriterEventHandlers.cs
- WebOperationContext.cs
- IFormattable.cs
- DataControlCommands.cs
- UnaryQueryOperator.cs
- M3DUtil.cs
- Menu.cs
- DetailsViewAutoFormat.cs
- sqlinternaltransaction.cs
- DesignTimeType.cs
- OrderToken.cs
- CallbackValidator.cs
- TreeViewCancelEvent.cs
- TextBoxAutomationPeer.cs
- Matrix3DConverter.cs
- ToolStripPanelRow.cs
- DisplayNameAttribute.cs
- Win32MouseDevice.cs
- EntityDataSourceColumn.cs
- SqlXmlStorage.cs
- Rijndael.cs
- TemplatePartAttribute.cs
- ThreadWorkerController.cs
- DefaultShape.cs
- TypeEnumerableViewSchema.cs
- MessageBox.cs
- COM2Properties.cs
- ControlSerializer.cs
- BlurBitmapEffect.cs
- PeerTransportElement.cs
- PropertyInfo.cs
- TypeDescriptor.cs
- UnionCodeGroup.cs
- ToolStripItemEventArgs.cs
- ProtocolsConfigurationEntry.cs
- QilTernary.cs
- JavaScriptObjectDeserializer.cs
- EasingKeyFrames.cs
- HostUtils.cs
- Attributes.cs
- DiagnosticEventProvider.cs
- ModifierKeysValueSerializer.cs
- StringSource.cs
- DeferredTextReference.cs
- SchemaManager.cs
- SlotInfo.cs
- NamespaceQuery.cs
- BitmapEffectRenderDataResource.cs
- HitTestWithGeometryDrawingContextWalker.cs
- VideoDrawing.cs
- WorkflowCompensationBehavior.cs