当前位置: 首页>>代码示例>>C#>>正文


C# UIElement.InputHitTest方法代码示例

本文整理汇总了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;
        }
开发者ID:flying19880517,项目名称:MaterialDesignInXamlToolkit,代码行数:59,代码来源:TreeHelper.cs

示例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;
        }
开发者ID:anaimi,项目名称:farawla,代码行数:9,代码来源:DragDropTabManager.cs

示例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;
    }
开发者ID:wangws556,项目名称:duoduo-chat,代码行数:43,代码来源:DragDropHelper.cs

示例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;
    }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:33,代码来源:ColumnReorderingDragSourceManager.cs

示例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);
 }
开发者ID:rwinzhang,项目名称:MarketingMikroskil,代码行数:5,代码来源:MainWindow.xaml.cs

示例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;
 }
开发者ID:Vanlalhriata,项目名称:Vans-Memo-thingy,代码行数:29,代码来源:MainWindow.xaml.cs

示例7: HitTest

		static DependencyObject HitTest(UIElement root, Point position)
		{
			return root.InputHitTest(position) as DependencyObject;
		}
开发者ID:zhuangfangwang,项目名称:ise,代码行数:4,代码来源:MultitouchLogic.cs

示例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);
        }
开发者ID:Kazhunter,项目名称:Kinect,代码行数:13,代码来源:MainWindow.xaml.cs

示例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;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:24,代码来源:GraphView.cs


注:本文中的System.Windows.UIElement.InputHitTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。