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
- Stream.cs
- __ComObject.cs
- DataObject.cs
- MatrixConverter.cs
- WindowsHyperlink.cs
- EventTrigger.cs
- SoapFormatExtensions.cs
- TargetParameterCountException.cs
- TransactionInformation.cs
- ObjectStorage.cs
- ImageListStreamer.cs
- AmbientLight.cs
- MouseBinding.cs
- ApplicationId.cs
- TypeDescriptor.cs
- ZipIOExtraField.cs
- EpmSourceTree.cs
- isolationinterop.cs
- PolicyValidationException.cs
- DesignerCatalogPartChrome.cs
- versioninfo.cs
- HitTestWithGeometryDrawingContextWalker.cs
- TextEditorLists.cs
- processwaithandle.cs
- ZoneButton.cs
- LabelEditEvent.cs
- InstanceDescriptor.cs
- ResourceDictionary.cs
- SvcMapFileSerializer.cs
- DataExpression.cs
- DateTimeConstantAttribute.cs
- Deflater.cs
- NamedObject.cs
- StreamResourceInfo.cs
- FormatPage.cs
- DesignerView.cs
- DataServiceRequestOfT.cs
- EventHandlerList.cs
- XamlTypeMapper.cs
- DrawingServices.cs
- NotImplementedException.cs
- TextStore.cs
- XmlC14NWriter.cs
- ValueTable.cs
- RandomNumberGenerator.cs
- CompletionProxy.cs
- MultiTrigger.cs
- PropertyKey.cs
- SmiConnection.cs
- ServiceDocumentFormatter.cs
- ConfigXmlAttribute.cs
- DataGridViewCellCollection.cs
- Command.cs
- TextViewSelectionProcessor.cs
- DataGridViewRowPrePaintEventArgs.cs
- SendActivityEventArgs.cs
- RoutedEventValueSerializer.cs
- SqlDataSourceFilteringEventArgs.cs
- MatrixCamera.cs
- FileSystemInfo.cs
- AxHost.cs
- Thumb.cs
- FolderNameEditor.cs
- ItemContainerProviderWrapper.cs
- ClientSection.cs
- TitleStyle.cs
- KeyboardNavigation.cs
- HScrollBar.cs
- SQLDateTime.cs
- DataGridViewRowPrePaintEventArgs.cs
- _SslStream.cs
- HtmlInputSubmit.cs
- XmlUTF8TextReader.cs
- TaskFileService.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ConfigurationSectionGroup.cs
- PreloadedPackages.cs
- dbenumerator.cs
- OperationFormatUse.cs
- _UriSyntax.cs
- ResXDataNode.cs
- TimersDescriptionAttribute.cs
- LingerOption.cs
- SqlSupersetValidator.cs
- LocalizabilityAttribute.cs
- ADConnectionHelper.cs
- ManipulationVelocities.cs
- DataGridViewLayoutData.cs
- DesignerSerializerAttribute.cs
- OptionalMessageQuery.cs
- TextUtf8RawTextWriter.cs
- InlinedAggregationOperator.cs
- DataSourceGroupCollection.cs
- DataListItemEventArgs.cs
- MinMaxParagraphWidth.cs
- CodeConditionStatement.cs
- Visitor.cs
- __Error.cs
- CookieHandler.cs
- Selection.cs