예제 #1
0
        private Interactive GetTarget(IInputElement root, Point local)
        {
            var target = root.InputHitTest(local)?.GetSelfAndVisualAncestors()?.OfType <Interactive>()?.FirstOrDefault();

            if (target != null && DragDrop.GetAllowDrop(target))
            {
                return(target);
            }
            return(null);
        }
예제 #2
0
        private bool MouseDown(IMouseDevice device, ulong timestamp, IInputElement root, Point p,
                               PointerPointProperties properties,
                               KeyModifiers inputModifiers, IInputElement?hitTest)
        {
            device = device ?? throw new ArgumentNullException(nameof(device));
            root   = root ?? throw new ArgumentNullException(nameof(root));

            var source = _pointer.Captured ?? root.InputHitTest(p);

            if (source != null)
            {
                _pointer.Capture(source);
                if (source != null)
                {
                    var settings        = AvaloniaLocator.Current.GetService <IPlatformSettings>();
                    var doubleClickTime = settings?.DoubleClickTime.TotalMilliseconds ?? 500;
                    var doubleClickSize = settings?.DoubleClickSize ?? new Size(4, 4);

                    if (!_lastClickRect.Contains(p) || timestamp - _lastClickTime > doubleClickTime)
                    {
                        _clickCount = 0;
                    }

                    ++_clickCount;
                    _lastClickTime = timestamp;
                    _lastClickRect = new Rect(p, new Size())
                                     .Inflate(new Thickness(doubleClickSize.Width / 2, doubleClickSize.Height / 2));
                    _lastMouseDownButton = properties.PointerUpdateKind.GetMouseButton();
                    var e = new PointerPressedEventArgs(source, _pointer, root, p, timestamp, properties, inputModifiers, _clickCount);
                    source.RaiseEvent(e);
                    return(e.Handled);
                }
            }

            return(false);
        }
예제 #3
0
 private IInputElement HitTest(IInputElement root, Point p)
 {
     return(Captured ?? root.InputHitTest(p));
 }
예제 #4
0
 private IInputElement HitTest(IInputElement root, Point p)
 {
     return Captured ?? root.InputHitTest(p);
 }
예제 #5
0
        private IInputElement HitTest(IInputElement root, Point p)
        {
            Contract.Requires <ArgumentNullException>(root != null);

            return(Captured ?? root.InputHitTest(p));
        }
예제 #6
0
        private IInputElement?HitTest(IInputElement root, Point p)
        {
            root = root ?? throw new ArgumentNullException(nameof(root));

            return(_pointer.Captured ?? root.InputHitTest(p));
        }