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
- _BaseOverlappedAsyncResult.cs
- AssemblyAttributesGoHere.cs
- XPathExpr.cs
- Style.cs
- WorkflowControlEndpoint.cs
- PropertyIDSet.cs
- SqlDelegatedTransaction.cs
- SimpleMailWebEventProvider.cs
- ApplicationDirectory.cs
- EntityDataSourceWrapper.cs
- WindowsListBox.cs
- TextContainer.cs
- PeerNameRegistration.cs
- TrustLevelCollection.cs
- Rotation3DAnimationBase.cs
- TextElementEnumerator.cs
- ChtmlTextWriter.cs
- Version.cs
- XmlAttributeOverrides.cs
- RemoteCryptoDecryptRequest.cs
- Section.cs
- SqlAliasesReferenced.cs
- PrimitiveRenderer.cs
- ImportContext.cs
- MaskDescriptor.cs
- path.cs
- WsdlBuildProvider.cs
- RuleInfoComparer.cs
- SmiRequestExecutor.cs
- FlowDocumentPage.cs
- ToolStripButton.cs
- Int64Animation.cs
- ExceptionAggregator.cs
- ListBoxDesigner.cs
- NamedPipeDuplicateContext.cs
- FileClassifier.cs
- MetadataExchangeBindings.cs
- DataProviderNameConverter.cs
- MemberRelationshipService.cs
- SuppressIldasmAttribute.cs
- ParameterElementCollection.cs
- AppSettingsReader.cs
- ServiceModelConfigurationSection.cs
- ValueUnavailableException.cs
- PropertyPathConverter.cs
- MouseWheelEventArgs.cs
- CachedCompositeFamily.cs
- ValueQuery.cs
- CodeRegionDirective.cs
- BlurBitmapEffect.cs
- CallbackHandler.cs
- EntryPointNotFoundException.cs
- HostingEnvironment.cs
- ZipPackage.cs
- TokenBasedSetEnumerator.cs
- ClickablePoint.cs
- KeyConverter.cs
- Claim.cs
- JavascriptXmlWriterWrapper.cs
- HtmlEmptyTagControlBuilder.cs
- WebPartCloseVerb.cs
- SchemaImporterExtensionElementCollection.cs
- WebSysDescriptionAttribute.cs
- EventSinkHelperWriter.cs
- PropertyGeneratedEventArgs.cs
- ContentValidator.cs
- ComponentCommands.cs
- XmlTextWriter.cs
- XmlComment.cs
- PageRanges.cs
- InkCanvasFeedbackAdorner.cs
- ValidationRule.cs
- ReachFixedPageSerializerAsync.cs
- ObjectFullSpanRewriter.cs
- TemplateEditingVerb.cs
- XhtmlBasicLinkAdapter.cs
- UpdateRecord.cs
- CodeTypeReference.cs
- KeyboardNavigation.cs
- ScriptReferenceEventArgs.cs
- AdornerPresentationContext.cs
- NavigationEventArgs.cs
- DesignTimeVisibleAttribute.cs
- XmlFileEditor.cs
- ProviderUtil.cs
- UrlMappingCollection.cs
- XmlSecureResolver.cs
- UserControlBuildProvider.cs
- TableLayout.cs
- FunctionQuery.cs
- TdsEnums.cs
- PeerCredentialElement.cs
- FieldNameLookup.cs
- CompilationRelaxations.cs
- ContextMenu.cs
- FormViewAutoFormat.cs
- DesignerAutoFormatStyle.cs
- FlatButtonAppearance.cs
- SqlDelegatedTransaction.cs
- Int16Converter.cs