Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / MS / Internal / DeferredElementTreeState.cs / 1 / DeferredElementTreeState.cs
using System.Windows; using System.Collections.Generic; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Media3D; namespace MS.Internal { internal class DeferredElementTreeState { public void SetCoreParent(DependencyObject element, DependencyObject parent) { if(!_oldCoreParents.ContainsKey(element)) { _oldCoreParents[element] = parent; } } public static DependencyObject GetCoreParent(DependencyObject element, DeferredElementTreeState treeState) { DependencyObject parent = null; if(treeState != null && treeState._oldCoreParents.ContainsKey(element)) { parent = treeState._oldCoreParents[element]; } else { Visual v = element as Visual; if(v != null) { parent = VisualTreeHelper.GetParent(v); } else { ContentElement ce = element as ContentElement; if(ce != null) { parent = ContentOperations.GetParent(ce); } else { Visual3D v3D = element as Visual3D; if (v3D != null) { parent = VisualTreeHelper.GetParent(v3D); } } } } return parent; } public static DependencyObject GetInputElementParent(DependencyObject element, DeferredElementTreeState treeState) { DependencyObject parent = element; while (true) { parent = GetCoreParent(parent, treeState); if (parent == null || InputElement.IsValid(parent)) { break; } } return parent; } public void SetLogicalParent(DependencyObject element, DependencyObject parent) { if(!_oldLogicalParents.ContainsKey(element)) { _oldLogicalParents[element] = parent; } } public static DependencyObject GetLogicalParent(DependencyObject element, DeferredElementTreeState treeState) { DependencyObject parent = null; if(treeState != null && treeState._oldLogicalParents.ContainsKey(element)) { parent = treeState._oldLogicalParents[element]; } else { UIElement e = element as UIElement; if(e != null) { parent = e.GetUIParentCore(); // Overriden by FrameworkElement. } ContentElement ce = element as ContentElement; if(ce != null) { parent = ce.GetUIParentCore(); // Overriden by FrameworkContentElement. } } return parent; } public void Clear() { _oldCoreParents.Clear(); _oldLogicalParents.Clear(); } public bool IsEmpty { get { return _oldCoreParents.Count > 0 || _oldLogicalParents.Count > 0; } } private Dictionary_oldCoreParents = new Dictionary (); private Dictionary _oldLogicalParents = new Dictionary (); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System.Windows; using System.Collections.Generic; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Media3D; namespace MS.Internal { internal class DeferredElementTreeState { public void SetCoreParent(DependencyObject element, DependencyObject parent) { if(!_oldCoreParents.ContainsKey(element)) { _oldCoreParents[element] = parent; } } public static DependencyObject GetCoreParent(DependencyObject element, DeferredElementTreeState treeState) { DependencyObject parent = null; if(treeState != null && treeState._oldCoreParents.ContainsKey(element)) { parent = treeState._oldCoreParents[element]; } else { Visual v = element as Visual; if(v != null) { parent = VisualTreeHelper.GetParent(v); } else { ContentElement ce = element as ContentElement; if(ce != null) { parent = ContentOperations.GetParent(ce); } else { Visual3D v3D = element as Visual3D; if (v3D != null) { parent = VisualTreeHelper.GetParent(v3D); } } } } return parent; } public static DependencyObject GetInputElementParent(DependencyObject element, DeferredElementTreeState treeState) { DependencyObject parent = element; while (true) { parent = GetCoreParent(parent, treeState); if (parent == null || InputElement.IsValid(parent)) { break; } } return parent; } public void SetLogicalParent(DependencyObject element, DependencyObject parent) { if(!_oldLogicalParents.ContainsKey(element)) { _oldLogicalParents[element] = parent; } } public static DependencyObject GetLogicalParent(DependencyObject element, DeferredElementTreeState treeState) { DependencyObject parent = null; if(treeState != null && treeState._oldLogicalParents.ContainsKey(element)) { parent = treeState._oldLogicalParents[element]; } else { UIElement e = element as UIElement; if(e != null) { parent = e.GetUIParentCore(); // Overriden by FrameworkElement. } ContentElement ce = element as ContentElement; if(ce != null) { parent = ce.GetUIParentCore(); // Overriden by FrameworkContentElement. } } return parent; } public void Clear() { _oldCoreParents.Clear(); _oldLogicalParents.Clear(); } public bool IsEmpty { get { return _oldCoreParents.Count > 0 || _oldLogicalParents.Count > 0; } } private Dictionary _oldCoreParents = new Dictionary (); private Dictionary _oldLogicalParents = new Dictionary (); } } // 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
- VirtualizingStackPanel.cs
- DependencyObject.cs
- SafeArrayRankMismatchException.cs
- RowUpdatingEventArgs.cs
- If.cs
- LifetimeServices.cs
- ClientTargetSection.cs
- RadialGradientBrush.cs
- DummyDataSource.cs
- sqlcontext.cs
- MultiTrigger.cs
- UncommonField.cs
- CodeVariableReferenceExpression.cs
- PageRanges.cs
- Int32.cs
- BamlLocalizabilityResolver.cs
- SchemaManager.cs
- XmlQueryType.cs
- VirtualPathProvider.cs
- ClassDataContract.cs
- BindingList.cs
- HttpRequestCacheValidator.cs
- CompModSwitches.cs
- MetaType.cs
- WebPartZone.cs
- ValidatedControlConverter.cs
- SessionStateItemCollection.cs
- SchemaConstraints.cs
- ListItemCollection.cs
- TextRangeEdit.cs
- DataGridViewTextBoxEditingControl.cs
- AccessDataSourceView.cs
- OperationValidationEventArgs.cs
- SetterBase.cs
- RectangleHotSpot.cs
- StorageAssociationSetMapping.cs
- Int16.cs
- PeerEndPoint.cs
- ObjectDataSourceView.cs
- SqlDeflator.cs
- ReadOnlyCollection.cs
- ViewPort3D.cs
- SelectionItemPattern.cs
- PageContentAsyncResult.cs
- CompressEmulationStream.cs
- ServiceOperationParameter.cs
- SessionStateItemCollection.cs
- LabelLiteral.cs
- BitVector32.cs
- ImageCodecInfoPrivate.cs
- EventSourceCreationData.cs
- IndentedTextWriter.cs
- ElapsedEventArgs.cs
- XmlTextEncoder.cs
- MergePropertyDescriptor.cs
- DataTableTypeConverter.cs
- ModelVisual3D.cs
- XmlSchemaIdentityConstraint.cs
- SmtpSection.cs
- MultiView.cs
- XmlDomTextWriter.cs
- RowsCopiedEventArgs.cs
- SafeLocalMemHandle.cs
- CodeConditionStatement.cs
- ReaderOutput.cs
- FlowDocument.cs
- XslAstAnalyzer.cs
- ColorDialog.cs
- HtmlInputButton.cs
- DateTimeOffset.cs
- DataControlCommands.cs
- HtmlWindow.cs
- AppDomainAttributes.cs
- SiteMapSection.cs
- TextFormatterContext.cs
- TextReader.cs
- WindowsAuthenticationEventArgs.cs
- InnerItemCollectionView.cs
- Image.cs
- AttachedPropertyMethodSelector.cs
- AppLevelCompilationSectionCache.cs
- CodeTypeDeclaration.cs
- UnwrappedTypesXmlSerializerManager.cs
- PropertyKey.cs
- XmlSchemaType.cs
- DetailsViewRow.cs
- IssuanceLicense.cs
- HitTestWithPointDrawingContextWalker.cs
- SqlRecordBuffer.cs
- AssemblyAttributesGoHere.cs
- recordstatescratchpad.cs
- XmlBoundElement.cs
- GraphicsPathIterator.cs
- RewritingPass.cs
- DropDownButton.cs
- TreeViewHitTestInfo.cs
- Speller.cs
- SqlUtils.cs
- Formatter.cs
- InkCanvasSelectionAdorner.cs