Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- ComNativeDescriptor.cs
- TextFormatterHost.cs
- Sql8ExpressionRewriter.cs
- XmlSchemaSimpleContent.cs
- HandlerFactoryCache.cs
- CodeNamespaceCollection.cs
- AssociationSetEnd.cs
- AttachedAnnotation.cs
- TreeViewImageIndexConverter.cs
- ProfileBuildProvider.cs
- ListView.cs
- ExpressionBinding.cs
- FixedSOMPageConstructor.cs
- TraceContext.cs
- QuadraticBezierSegment.cs
- ProviderMetadata.cs
- DefaultTextStore.cs
- NativeWrapper.cs
- StringAttributeCollection.cs
- RoleBoolean.cs
- SafeNativeMethods.cs
- PropertyGroupDescription.cs
- FileStream.cs
- SortedSet.cs
- RowUpdatingEventArgs.cs
- AdapterUtil.cs
- TiffBitmapEncoder.cs
- LocalClientSecuritySettingsElement.cs
- SqlDataSourceConfigureSelectPanel.cs
- CellCreator.cs
- IImplicitResourceProvider.cs
- CodeValidator.cs
- FtpWebResponse.cs
- DataGridViewBand.cs
- ScrollEvent.cs
- PreloadHost.cs
- HttpHandlerAction.cs
- MetadataAssemblyHelper.cs
- ManifestSignedXml.cs
- securitycriticaldataformultiplegetandset.cs
- XmlSchemaObjectTable.cs
- DecimalConstantAttribute.cs
- FileSystemWatcher.cs
- DependsOnAttribute.cs
- ErrorStyle.cs
- NgenServicingAttributes.cs
- PathData.cs
- ACE.cs
- SubpageParaClient.cs
- InternalPolicyElement.cs
- ResourceAssociationSetEnd.cs
- ManualResetEvent.cs
- DetailsViewPagerRow.cs
- WorkflowServiceBehavior.cs
- LineBreak.cs
- SqlMethodAttribute.cs
- AxHostDesigner.cs
- XmlSchemaSet.cs
- Color.cs
- NamedElement.cs
- CodeSubDirectoriesCollection.cs
- ProcessModelSection.cs
- MetadataWorkspace.cs
- ReachPageContentCollectionSerializerAsync.cs
- RuleRefElement.cs
- SymmetricAlgorithm.cs
- BoundsDrawingContextWalker.cs
- X509ChainElement.cs
- JavaScriptString.cs
- ListViewSortEventArgs.cs
- KeyPressEvent.cs
- WindowsFormsHelpers.cs
- unitconverter.cs
- SystemDiagnosticsSection.cs
- InputScopeAttribute.cs
- TreeWalkHelper.cs
- ExeContext.cs
- VirtualDirectoryMappingCollection.cs
- HelpExampleGenerator.cs
- TextRangeProviderWrapper.cs
- TraceSwitch.cs
- NameSpaceExtractor.cs
- AutomationPeer.cs
- Stream.cs
- RawUIStateInputReport.cs
- ScrollContentPresenter.cs
- HostingEnvironmentSection.cs
- ProviderException.cs
- PartitionResolver.cs
- SingleAnimationUsingKeyFrames.cs
- Visual3DCollection.cs
- InvalidProgramException.cs
- TypeTypeConverter.cs
- ScriptControlManager.cs
- UniqueIdentifierService.cs
- WarningException.cs
- InstanceDataCollection.cs
- HtmlInputImage.cs
- TdsEnums.cs
- InputBuffer.cs