Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / MS / Internal / DeferredElementTreeState.cs / 2 / 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
- RawStylusInput.cs
- SoapFault.cs
- ConditionalAttribute.cs
- SetState.cs
- AutomationInteropProvider.cs
- DataGridCaption.cs
- AssertHelper.cs
- AsymmetricSignatureFormatter.cs
- DummyDataSource.cs
- GetCertificateRequest.cs
- Stream.cs
- FtpWebResponse.cs
- HwndStylusInputProvider.cs
- _CacheStreams.cs
- PriorityItem.cs
- PersonalizationState.cs
- SoapReflectionImporter.cs
- CheckoutException.cs
- RSAPKCS1SignatureDeformatter.cs
- Bezier.cs
- PeerCollaborationPermission.cs
- SecureUICommand.cs
- formatstringdialog.cs
- AcceleratedTokenAuthenticator.cs
- loginstatus.cs
- ComponentResourceManager.cs
- MetabaseReader.cs
- DocumentOrderQuery.cs
- TreeViewAutomationPeer.cs
- PanelContainerDesigner.cs
- Grid.cs
- Adorner.cs
- StrongNameSignatureInformation.cs
- CredentialCache.cs
- HighContrastHelper.cs
- ObjectItemCollection.cs
- Calendar.cs
- FontCacheUtil.cs
- BaseValidator.cs
- StringInfo.cs
- PointAnimation.cs
- TreeViewBindingsEditor.cs
- StreamGeometryContext.cs
- ReadWriteSpinLock.cs
- ObjectViewQueryResultData.cs
- DataGridViewTextBoxEditingControl.cs
- UnhandledExceptionEventArgs.cs
- BitmapFrameEncode.cs
- UiaCoreTypesApi.cs
- DeploymentSection.cs
- RedistVersionInfo.cs
- WmlValidatorAdapter.cs
- dbenumerator.cs
- LocatorPart.cs
- StringPropertyBuilder.cs
- SimpleWebHandlerParser.cs
- SqlUtil.cs
- DatatypeImplementation.cs
- OdbcInfoMessageEvent.cs
- QilChoice.cs
- DefaultExpression.cs
- HitTestParameters3D.cs
- ObjectStorage.cs
- CapabilitiesSection.cs
- objectresult_tresulttype.cs
- XmlSerializerNamespaces.cs
- CqlIdentifiers.cs
- WebEvents.cs
- ToolStripPanelSelectionGlyph.cs
- DesignerForm.cs
- PropertyPushdownHelper.cs
- ComboBoxDesigner.cs
- ActiveXSerializer.cs
- XmlDataSource.cs
- SafeRegistryHandle.cs
- SchemaHelper.cs
- DataGridViewRowCancelEventArgs.cs
- BufferBuilder.cs
- messageonlyhwndwrapper.cs
- AssemblyBuilder.cs
- DocumentGrid.cs
- ExtensibleClassFactory.cs
- DropShadowEffect.cs
- Vector3DConverter.cs
- ComponentDispatcher.cs
- ParallelEnumerable.cs
- NavigateEvent.cs
- DiffuseMaterial.cs
- DataGridViewColumnCollection.cs
- FunctionMappingTranslator.cs
- QueryInterceptorAttribute.cs
- Wildcard.cs
- StackBuilderSink.cs
- PolicyStatement.cs
- WebPartTracker.cs
- cookie.cs
- ProxyGenerationError.cs
- SoapIncludeAttribute.cs
- SelectedCellsCollection.cs
- TableAdapterManagerHelper.cs