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
- WindowsListViewItemStartMenu.cs
- EntityWithChangeTrackerStrategy.cs
- WriteFileContext.cs
- EncoderParameters.cs
- CommonProperties.cs
- Root.cs
- TableLayoutSettings.cs
- DescendantOverDescendantQuery.cs
- IteratorFilter.cs
- CodeChecksumPragma.cs
- SpeechEvent.cs
- NativeMethods.cs
- SqlTriggerAttribute.cs
- WebPartsSection.cs
- MemoryPressure.cs
- SelectionHighlightInfo.cs
- InstancePersistenceCommandException.cs
- ErrorWrapper.cs
- HwndAppCommandInputProvider.cs
- OracleNumber.cs
- GeometryModel3D.cs
- FixedDocumentPaginator.cs
- JsonSerializer.cs
- SignatureResourcePool.cs
- Visual3D.cs
- WebPartDescriptionCollection.cs
- Trace.cs
- EditorZoneBase.cs
- Site.cs
- OutOfProcStateClientManager.cs
- TraceContextRecord.cs
- LineInfo.cs
- RightsManagementInformation.cs
- Vector3DKeyFrameCollection.cs
- DetailsViewUpdatedEventArgs.cs
- WindowsAuthenticationEventArgs.cs
- ObjectKeyFrameCollection.cs
- XamlSerializationHelper.cs
- Cursor.cs
- PassportIdentity.cs
- SignalGate.cs
- SecUtil.cs
- Int32Converter.cs
- PenContexts.cs
- IsolatedStorageException.cs
- DefaultValueAttribute.cs
- SiteOfOriginPart.cs
- CodeVariableDeclarationStatement.cs
- CheckBoxList.cs
- CheckBoxList.cs
- PreviewControlDesigner.cs
- ProcessHostConfigUtils.cs
- ByteAnimationUsingKeyFrames.cs
- ProcessExitedException.cs
- ProcessHostServerConfig.cs
- MissingFieldException.cs
- FirstMatchCodeGroup.cs
- DataGridHelper.cs
- SqlNodeAnnotation.cs
- Maps.cs
- BinaryConverter.cs
- GlyphInfoList.cs
- ExtendedProtectionPolicyTypeConverter.cs
- SessionStateModule.cs
- ListBoxItem.cs
- InvokerUtil.cs
- CallSiteHelpers.cs
- Graph.cs
- SqlTriggerContext.cs
- OdbcReferenceCollection.cs
- WebPartRestoreVerb.cs
- PersonalizableAttribute.cs
- XmlMembersMapping.cs
- DataGridViewRowPostPaintEventArgs.cs
- UserMapPath.cs
- QuaternionConverter.cs
- EventManager.cs
- CompilationUtil.cs
- CopyNamespacesAction.cs
- DataPointer.cs
- SQLMoney.cs
- AppDomainCompilerProxy.cs
- PeerNameRecordCollection.cs
- TextEndOfSegment.cs
- VisualBasicImportReference.cs
- SocketElement.cs
- CodeRemoveEventStatement.cs
- PlaceHolder.cs
- FileSystemEventArgs.cs
- QuadraticBezierSegment.cs
- TrackingDataItem.cs
- ColumnTypeConverter.cs
- WindowsStartMenu.cs
- DCSafeHandle.cs
- List.cs
- PropertyGridEditorPart.cs
- WebUtil.cs
- Permission.cs
- ObjectListDesigner.cs
- GlobalAclOperationRequirement.cs