Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextTreeText.cs
- IODescriptionAttribute.cs
- DirectoryNotFoundException.cs
- CodeCommentStatement.cs
- relpropertyhelper.cs
- ProxyHwnd.cs
- SignedXml.cs
- HtmlInputCheckBox.cs
- FrameworkElementFactoryMarkupObject.cs
- IconEditor.cs
- SessionStateContainer.cs
- SqlTransaction.cs
- ClientRuntimeConfig.cs
- DetailsViewPagerRow.cs
- CustomAttributeFormatException.cs
- AnnotationService.cs
- DataServiceRequestException.cs
- GradientBrush.cs
- PolyBezierSegment.cs
- TemplateControlCodeDomTreeGenerator.cs
- X509RawDataKeyIdentifierClause.cs
- PngBitmapDecoder.cs
- CommandEventArgs.cs
- TreeBuilderBamlTranslator.cs
- Oci.cs
- ObjectItemCachedAssemblyLoader.cs
- ShapingEngine.cs
- StorageModelBuildProvider.cs
- ImageBrush.cs
- WebBrowserSiteBase.cs
- StatusBarItemAutomationPeer.cs
- DrawListViewSubItemEventArgs.cs
- SHA1.cs
- SingleStorage.cs
- WindowsScrollBarBits.cs
- JsonDeserializer.cs
- LightweightCodeGenerator.cs
- ObjectDataSourceDisposingEventArgs.cs
- PathNode.cs
- FacetDescriptionElement.cs
- SafeSecurityHandles.cs
- KnownAssembliesSet.cs
- EdmEntityTypeAttribute.cs
- SecurityKeyEntropyMode.cs
- ModelServiceImpl.cs
- ConfigurationElementCollection.cs
- XPathPatternBuilder.cs
- ServiceNotStartedException.cs
- DataSetSchema.cs
- CodePageUtils.cs
- CodeThrowExceptionStatement.cs
- GridViewSelectEventArgs.cs
- GregorianCalendar.cs
- TransformGroup.cs
- ClientRolePrincipal.cs
- DataList.cs
- PermissionSet.cs
- MailSettingsSection.cs
- AssemblyResourceLoader.cs
- PointHitTestResult.cs
- ServiceHandle.cs
- WebConfigurationFileMap.cs
- SafeHandles.cs
- ProviderSettings.cs
- FileChangesMonitor.cs
- AuthenticationServiceManager.cs
- M3DUtil.cs
- FontStretches.cs
- HttpClientCertificate.cs
- Converter.cs
- HMACSHA384.cs
- ImageBrush.cs
- DesignTimeTemplateParser.cs
- JoinSymbol.cs
- StrongNameIdentityPermission.cs
- ToolStripDropDownItem.cs
- NullableFloatMinMaxAggregationOperator.cs
- WebPartDisplayModeCancelEventArgs.cs
- DetailsViewRow.cs
- DataGridHeaderBorder.cs
- TextViewBase.cs
- XmlConvert.cs
- RoutedUICommand.cs
- CroppedBitmap.cs
- ColorKeyFrameCollection.cs
- TextSelection.cs
- SharedPerformanceCounter.cs
- FillErrorEventArgs.cs
- CodeSnippetCompileUnit.cs
- CompiledQuery.cs
- FeatureAttribute.cs
- BuildDependencySet.cs
- FlowDocumentView.cs
- FileDialogCustomPlace.cs
- InternalsVisibleToAttribute.cs
- GPRECT.cs
- HtmlProps.cs
- PolicyVersionConverter.cs
- ChtmlCalendarAdapter.cs
- ConfigXmlElement.cs