Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / DescendentsWalkerBase.cs / 1 / 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; internal const int MAX_TREE_DEPTH = 250; } /// /// 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; internal const int MAX_TREE_DEPTH = 250; } /// /// 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
- MailWriter.cs
- MenuItem.cs
- CreatingCookieEventArgs.cs
- Stylesheet.cs
- DispatchOperationRuntime.cs
- LinqDataSourceUpdateEventArgs.cs
- RepeatButton.cs
- RequestCache.cs
- WmfPlaceableFileHeader.cs
- RegisteredArrayDeclaration.cs
- WebPartMenu.cs
- XmlCharCheckingReader.cs
- QilDataSource.cs
- FilterRepeater.cs
- Brush.cs
- ObjectListDataBindEventArgs.cs
- XmlSchemaObjectCollection.cs
- MenuItemAutomationPeer.cs
- NumberFormatter.cs
- ClientRolePrincipal.cs
- LinkUtilities.cs
- WpfXamlLoader.cs
- CultureSpecificStringDictionary.cs
- DataGridViewComboBoxEditingControl.cs
- Logging.cs
- SafeMemoryMappedViewHandle.cs
- SmtpMail.cs
- PeerApplication.cs
- TraceRecord.cs
- MultipleViewPattern.cs
- InputBuffer.cs
- PathSegmentCollection.cs
- StyleBamlRecordReader.cs
- ExpanderAutomationPeer.cs
- FunctionDefinition.cs
- InputMethod.cs
- ImageCodecInfo.cs
- TextFormatterContext.cs
- TextTreeExtractElementUndoUnit.cs
- XmlSerializer.cs
- MemoryStream.cs
- GridViewUpdateEventArgs.cs
- QueryCacheKey.cs
- ToolBarButtonClickEvent.cs
- GatewayDefinition.cs
- LogicalMethodInfo.cs
- RadioButtonList.cs
- ErrorTableItemStyle.cs
- CalloutQueueItem.cs
- GPPOINTF.cs
- Globals.cs
- StylusPointCollection.cs
- RemotingException.cs
- SingleKeyFrameCollection.cs
- SessionParameter.cs
- XamlClipboardData.cs
- ProcessHostServerConfig.cs
- ProfileWorkflowElement.cs
- If.cs
- TypeLoadException.cs
- ListViewUpdatedEventArgs.cs
- ObjectReaderCompiler.cs
- TypeSystemProvider.cs
- XomlCompilerParameters.cs
- DataGridToolTip.cs
- HuffmanTree.cs
- AmbiguousMatchException.cs
- assertwrapper.cs
- DesignerInterfaces.cs
- EncoderBestFitFallback.cs
- WriteTimeStream.cs
- PermissionToken.cs
- RawStylusActions.cs
- Style.cs
- EventMappingSettings.cs
- InitializerFacet.cs
- login.cs
- DetailsViewRowCollection.cs
- UnicodeEncoding.cs
- AuthenticationConfig.cs
- LinkTarget.cs
- SecureStringHasher.cs
- MetadataCacheItem.cs
- TrackPoint.cs
- ErrorWebPart.cs
- SapiGrammar.cs
- COM2PictureConverter.cs
- SourceExpressionException.cs
- ByValueEqualityComparer.cs
- DropShadowBitmapEffect.cs
- AppLevelCompilationSectionCache.cs
- TemplateNameScope.cs
- SqlDataSourceSelectingEventArgs.cs
- Pen.cs
- GridViewDeleteEventArgs.cs
- Stroke2.cs
- ExtendedPropertyInfo.cs
- StringAttributeCollection.cs
- BrowserPolicyValidator.cs
- Encoder.cs