Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / MS / Internal / UIElementHelper.cs / 1 / 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. 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
- ComponentDispatcher.cs
- TextDecorationLocationValidation.cs
- InteropAutomationProvider.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- CompositeActivityCodeGenerator.cs
- CustomExpression.cs
- DispatcherObject.cs
- QueryAccessibilityHelpEvent.cs
- XmlAttributeOverrides.cs
- FieldTemplateFactory.cs
- IncrementalCompileAnalyzer.cs
- ObjectSecurity.cs
- TypeUtils.cs
- UTF32Encoding.cs
- AvTrace.cs
- TableCell.cs
- FusionWrap.cs
- XPathDocumentNavigator.cs
- ObjectSpanRewriter.cs
- Stack.cs
- ObjectTypeMapping.cs
- RemotingException.cs
- OleDbStruct.cs
- DllNotFoundException.cs
- TextEditorTables.cs
- LineServicesCallbacks.cs
- ToolStripDropDown.cs
- WorkItem.cs
- ColorBlend.cs
- RequestUriProcessor.cs
- DrawingGroupDrawingContext.cs
- CodeTypeDelegate.cs
- PresentationTraceSources.cs
- GridItemPattern.cs
- OdbcParameterCollection.cs
- COM2PictureConverter.cs
- COAUTHIDENTITY.cs
- RequestResizeEvent.cs
- PermissionAttributes.cs
- DataGridViewEditingControlShowingEventArgs.cs
- MissingFieldException.cs
- AutomationEvent.cs
- SwitchLevelAttribute.cs
- PathFigure.cs
- Select.cs
- Sql8ExpressionRewriter.cs
- QuerySettings.cs
- MatrixTransform.cs
- CommonBehaviorsSection.cs
- FormViewUpdatedEventArgs.cs
- FileAuthorizationModule.cs
- CuspData.cs
- IdentityModelStringsVersion1.cs
- RepeaterItem.cs
- smtpconnection.cs
- DataTableTypeConverter.cs
- _SingleItemRequestCache.cs
- PrimaryKeyTypeConverter.cs
- InternalTypeHelper.cs
- TypeDescriptionProviderAttribute.cs
- ColumnCollectionEditor.cs
- RecipientIdentity.cs
- PartialTrustVisibleAssembliesSection.cs
- SqlHelper.cs
- TrackingCondition.cs
- DocumentEventArgs.cs
- Size3D.cs
- TypeConverterValueSerializer.cs
- ListItemCollection.cs
- TextContainerChangeEventArgs.cs
- FixUpCollection.cs
- DrawListViewColumnHeaderEventArgs.cs
- SecurityTokenResolver.cs
- ProcessModuleCollection.cs
- XmlSchemaException.cs
- NotifyParentPropertyAttribute.cs
- WsdlBuildProvider.cs
- PeerCollaboration.cs
- ParagraphVisual.cs
- MetadataArtifactLoaderCompositeFile.cs
- C14NUtil.cs
- InputScopeAttribute.cs
- SoapIncludeAttribute.cs
- Environment.cs
- ExeContext.cs
- DesignerAttribute.cs
- FormatConvertedBitmap.cs
- ByteStream.cs
- CheckableControlBaseAdapter.cs
- BufferModesCollection.cs
- GridViewColumn.cs
- StatusBarItemAutomationPeer.cs
- Rect3D.cs
- KeyProperty.cs
- ValidatingPropertiesEventArgs.cs
- WebPartZone.cs
- BitmapEffectInput.cs
- HijriCalendar.cs
- IdentityHolder.cs
- CTreeGenerator.cs