本文整理汇总了C#中System.Windows.UIElement.InputHitTest方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.InputHitTest方法的具体用法?C# UIElement.InputHitTest怎么用?C# UIElement.InputHitTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.InputHitTest方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVisibleWidth
public static double GetVisibleWidth(FrameworkElement element, UIElement parent)
{
if (element == null) throw new ArgumentNullException(nameof(element));
if (parent == null) throw new ArgumentNullException(nameof(parent));
var location = element.TransformToAncestor(parent).Transform(new Point(0, 0));
int width = (int) Math.Floor(element.ActualWidth);
var hitTest = parent.InputHitTest(new Point(location.X + width, location.Y));
if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
{
return width;
}
//BinarySearch here
int end = (int) Math.Floor(element.ActualWidth);
int start = 0;
while (start < end)
{
width = (end + start)/2;
hitTest = parent.InputHitTest(new Point(location.X + width, location.Y));
if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
{
//Speed tweak
hitTest = parent.InputHitTest(new Point(location.X + width + 1, location.Y));
if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
{
start = width;
}
else
{
return width;
}
}
else
{
end = width;
}
}
//for (int width = (int) Math.Floor(element.ActualWidth); width >= 0; width--)
//{
// var hitTest = parent.InputHitTest(new Point(location.X + width, location.Y));
//
// if (hitTest == null) continue;
//
// if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
// {
// return width;
// }
//}
return element.ActualWidth;
}
示例2: FindTabItem
private static TabItem FindTabItem(UIElement parent, Point pt)
{
var fe = parent.InputHitTest(pt) as FrameworkElement;
while (fe != null && fe.GetType() != typeof(ExtendedTabItem))
fe = VisualTreeHelper.GetParent(fe) as FrameworkElement;
return fe as TabItem;
}
示例3: GetDropTargetAtPoint
public static IDropTarget GetDropTargetAtPoint(
UIElement draggedElement,
UIElement dragContainer,
MouseEventArgs e,
out Nullable<Point> dropTargetPosition,
out IDropTarget lastFoundDropTarget )
{
dropTargetPosition = null;
lastFoundDropTarget = null;
if( dragContainer == null )
return null;
IDropTarget dropTarget = null;
Point pointToDragContainer = e.GetPosition( dragContainer );
IInputElement hitTest = dragContainer.InputHitTest( pointToDragContainer );
if( hitTest != null )
{
DependencyObject parent = hitTest as DependencyObject;
while( parent != null )
{
dropTarget = parent as IDropTarget;
if( dropTarget != null )
{
lastFoundDropTarget = dropTarget;
if( dropTarget.CanDropElement( draggedElement ) )
{
dropTargetPosition = pointToDragContainer;
break;
}
}
dropTarget = null;
parent = Xceed.Utils.Wpf.TreeHelper.GetParent( parent );
}
}
return dropTarget;
}
示例4: GetDropTargetAtPoint
private static IDropTarget GetDropTargetAtPoint( UIElement dragContainer, UIElement draggedElement, Point point )
{
IInputElement hitTest = dragContainer.InputHitTest( point );
if( hitTest == null )
return null;
DependencyObject parent = hitTest as DependencyObject;
while( parent != null )
{
IDropTarget dropTarget = parent as IDropTarget;
ColumnManagerCell cell = dropTarget as ColumnManagerCell;
bool isCellHitTestible = true;
if( cell != null )
{
// The Cell could be partially or completely under the fixed region of the FixedCellPanel, so not "really" HitTestible
isCellHitTestible = ColumnReorderingDragSourceManager.TryHitTestCell( cell, point, dragContainer );
}
if( ( isCellHitTestible ) && ( dropTarget != null ) && ( dropTarget.CanDropElement( draggedElement ) ) )
{
return dropTarget;
}
dropTarget = null;
parent = Xceed.Utils.Wpf.TreeHelper.GetParent( parent );
}
return null;
}
示例5: GetHitTarget
private IInputElement GetHitTarget(Joint joint, UIElement target)
{
Point targetPoint = _layoutRoot.TranslatePoint(GetJointPoint(this.KinectDevice, joint, _layoutRoot.RenderSize, new Point()), target);
return target.InputHitTest(targetPoint);
}
示例6: GetItemFromPoint
private object GetItemFromPoint(UIElement source, Point point)
{
UIElement element = source.InputHitTest(point) as UIElement;
//if (element != null)
//{
// object data = DependencyProperty.UnsetValue;
// while (data == DependencyProperty.UnsetValue)
// {
// data = source.ItemContainerGenerator.ItemFromContainer(element);
// if (data == DependencyProperty.UnsetValue)
// element = VisualTreeHelper.GetParent(element) as UIElement;
// if (element == source)
// return null;
// }
// if (data != DependencyProperty.UnsetValue)
// return data;
//}
//return null;
if (element != null)
{
while (element != null)
{
element = VisualTreeHelper.GetParent(element) as UIElement;
if (element is ListBoxItem)
return ToDoListBox.ItemContainerGenerator.ItemFromContainer(element);
}
}
return null;
}
示例7: HitTest
static DependencyObject HitTest(UIElement root, Point position)
{
return root.InputHitTest(position) as DependencyObject;
}
示例8: GetHitTarget
//GET HIT TARGET!!
private IInputElement GetHitTarget(Joint joint, UIElement target)
{
//GetjoinPoint: get the coordinates of the join within the coordinate space ofthe LayoutRoot
Point targetPoint = GetJointPoint(this.Kinect, joint,LayoutRoot.RenderSize, new Point());
//Translates the joint point in the LayoutRoot space to the target space
targetPoint = LayoutRoot.TranslatePoint(targetPoint, target);
//If joint in the target returns the UI element in the target's visual tree
//No-null value = ok
return target.InputHitTest(targetPoint);
}
示例9: IsUIElementOccludedByAnotherGraphView
/// <summary>
/// Determines whether the given ui element at the given position is occluded by other graph view (for example occluded by scope view).
/// </summary>
/// <param name="uiElement">The UI element.</param>
/// <param name="clickPoint">The click point.</param>
/// <returns>
/// <c>true</c> if this ui element is occluded at the specified position; otherwise, <c>false</c>.
/// </returns>
private bool IsUIElementOccludedByAnotherGraphView(UIElement uiElement, Point clickPoint)
{
bool isOccluded = true;
var hitElement = uiElement.InputHitTest(clickPoint) as DependencyObject;
if (hitElement != null)
{
var graphView = hitElement.GetParent<TraceLab.UI.WPF.Views.GraphView>(this);
if (graphView == this)
{
isOccluded = false;
}
}
return isOccluded;
}