Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- ButtonField.cs
- ListDesigner.cs
- WebPartZoneBase.cs
- GeometryHitTestResult.cs
- ArrayTypeMismatchException.cs
- ZipIOExtraFieldPaddingElement.cs
- DesignObjectWrapper.cs
- ThemeableAttribute.cs
- Subset.cs
- TypeConverter.cs
- DesigntimeLicenseContext.cs
- SiteMapHierarchicalDataSourceView.cs
- FunctionUpdateCommand.cs
- MSAAWinEventWrap.cs
- HttpCapabilitiesBase.cs
- RelationshipEnd.cs
- ColumnTypeConverter.cs
- WebPartsPersonalizationAuthorization.cs
- SelectedDatesCollection.cs
- XPathNodeInfoAtom.cs
- Rfc2898DeriveBytes.cs
- Lease.cs
- SiteMapNode.cs
- DelayedRegex.cs
- ZoneLinkButton.cs
- GroupAggregateExpr.cs
- InstanceCollisionException.cs
- SqlDataSourceCommandEventArgs.cs
- ObjectTag.cs
- DataFieldConverter.cs
- WebPartDisplayModeEventArgs.cs
- QuaternionAnimation.cs
- Atom10FormatterFactory.cs
- SelectionEditor.cs
- XmlSerializerFactory.cs
- SamlDelegatingWriter.cs
- ButtonChrome.cs
- EntityProviderFactory.cs
- CompoundFileDeflateTransform.cs
- COM2ColorConverter.cs
- BitmapImage.cs
- Asn1IntegerConverter.cs
- TemplateInstanceAttribute.cs
- SerializationObjectManager.cs
- userdatakeys.cs
- ListSourceHelper.cs
- COM2PropertyDescriptor.cs
- DbProviderFactory.cs
- EpmHelper.cs
- ArgumentException.cs
- WebPartCatalogCloseVerb.cs
- BrowserCapabilitiesCompiler.cs
- CommandEventArgs.cs
- MenuBase.cs
- RSAPKCS1SignatureDeformatter.cs
- SystemDiagnosticsSection.cs
- RepeatButton.cs
- SortAction.cs
- FunctionQuery.cs
- ExpressionEditor.cs
- DataGridViewColumnConverter.cs
- ArrangedElement.cs
- ChangesetResponse.cs
- FileClassifier.cs
- WindowsAltTab.cs
- TypeDescriptionProvider.cs
- PaintValueEventArgs.cs
- Attributes.cs
- SqlCacheDependency.cs
- AspNetHostingPermission.cs
- DefaultSerializationProviderAttribute.cs
- IntegerValidator.cs
- SrgsGrammar.cs
- RuleInfoComparer.cs
- TagPrefixInfo.cs
- MouseEventArgs.cs
- PolyBezierSegment.cs
- CachingHintValidation.cs
- XmlSerializerVersionAttribute.cs
- DataGridViewTextBoxCell.cs
- Profiler.cs
- DataColumnMappingCollection.cs
- XmlSignatureManifest.cs
- ClientProxyGenerator.cs
- DataListGeneralPage.cs
- ListQueryResults.cs
- MarkupWriter.cs
- SqlClientFactory.cs
- FixedSOMContainer.cs
- Trace.cs
- TextParagraph.cs
- AsymmetricSignatureDeformatter.cs
- DataGridTextColumn.cs
- TemplateControlBuildProvider.cs
- Size3D.cs
- OpCopier.cs
- DropDownList.cs
- LinkButton.cs
- BamlBinaryReader.cs
- StorageInfo.cs