Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- SerialStream.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- Vector3DCollectionValueSerializer.cs
- WizardPanel.cs
- TextFormattingConverter.cs
- Pair.cs
- DataServiceOperationContext.cs
- EntityDataSourceReferenceGroup.cs
- XmlElementAttributes.cs
- CompilerScopeManager.cs
- DataBindingExpressionBuilder.cs
- BitmapCache.cs
- TakeOrSkipWhileQueryOperator.cs
- CodeConditionStatement.cs
- XmlResolver.cs
- AnimatedTypeHelpers.cs
- SortedList.cs
- UdpChannelFactory.cs
- XmlSequenceWriter.cs
- AccessibleObject.cs
- DataViewSetting.cs
- StrokeCollectionConverter.cs
- InvalidComObjectException.cs
- WebBrowserNavigatingEventHandler.cs
- DataGridViewCellStyleChangedEventArgs.cs
- ElementAction.cs
- SmiSettersStream.cs
- ListParagraph.cs
- XmlAnyElementAttributes.cs
- ZipIOBlockManager.cs
- ReversePositionQuery.cs
- SqlUtils.cs
- TypeGeneratedEventArgs.cs
- TextServicesPropertyRanges.cs
- CompilationUtil.cs
- AccessibilityHelperForVista.cs
- Graph.cs
- RequestBringIntoViewEventArgs.cs
- ClickablePoint.cs
- RenderData.cs
- InputLangChangeRequestEvent.cs
- SecurityContext.cs
- CombinedTcpChannel.cs
- Stack.cs
- XmlObjectSerializer.cs
- WindowsToolbar.cs
- DeflateStream.cs
- Vector3DCollection.cs
- webproxy.cs
- WindowsAltTab.cs
- PackageProperties.cs
- HTMLTextWriter.cs
- Effect.cs
- HierarchicalDataSourceConverter.cs
- listitem.cs
- SmiContextFactory.cs
- CatalogZoneBase.cs
- RelationshipEndCollection.cs
- MissingMemberException.cs
- X509ChainPolicy.cs
- TypeForwardedFromAttribute.cs
- UIElementParagraph.cs
- ImageDrawing.cs
- RangeBase.cs
- FormView.cs
- EntityCollection.cs
- PngBitmapEncoder.cs
- XmlDataSourceView.cs
- Simplifier.cs
- TreeNodeCollection.cs
- Container.cs
- EmptyEnumerable.cs
- TabletCollection.cs
- LinqDataSource.cs
- Panel.cs
- OperationCanceledException.cs
- ZipIOCentralDirectoryFileHeader.cs
- AutoCompleteStringCollection.cs
- Oid.cs
- XamlTypeWithExplicitNamespace.cs
- ColumnResizeAdorner.cs
- EtwTrace.cs
- CompilerParameters.cs
- DataFormat.cs
- WebPartRestoreVerb.cs
- HttpPostedFileBase.cs
- FontInfo.cs
- JsonReaderWriterFactory.cs
- BindingNavigator.cs
- ParagraphVisual.cs
- UIElement3D.cs
- FlowDecisionDesigner.xaml.cs
- MetadataArtifactLoader.cs
- SwitchElementsCollection.cs
- IsolatedStorageFile.cs
- InvokeDelegate.cs
- ScrollBar.cs
- LinqDataSourceEditData.cs
- HtmlElementErrorEventArgs.cs
- TableRowGroupCollection.cs