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
- ControlBindingsConverter.cs
- XmlLanguageConverter.cs
- DaylightTime.cs
- HttpCacheParams.cs
- ConditionalDesigner.cs
- TextTrailingCharacterEllipsis.cs
- XmlCountingReader.cs
- IdentityModelStringsVersion1.cs
- DocumentSequence.cs
- BasicViewGenerator.cs
- GeneralTransform3DTo2D.cs
- UnlockInstanceAsyncResult.cs
- WebControlsSection.cs
- ResolveResponse.cs
- safelinkcollection.cs
- SyntaxCheck.cs
- Label.cs
- InvalidCastException.cs
- XPathChildIterator.cs
- WindowsAuthenticationEventArgs.cs
- XmlLanguageConverter.cs
- Label.cs
- LinqDataSourceInsertEventArgs.cs
- unsafenativemethodstextservices.cs
- CompletedAsyncResult.cs
- MinimizableAttributeTypeConverter.cs
- System.Data.OracleClient_BID.cs
- ParameterToken.cs
- InteropBitmapSource.cs
- CapabilitiesSection.cs
- ExtendLockAsyncResult.cs
- ReadOnlyCollectionBuilder.cs
- SafeFileMappingHandle.cs
- CollectionConverter.cs
- XmlFormatMapping.cs
- OracleInternalConnection.cs
- SchemaObjectWriter.cs
- AppModelKnownContentFactory.cs
- StyleCollection.cs
- PrePrepareMethodAttribute.cs
- MsdtcClusterUtils.cs
- BufferedStream2.cs
- QilName.cs
- SqlCacheDependency.cs
- MenuAutoFormat.cs
- ObjectQuery.cs
- HtmlInputReset.cs
- AccessibleObject.cs
- HelpFileFileNameEditor.cs
- DelimitedListTraceListener.cs
- DataGridViewColumnConverter.cs
- EpmAttributeNameBuilder.cs
- Rotation3DKeyFrameCollection.cs
- Mouse.cs
- MarkupObject.cs
- SmtpFailedRecipientsException.cs
- DigitShape.cs
- DataTemplate.cs
- WebPartUtil.cs
- Transform3D.cs
- ListViewDataItem.cs
- ScrollViewer.cs
- XmlEventCache.cs
- DllNotFoundException.cs
- XmlNodeChangedEventManager.cs
- SafeTimerHandle.cs
- MappingModelBuildProvider.cs
- Number.cs
- ServiceModelActivationSectionGroup.cs
- GenericTypeParameterBuilder.cs
- QueryExpression.cs
- FlowThrottle.cs
- DirectoryObjectSecurity.cs
- SmtpDateTime.cs
- LoginDesigner.cs
- SqlInfoMessageEvent.cs
- figurelength.cs
- RenderData.cs
- DataGridViewImageCell.cs
- CompilerGeneratedAttribute.cs
- WebRequestModulesSection.cs
- CheckedPointers.cs
- TypeSystem.cs
- QueryCacheManager.cs
- MemoryStream.cs
- SystemKeyConverter.cs
- ProgressBar.cs
- ActivityExecutionContextCollection.cs
- Shape.cs
- DesignerActionVerbItem.cs
- FileStream.cs
- SoapAttributes.cs
- MultiAsyncResult.cs
- MemoryMappedViewAccessor.cs
- TextBox.cs
- DtrList.cs
- XComponentModel.cs
- Enum.cs
- DataTemplateKey.cs
- RoleService.cs