Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- x509utils.cs
- AnnotationMap.cs
- DispatcherOperation.cs
- contentDescriptor.cs
- HasCopySemanticsAttribute.cs
- XPathNavigatorKeyComparer.cs
- BidPrivateBase.cs
- UpdateTracker.cs
- LinqDataSourceView.cs
- WebPartActionVerb.cs
- WebPermission.cs
- ErrorFormatterPage.cs
- _SSPISessionCache.cs
- AmbientProperties.cs
- DynamicMethod.cs
- PropertyDescriptorCollection.cs
- TreeNode.cs
- ConvertersCollection.cs
- DataContractSerializerFaultFormatter.cs
- VirtualPath.cs
- OleAutBinder.cs
- ScalarOps.cs
- EventLogEntry.cs
- EndpointIdentityConverter.cs
- MissingSatelliteAssemblyException.cs
- BasicBrowserDialog.cs
- Root.cs
- GeneratedCodeAttribute.cs
- XmlILTrace.cs
- ChildDocumentBlock.cs
- Int16.cs
- SuppressIldasmAttribute.cs
- CodeTypeReference.cs
- SoapEnumAttribute.cs
- FixedSOMImage.cs
- DateTime.cs
- LinqExpressionNormalizer.cs
- HttpContextServiceHost.cs
- DataGridItem.cs
- MetadataItem_Static.cs
- DataGridViewCellCollection.cs
- PageTheme.cs
- SerializableAttribute.cs
- QuestionEventArgs.cs
- AdRotator.cs
- DeploymentSection.cs
- LongTypeConverter.cs
- SchemaImporterExtensionElementCollection.cs
- _PooledStream.cs
- BidOverLoads.cs
- VisemeEventArgs.cs
- PropertyToken.cs
- BigInt.cs
- RulePatternOps.cs
- WebEncodingValidatorAttribute.cs
- MatrixStack.cs
- SystemIPv6InterfaceProperties.cs
- CodePrimitiveExpression.cs
- UpdateCommand.cs
- BasicHttpMessageSecurity.cs
- ComponentResourceKeyConverter.cs
- CachingHintValidation.cs
- WeakRefEnumerator.cs
- DispatcherTimer.cs
- TrustManagerPromptUI.cs
- WeakRefEnumerator.cs
- FlowDocumentPage.cs
- SatelliteContractVersionAttribute.cs
- DbModificationClause.cs
- Privilege.cs
- DetailsViewInsertEventArgs.cs
- SqlInternalConnectionSmi.cs
- HostUtils.cs
- Window.cs
- ResourceExpressionEditor.cs
- __Filters.cs
- OdbcPermission.cs
- PeerNameResolver.cs
- Graph.cs
- CodeGotoStatement.cs
- SerializationObjectManager.cs
- DropDownButton.cs
- Rect3D.cs
- SqlInfoMessageEvent.cs
- AssemblyResourceLoader.cs
- BooleanAnimationUsingKeyFrames.cs
- PersistChildrenAttribute.cs
- XPathDocumentIterator.cs
- XmlSchemaObjectCollection.cs
- TrueReadOnlyCollection.cs
- InitializerFacet.cs
- WindowsListViewGroupSubsetLink.cs
- ToolStripInSituService.cs
- XmlSchemaExporter.cs
- SearchForVirtualItemEventArgs.cs
- DocumentEventArgs.cs
- SqlConnectionStringBuilder.cs
- ToolBarOverflowPanel.cs
- NavigateUrlConverter.cs
- TextElement.cs