Code:
/ 4.0 / 4.0 / 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. 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
- WsdlBuildProvider.cs
- TdsParserSessionPool.cs
- SettingsSavedEventArgs.cs
- SerializationException.cs
- QueryConverter.cs
- ProfileParameter.cs
- MenuAdapter.cs
- DiagnosticsConfigurationHandler.cs
- ClientCultureInfo.cs
- ClientBuildManager.cs
- Literal.cs
- ChildTable.cs
- HttpServerProtocol.cs
- Attribute.cs
- PeerToPeerException.cs
- DataGridBoolColumn.cs
- ClassicBorderDecorator.cs
- DrawingGroup.cs
- BindToObject.cs
- TextTreeDeleteContentUndoUnit.cs
- GeneralTransform2DTo3D.cs
- ImageMetadata.cs
- WebPartPersonalization.cs
- IISMapPath.cs
- WCFModelStrings.Designer.cs
- X500Name.cs
- ToolStripItemRenderEventArgs.cs
- QilReference.cs
- FormsAuthentication.cs
- SessionEndingCancelEventArgs.cs
- CopyOnWriteList.cs
- ZipQueryOperator.cs
- EntityDesignerBuildProvider.cs
- PowerModeChangedEventArgs.cs
- _Rfc2616CacheValidators.cs
- DataFormats.cs
- BrowserCapabilitiesCompiler.cs
- XmlEventCache.cs
- DataBinder.cs
- HiddenFieldPageStatePersister.cs
- ScalarOps.cs
- MulticastDelegate.cs
- XhtmlBasicLabelAdapter.cs
- DataGridViewColumn.cs
- XmlUnspecifiedAttribute.cs
- AccessibilityApplicationManager.cs
- UInt32Converter.cs
- HostedElements.cs
- ActivityExecutor.cs
- WebResponse.cs
- StringCollection.cs
- XmlSchema.cs
- DataGridRowHeader.cs
- SafeRightsManagementHandle.cs
- Model3D.cs
- TreeWalker.cs
- ParameterRetriever.cs
- TriggerAction.cs
- RtfControlWordInfo.cs
- InputBinder.cs
- CacheVirtualItemsEvent.cs
- CharKeyFrameCollection.cs
- MenuBindingsEditorForm.cs
- DataGridLinkButton.cs
- ApplicationSecurityInfo.cs
- CatalogPartDesigner.cs
- ILGenerator.cs
- Task.cs
- NotifyParentPropertyAttribute.cs
- EventHandlersStore.cs
- AuthenticationModuleElementCollection.cs
- Pkcs7Recipient.cs
- RelatedImageListAttribute.cs
- EntityDataSourceDataSelectionPanel.designer.cs
- BrowserInteropHelper.cs
- _NtlmClient.cs
- SqlMethods.cs
- BulletChrome.cs
- ParseHttpDate.cs
- ClientApiGenerator.cs
- ScriptIgnoreAttribute.cs
- SafeArrayRankMismatchException.cs
- ReadOnlyCollectionBase.cs
- DirectionalLight.cs
- PersistChildrenAttribute.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- CompModSwitches.cs
- CheckBox.cs
- SizeAnimationBase.cs
- ResolvedKeyFrameEntry.cs
- ParameterExpression.cs
- HostVisual.cs
- JsonReader.cs
- Int64KeyFrameCollection.cs
- DataGridCheckBoxColumn.cs
- sqlser.cs
- ObjectDataSourceDisposingEventArgs.cs
- DPAPIProtectedConfigurationProvider.cs
- SystemKeyConverter.cs
- HtmlControlPersistable.cs