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
- FtpRequestCacheValidator.cs
- AssemblyCache.cs
- ClientReliableChannelBinder.cs
- PropertyDescriptor.cs
- GPStream.cs
- ValueChangedEventManager.cs
- PropertyMap.cs
- ColumnResult.cs
- ConnectorEditor.cs
- InvokeProviderWrapper.cs
- PrintingPermission.cs
- CompoundFileStreamReference.cs
- SQLDouble.cs
- GetBrowserTokenRequest.cs
- ToolStripHighContrastRenderer.cs
- MembershipUser.cs
- MDIClient.cs
- WebConfigurationFileMap.cs
- SmiMetaDataProperty.cs
- DesignerSerializerAttribute.cs
- MaskDesignerDialog.cs
- LexicalChunk.cs
- ComplexTypeEmitter.cs
- DataPagerFieldItem.cs
- TableRowCollection.cs
- Brushes.cs
- PlacementWorkspace.cs
- AnyReturnReader.cs
- CqlIdentifiers.cs
- xamlnodes.cs
- BuildTopDownAttribute.cs
- ContentPosition.cs
- CustomErrorCollection.cs
- SqlRowUpdatingEvent.cs
- XmlDataSource.cs
- StylusPointDescription.cs
- PathFigure.cs
- StaticDataManager.cs
- DBNull.cs
- ResourceProviderFactory.cs
- HtmlTableCellCollection.cs
- NavigationProperty.cs
- BindableTemplateBuilder.cs
- XmlWriterSettings.cs
- NetCodeGroup.cs
- SynchronousReceiveElement.cs
- UntypedNullExpression.cs
- WMICapabilities.cs
- Expressions.cs
- RepeatBehavior.cs
- SafeEventLogWriteHandle.cs
- SimpleType.cs
- ParseElement.cs
- HiddenField.cs
- XPathAncestorQuery.cs
- BufferedReceiveElement.cs
- StorageMappingFragment.cs
- ComboBoxAutomationPeer.cs
- ModuleBuilderData.cs
- Permission.cs
- ConstNode.cs
- MessageBox.cs
- DataServiceHostFactory.cs
- NetNamedPipeBindingCollectionElement.cs
- SignerInfo.cs
- SkinIDTypeConverter.cs
- CrossAppDomainChannel.cs
- CompareValidator.cs
- PartialArray.cs
- Solver.cs
- UpdatePanelControlTrigger.cs
- ResourcesBuildProvider.cs
- ScopelessEnumAttribute.cs
- CngProperty.cs
- DesignerActionPropertyItem.cs
- SqlCrossApplyToCrossJoin.cs
- TemplateInstanceAttribute.cs
- MenuItemCollection.cs
- ObjectItemCollection.cs
- XmlQueryType.cs
- Inflater.cs
- StackOverflowException.cs
- MtomMessageEncoder.cs
- EdmPropertyAttribute.cs
- PageOutputColor.cs
- SuppressIldasmAttribute.cs
- ObjectSet.cs
- DelegatingConfigHost.cs
- AbstractDataSvcMapFileLoader.cs
- VoiceInfo.cs
- LayoutTableCell.cs
- PartitionResolver.cs
- RoleManagerModule.cs
- FieldAccessException.cs
- BorderGapMaskConverter.cs
- TraceSection.cs
- RoleManagerModule.cs
- ContainerControl.cs
- AttachedAnnotation.cs
- XPathMultyIterator.cs