Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / MS / Internal / UIElementHelper.cs / 3 / UIElementHelper.cs
using System.Diagnostics; using System.Windows; using System.Windows.Media; using System.Windows.Media.Media3D; using System.Windows.Input; using MS.Internal.PresentationCore; namespace MS.Internal { internal static class UIElementHelper { [FriendAccessAllowed] internal static bool IsHitTestVisible(DependencyObject o) { Debug.Assert(o != null, "UIElementHelper.IsHitTestVisible called with null argument"); UIElement oAsUIElement = o as UIElement; if (oAsUIElement != null) { return oAsUIElement.IsHitTestVisible; } else { return ((UIElement3D)o).IsHitTestVisible; } } [FriendAccessAllowed] internal static bool IsVisible(DependencyObject o) { Debug.Assert(o != null, "UIElementHelper.IsVisible called with null argument"); UIElement oAsUIElement = o as UIElement; if (oAsUIElement != null) { return oAsUIElement.IsVisible; } else { return ((UIElement3D)o).IsVisible; } } [FriendAccessAllowed] internal static DependencyObject PredictFocus(DependencyObject o, FocusNavigationDirection direction) { Debug.Assert(o != null, "UIElementHelper.PredictFocus called with null argument"); UIElement oAsUIElement = o as UIElement; if (oAsUIElement != null) { return oAsUIElement.PredictFocus(direction); } else { return ((UIElement3D)o).PredictFocus(direction); } } [FriendAccessAllowed] internal static UIElement GetContainingUIElement2D(DependencyObject reference) { UIElement element = null; while (reference != null) { element = reference as UIElement; if (element != null) break; reference = VisualTreeHelper.GetParent(reference); } return element; } [FriendAccessAllowed] internal static DependencyObject GetUIParent(DependencyObject child) { DependencyObject parent = GetUIParent(child, false); return parent; } [FriendAccessAllowed] internal static DependencyObject GetUIParent(DependencyObject child, bool continuePastVisualTree) { DependencyObject parent = null; DependencyObject myParent = null; // Try to find a UIElement parent in the visual ancestry. if (child is Visual) { myParent = ((Visual)child).InternalVisualParent; } else { myParent = ((Visual3D)child).InternalVisualParent; } parent = InputElement.GetContainingUIElement(myParent) as DependencyObject; // If there was no UIElement parent in the visual ancestry, // check along the logical branch. if(parent == null && continuePastVisualTree) { UIElement childAsUIElement = child as UIElement; if (childAsUIElement != null) { parent = InputElement.GetContainingInputElement(childAsUIElement.GetUIParentCore()) as DependencyObject; } else { UIElement3D childAsUIElement3D = child as UIElement3D; if (childAsUIElement3D != null) { parent = InputElement.GetContainingInputElement(childAsUIElement3D.GetUIParentCore()) as DependencyObject; } } } return parent; } [FriendAccessAllowed] internal static bool IsUIElementOrUIElement3D(DependencyObject o) { return (o is UIElement || o is UIElement3D); } } } // 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
- EncodingFallbackAwareXmlTextWriter.cs
- BufferedStream.cs
- RecordManager.cs
- MbpInfo.cs
- IdentityReference.cs
- GestureRecognitionResult.cs
- TextElement.cs
- AutoCompleteStringCollection.cs
- MdiWindowListStrip.cs
- CodeTypeDeclaration.cs
- CompositeActivityDesigner.cs
- BitmapCodecInfoInternal.cs
- ValidatingReaderNodeData.cs
- AsyncCallback.cs
- _OSSOCK.cs
- TableStyle.cs
- COM2PropertyBuilderUITypeEditor.cs
- _NetworkingPerfCounters.cs
- ObjectDataSourceStatusEventArgs.cs
- WindowsListView.cs
- EdmToObjectNamespaceMap.cs
- StartFileNameEditor.cs
- ProviderBase.cs
- TraceHwndHost.cs
- GregorianCalendar.cs
- XmlSchemaAll.cs
- XmlSchemaSimpleContentExtension.cs
- XmlReaderDelegator.cs
- AxisAngleRotation3D.cs
- UInt64.cs
- ListenerElementsCollection.cs
- LockRecursionException.cs
- SafeNativeMethods.cs
- NeutralResourcesLanguageAttribute.cs
- PathStreamGeometryContext.cs
- ValidateNames.cs
- HttpCookiesSection.cs
- UrlPath.cs
- MailDefinition.cs
- BulletedList.cs
- XmlSerializerSection.cs
- FontWeightConverter.cs
- WindowsTooltip.cs
- ObjectMaterializedEventArgs.cs
- XmlSchemaComplexContentExtension.cs
- AccessDataSource.cs
- HelpKeywordAttribute.cs
- SplitContainer.cs
- DataContext.cs
- DataSetFieldSchema.cs
- Tracking.cs
- PartitionerStatic.cs
- FormViewUpdateEventArgs.cs
- ReadOnlyObservableCollection.cs
- ProgressBarAutomationPeer.cs
- CngUIPolicy.cs
- XmlAttributeOverrides.cs
- CompileLiteralTextParser.cs
- AspCompat.cs
- CqlGenerator.cs
- TextSpan.cs
- LoginUtil.cs
- XmlSchemaSimpleTypeRestriction.cs
- Cursors.cs
- EmbeddedObject.cs
- SerializationHelper.cs
- Container.cs
- ClaimSet.cs
- XpsThumbnail.cs
- input.cs
- XmlStreamNodeWriter.cs
- Matrix3DStack.cs
- SHA512Cng.cs
- ConfigurationValue.cs
- StylusPlugin.cs
- MouseGestureValueSerializer.cs
- ClientConfigPaths.cs
- XmlTextAttribute.cs
- SByte.cs
- PolicyLevel.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- XNodeValidator.cs
- StopStoryboard.cs
- MetafileHeaderEmf.cs
- AssemblyCache.cs
- InputScopeNameConverter.cs
- XPathNode.cs
- OleDbParameterCollection.cs
- PolicyImporterElement.cs
- FunctionImportElement.cs
- SapiRecoInterop.cs
- ObjectDataSourceSelectingEventArgs.cs
- WebServicesSection.cs
- loginstatus.cs
- InkCanvasInnerCanvas.cs
- AuthenticationModuleElement.cs
- DataControlFieldCell.cs
- SettingsBindableAttribute.cs
- ControllableStoryboardAction.cs
- IndexerNameAttribute.cs