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
- CustomAttribute.cs
- EntityTypeEmitter.cs
- CompModHelpers.cs
- DbConnectionHelper.cs
- SafeReversePInvokeHandle.cs
- DbLambda.cs
- XmlDocumentType.cs
- InspectionWorker.cs
- EventMappingSettingsCollection.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- InstancePersistenceException.cs
- ObjectViewFactory.cs
- EFTableProvider.cs
- DateRangeEvent.cs
- SQLBinary.cs
- XmlSchemaAttributeGroup.cs
- DBParameter.cs
- DataAdapter.cs
- XPathAncestorIterator.cs
- GroupBoxDesigner.cs
- Encoder.cs
- StringPropertyBuilder.cs
- IMembershipProvider.cs
- TransactionFilter.cs
- MouseOverProperty.cs
- SingleTagSectionHandler.cs
- FormView.cs
- ValidationHelper.cs
- IsolatedStorageException.cs
- SqlTrackingQuery.cs
- UnauthorizedAccessException.cs
- ExtensionSimplifierMarkupObject.cs
- SqlDataSourceCache.cs
- WebPartHeaderCloseVerb.cs
- RuleRefElement.cs
- TriggerAction.cs
- HandlerBase.cs
- MsmqInputMessage.cs
- _SslStream.cs
- objectquery_tresulttype.cs
- RoleManagerSection.cs
- HuffCodec.cs
- linebase.cs
- PlaceHolder.cs
- PreviewPageInfo.cs
- ConfigurationStrings.cs
- TablePatternIdentifiers.cs
- XmlObjectSerializerReadContext.cs
- FormsAuthenticationCredentials.cs
- TextRange.cs
- DocumentXPathNavigator.cs
- ComponentManagerBroker.cs
- WebPartZoneCollection.cs
- SecondaryIndexList.cs
- GeometryModel3D.cs
- CodeGotoStatement.cs
- ByteRangeDownloader.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- PropertyCollection.cs
- EncodingInfo.cs
- Token.cs
- DataKey.cs
- ContentValidator.cs
- SRGSCompiler.cs
- ProjectionCamera.cs
- _AcceptOverlappedAsyncResult.cs
- XmlRawWriterWrapper.cs
- ScriptingWebServicesSectionGroup.cs
- ResumeStoryboard.cs
- GenerateScriptTypeAttribute.cs
- ServiceParser.cs
- EventProviderWriter.cs
- ChtmlImageAdapter.cs
- BinaryCommonClasses.cs
- CacheMode.cs
- TextBox.cs
- PrintControllerWithStatusDialog.cs
- DataGridItemEventArgs.cs
- TextServicesCompartmentEventSink.cs
- ContentFileHelper.cs
- CompoundFileIOPermission.cs
- BuildProvider.cs
- RecognizerBase.cs
- EmptyReadOnlyDictionaryInternal.cs
- SettingsAttributes.cs
- SingleResultAttribute.cs
- WorkflowWebHostingModule.cs
- TemplateControlCodeDomTreeGenerator.cs
- NavigationPropertyEmitter.cs
- RotationValidation.cs
- VisualStyleRenderer.cs
- WaitForChangedResult.cs
- DateTimeFormatInfo.cs
- Stylus.cs
- ZipPackagePart.cs
- _AcceptOverlappedAsyncResult.cs
- Transaction.cs
- GridItemPatternIdentifiers.cs
- ChangeNode.cs
- SystemDiagnosticsSection.cs