Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / MS / Internal / DeferredElementTreeState.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HeaderCollection.cs
- XmlBinaryReader.cs
- SmtpDigestAuthenticationModule.cs
- HyperLinkStyle.cs
- XmlNotation.cs
- TemplateControlBuildProvider.cs
- DelayedRegex.cs
- TreeNodeCollection.cs
- PriorityRange.cs
- TraceContextRecord.cs
- ColumnClickEvent.cs
- OlePropertyStructs.cs
- CultureSpecificCharacterBufferRange.cs
- Point3DAnimation.cs
- invalidudtexception.cs
- PageCache.cs
- ToolStripStatusLabel.cs
- PropertyMapper.cs
- CodeIndexerExpression.cs
- CustomBindingCollectionElement.cs
- TransformProviderWrapper.cs
- SqlConnection.cs
- ConfigurationConverterBase.cs
- ItemCheckEvent.cs
- Input.cs
- ComponentCommands.cs
- EnlistmentTraceIdentifier.cs
- NotificationContext.cs
- SamlSubjectStatement.cs
- TcpPortSharing.cs
- RSACryptoServiceProvider.cs
- GridItemCollection.cs
- TextCompositionManager.cs
- TextElementEnumerator.cs
- SrgsSemanticInterpretationTag.cs
- _ProxyRegBlob.cs
- XmlAggregates.cs
- ClientBuildManager.cs
- Tokenizer.cs
- TypeDescriptionProvider.cs
- CodeDefaultValueExpression.cs
- PopupEventArgs.cs
- MetadataHelper.cs
- ReadOnlyAttribute.cs
- ExpressionWriter.cs
- TreeNodeSelectionProcessor.cs
- Roles.cs
- EdmTypeAttribute.cs
- ValueTypeFixupInfo.cs
- TypeElement.cs
- UriParserTemplates.cs
- SQLDoubleStorage.cs
- EventSinkHelperWriter.cs
- ToolStripSystemRenderer.cs
- ConfigurationSection.cs
- TimeStampChecker.cs
- RowSpanVector.cs
- BamlTreeUpdater.cs
- WindowsAuthenticationModule.cs
- TraceSource.cs
- WindowsAuthenticationModule.cs
- WSTrust.cs
- HttpResponseHeader.cs
- SessionStateContainer.cs
- CheckBox.cs
- PersonalizableAttribute.cs
- SiteMapNode.cs
- GACIdentityPermission.cs
- JapaneseCalendar.cs
- COM2IDispatchConverter.cs
- DataGridViewTextBoxEditingControl.cs
- ClientBuildManager.cs
- SharedHttpsTransportManager.cs
- ParallelLoopState.cs
- QueryReaderSettings.cs
- DependencyProperty.cs
- SymLanguageVendor.cs
- PointLight.cs
- XPathNavigatorKeyComparer.cs
- Evidence.cs
- SQLBoolean.cs
- __Filters.cs
- DataTableMappingCollection.cs
- BaseComponentEditor.cs
- CopyAction.cs
- DataReaderContainer.cs
- DataGridViewColumnStateChangedEventArgs.cs
- SharedDp.cs
- GeometryValueSerializer.cs
- WindowsAuthenticationModule.cs
- Vector3D.cs
- RegexStringValidator.cs
- CommandBinding.cs
- OleDbWrapper.cs
- BehaviorEditorPart.cs
- FixedPageAutomationPeer.cs
- XmlDomTextWriter.cs
- HostedTcpTransportManager.cs
- InputBindingCollection.cs
- StringAnimationBase.cs