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
- RequestUriProcessor.cs
- ErrorHandler.cs
- SwitchElementsCollection.cs
- TextRange.cs
- DataContractSet.cs
- DatatypeImplementation.cs
- TypeDescriptorContext.cs
- BaseTemplateParser.cs
- ObjectDisposedException.cs
- AutomationElement.cs
- CompositeFontParser.cs
- CustomErrorsSection.cs
- OletxTransactionHeader.cs
- X509CertificateValidator.cs
- EncryptedData.cs
- ContextProperty.cs
- Int32Animation.cs
- XmlProcessingInstruction.cs
- Condition.cs
- TeredoHelper.cs
- AsymmetricKeyExchangeDeformatter.cs
- MetafileHeaderWmf.cs
- PersonalizationDictionary.cs
- PeerObject.cs
- GAC.cs
- CodeSnippetTypeMember.cs
- TemplateBindingExpression.cs
- TraceHandlerErrorFormatter.cs
- DocumentReferenceCollection.cs
- rsa.cs
- SafeNativeMethods.cs
- WebPartEventArgs.cs
- InfoCardUIAgent.cs
- IListConverters.cs
- IndexedWhereQueryOperator.cs
- SortFieldComparer.cs
- RepeaterItemCollection.cs
- Attributes.cs
- DetailsViewModeEventArgs.cs
- AlternateViewCollection.cs
- WSSecurityPolicy12.cs
- ConfigurationManager.cs
- DispatcherEventArgs.cs
- IdnMapping.cs
- webproxy.cs
- TextViewElement.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- RefreshEventArgs.cs
- NativeMethods.cs
- OneOfTypeConst.cs
- XmlAttributeOverrides.cs
- EntityContainerEntitySet.cs
- PaperSource.cs
- EncryptedPackage.cs
- XmlWellformedWriter.cs
- Hash.cs
- MruCache.cs
- ByteAnimation.cs
- XmlQueryContext.cs
- ExternalException.cs
- DispatchWrapper.cs
- PropertyGridEditorPart.cs
- ValueUtilsSmi.cs
- SystemWebSectionGroup.cs
- FieldAccessException.cs
- WebZone.cs
- PageAction.cs
- NeutralResourcesLanguageAttribute.cs
- DescendentsWalker.cs
- LocalValueEnumerator.cs
- Int16.cs
- StickyNoteAnnotations.cs
- GenerateScriptTypeAttribute.cs
- SAPICategories.cs
- DataColumnMapping.cs
- TextBoxView.cs
- RichTextBoxConstants.cs
- EmbeddedObject.cs
- DataGridRowDetailsEventArgs.cs
- ListBindableAttribute.cs
- Identity.cs
- _SecureChannel.cs
- StyleModeStack.cs
- SettingsPropertyIsReadOnlyException.cs
- UriWriter.cs
- SmiXetterAccessMap.cs
- CustomAttribute.cs
- NetWebProxyFinder.cs
- CornerRadius.cs
- BitConverter.cs
- MediaCommands.cs
- XPathConvert.cs
- RpcAsyncResult.cs
- GeneralTransform3DTo2DTo3D.cs
- WorkflowDebuggerSteppingAttribute.cs
- TypeBuilder.cs
- QueryOutputWriter.cs
- TimelineGroup.cs
- EncodingTable.cs
- assertwrapper.cs