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
- ResolveNameEventArgs.cs
- BamlRecordReader.cs
- TripleDESCryptoServiceProvider.cs
- DBDataPermissionAttribute.cs
- TrackingServices.cs
- SelectorAutomationPeer.cs
- HighContrastHelper.cs
- XmlDocumentFragment.cs
- CopyAction.cs
- sitestring.cs
- FrameDimension.cs
- TypeSchema.cs
- NullableDecimalMinMaxAggregationOperator.cs
- UInt16Storage.cs
- DeclarativeCatalogPart.cs
- VectorAnimationBase.cs
- FormViewInsertEventArgs.cs
- StylusEditingBehavior.cs
- Geometry.cs
- DynamicRouteExpression.cs
- CacheHelper.cs
- HttpServerUtilityWrapper.cs
- BindingMAnagerBase.cs
- storepermissionattribute.cs
- SqlClientWrapperSmiStreamChars.cs
- ChangeBlockUndoRecord.cs
- MergeEnumerator.cs
- ToggleButtonAutomationPeer.cs
- WebPartZoneBase.cs
- TaiwanCalendar.cs
- SettingsSavedEventArgs.cs
- XmlSchemaInferenceException.cs
- RepeatButton.cs
- SaveFileDialog.cs
- ServiceHostingEnvironment.cs
- Parameter.cs
- CaseInsensitiveComparer.cs
- XmlMtomWriter.cs
- FormViewInsertedEventArgs.cs
- CngAlgorithm.cs
- SqlNodeAnnotations.cs
- LocalizableAttribute.cs
- DefaultExpressionVisitor.cs
- ToolStripContainer.cs
- DrawTreeNodeEventArgs.cs
- HostProtectionPermission.cs
- CngKey.cs
- XmlFormatWriterGenerator.cs
- XslCompiledTransform.cs
- XmlElementAttributes.cs
- EventRouteFactory.cs
- OlePropertyStructs.cs
- AnimationStorage.cs
- HwndSource.cs
- LinqDataSourceInsertEventArgs.cs
- WindowsRichEdit.cs
- ProfileEventArgs.cs
- ThousandthOfEmRealPoints.cs
- namescope.cs
- TemplateManager.cs
- ScrollProviderWrapper.cs
- ThaiBuddhistCalendar.cs
- IdentitySection.cs
- RuleSetBrowserDialog.cs
- FixedTextPointer.cs
- GZipDecoder.cs
- AdPostCacheSubstitution.cs
- MSAAEventDispatcher.cs
- Light.cs
- AspProxy.cs
- WizardDesigner.cs
- OleDbTransaction.cs
- PrimitiveXmlSerializers.cs
- SvcMapFileLoader.cs
- DoubleUtil.cs
- HostedElements.cs
- Delegate.cs
- DataControlImageButton.cs
- PackageStore.cs
- Point.cs
- ColorTransformHelper.cs
- PrimarySelectionAdorner.cs
- InstalledVoice.cs
- ServiceEndpointElement.cs
- DES.cs
- Transactions.cs
- TraceListeners.cs
- DeferredBinaryDeserializerExtension.cs
- EditorZoneBase.cs
- RepeatButtonAutomationPeer.cs
- RubberbandSelector.cs
- DataTableTypeConverter.cs
- MultiPageTextView.cs
- XmlSchemaCompilationSettings.cs
- DataGridViewAutoSizeModeEventArgs.cs
- SqlBuffer.cs
- EventRecord.cs
- UIInitializationException.cs
- MsdtcWrapper.cs
- TraceSection.cs