Example #1
0
 private void rtb_MouseMove(object sender, MouseEventArgs e)
 {
     lastRTBMouseMove = e;
     if (btnHighlight.IsChecked.Value)
     {
         foreach (Rect r in m_selectionRect)
         {
             if (r.Contains(e.GetSafePosition(highlightCanvas)))
             {
                 if (highlightRect == null)
                 {
                     highlightRect = CreateHighlightRectangle(r);
                 }
                 else
                 {
                     highlightRect.Visibility = System.Windows.Visibility.Visible;
                     highlightRect.Width      = r.Width;
                     highlightRect.Height     = r.Height;
                     Canvas.SetLeft(highlightRect, r.Left);
                     Canvas.SetTop(highlightRect, r.Top);
                 }
             }
         }
     }
 }
Example #2
0
        public static bool HitTest(MouseEventArgs e, bool applyZoom, FrameworkElement element)
        {
            Rect?rect = element.GetBoundsRelativeTo(Application.Current.RootVisual);

            if (!rect.HasValue)
            {
                return(false);
            }

            Rect  box = rect.Value;
            Point pt  = e.GetSafePosition(null);

            if (applyZoom)
            {
                pt = MapToZoomValue(pt);
            }
            // Determine if the mouse lies within the element bounds
            return(pt.X > box.Left && pt.X < box.Right &&
                   pt.Y > box.Top && pt.Y < box.Bottom);
        }
Example #3
0
 public static bool HitTest(MouseEventArgs e, FrameworkElement element)
 {
     //HtmlPage.Document.SetProperty("Title", e.GetSafePosition(null).X);
     return(element.GetBoundsRelativeTo(Application.Current.RootVisual).HasValue &&
            IsPointWithinBounds(e.GetSafePosition(null), element.GetBoundsRelativeTo(Application.Current.RootVisual).Value));
 }