Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- Propagator.cs
- HtmlListAdapter.cs
- MailWriter.cs
- CodeExporter.cs
- UTF8Encoding.cs
- XmlNode.cs
- DialogResultConverter.cs
- Image.cs
- StandardMenuStripVerb.cs
- UnaryOperationBinder.cs
- Keyboard.cs
- ProcessModelSection.cs
- DesignerTransactionCloseEvent.cs
- ClientClassGenerator.cs
- Avt.cs
- DbQueryCommandTree.cs
- DebugHandleTracker.cs
- ViewCellRelation.cs
- ControlValuePropertyAttribute.cs
- XmlSerializerFactory.cs
- CollectionType.cs
- RangeValidator.cs
- InlineUIContainer.cs
- WindowsRebar.cs
- SelectorAutomationPeer.cs
- ApplicationManager.cs
- GlyphRun.cs
- ButtonFlatAdapter.cs
- PeerChannelFactory.cs
- ComContractElementCollection.cs
- SafeArrayTypeMismatchException.cs
- RecordBuilder.cs
- SchemaSetCompiler.cs
- odbcmetadatafactory.cs
- XmlDataLoader.cs
- NumericUpDown.cs
- TranslateTransform3D.cs
- EntityEntry.cs
- MultiplexingFormatMapping.cs
- HwndSubclass.cs
- CustomDictionarySources.cs
- addressfiltermode.cs
- SamlAuthenticationClaimResource.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- ConfigurationPropertyCollection.cs
- CellTreeNodeVisitors.cs
- HashHelper.cs
- BindingFormattingDialog.cs
- BevelBitmapEffect.cs
- EmptyStringExpandableObjectConverter.cs
- DefaultValueTypeConverter.cs
- ByteAnimationBase.cs
- XmlDocumentFragment.cs
- RootProfilePropertySettingsCollection.cs
- __ConsoleStream.cs
- Calendar.cs
- ProgressPage.cs
- CounterNameConverter.cs
- TextTreeTextNode.cs
- XPathQilFactory.cs
- SrgsToken.cs
- ByteStorage.cs
- WindowsGrip.cs
- DesignTimeVisibleAttribute.cs
- StateBag.cs
- HMACMD5.cs
- XsdCachingReader.cs
- TemplatePropertyEntry.cs
- PropertyGridCommands.cs
- ServiceModelActivationSectionGroup.cs
- HttpModuleCollection.cs
- Rfc2898DeriveBytes.cs
- EmptyStringExpandableObjectConverter.cs
- HtmlInputText.cs
- TextSpanModifier.cs
- SubMenuStyleCollection.cs
- UnsafeNativeMethods.cs
- ServiceXNameTypeConverter.cs
- ClonableStack.cs
- XmlChildEnumerator.cs
- HttpValueCollection.cs
- Object.cs
- ModuleBuilder.cs
- MethodExpr.cs
- ComponentGuaranteesAttribute.cs
- ProvidersHelper.cs
- ServicePointManager.cs
- UnaryNode.cs
- Point.cs
- RectAnimationClockResource.cs
- SafePEFileHandle.cs
- WorkflowExecutor.cs
- XmlSchemaCollection.cs
- AutomationPeer.cs
- RegionData.cs
- TimerEventSubscription.cs
- FileUpload.cs
- SqlInternalConnection.cs
- _HeaderInfoTable.cs
- RootProjectionNode.cs