public static IMouseDataSource BindLocalDragger(
     this IMouseDataSource source, ILocalDragger <Point> dragger)
 {
     source.MouseMoved += dragger.NewPoint;
     dragger.NewPoint(MouseMessageType.Down, source.InitialPoint);
     return(source);
 }
Beispiel #2
0
 public InitialDeltaSource(IMouseDataSource source, double xTol, double yTol)
 {
     this.xTol          = xTol;
     this.yTol          = yTol;
     this.source        = source;
     source.MouseMoved += OnMouseMoved;
 }
Beispiel #3
0
        public static IMouseDataSource DragTarget(this IMouseDataSource src, double opacity = 1)
        {
            IDragUIWindow?window = null;

            Point HandleMouseMove(LocalDragEventArgs ea)
            {
                if (window == null)
                {
                    if (ea.MessageType != MouseMessageType.Down)
                    {
                        return(ea.TransformedPoint);
                    }
                    window = src.Root.ConstructDragWindow(ea.Target, opacity);
                    window.Show();
                }

                window.MouseMoved(ea);
                if (ea.MessageType == MouseMessageType.Up)
                {
                    window = null;
                }

                return(ea.TransformedPoint);
            }

            return(LambdaMouseMonitor.FromFull(src, HandleMouseMove));
        }
Beispiel #4
0
 private LambdaMouseMonitor(IMouseDataSource other, Func <Point, Point> lambda)
 {
     this.other        = other;
     other.MouseMoved += (s, e) =>
     {
         e.TransformedPoint = lambda(e.TransformedPoint);
         MouseMoved?.Invoke(s, e);
     };
 }
 public static IMouseDataSource DragTarget(this IMouseDataSource src, double opacity = 1)
 {
     if (src.Target is not FrameworkElement target)
     {
         return(src);
     }
     src.BindLocalDragger(
         LocalDragger.MinimumDrag(new DragUiWindow(target, opacity)));
     return(src);
 }
 public static IMouseDataSource Drag(this IMouseDataSource mon, Func <IDataObject> dataToDrag, DragDropEffects allowedEffects,
                                     Action <DragDropEffects>?onDragDone = null)
 {
     mon.BindLocalDragger(
         LocalDragger.MinimumDrag(
             LocalDragger.MaxMoves(1, LocalDragger.Action((_, __) =>
     {
         var ret = new DragHandler(mon).InitiateDrag(dataToDrag(), allowedEffects);
         onDragDone?.Invoke(ret);
     }))));
     return(mon);
 }
Beispiel #7
0
        public static void Drag(this IMouseDataSource mon, Func <IDataObject> dataToDrag, DragDropEffects allowedEffects,
                                Action <DragDropEffects>?onDragDone = null)
        {
            var once = false;

            mon.MouseMoved += (s, e) =>
            {
                if (e.MessageType != MouseMessageType.Down)
                {
                    return;
                }
                if (once)
                {
                    return;
                }
                once = true;
                var ret = mon.Root.InitiateDrag(dataToDrag(), allowedEffects, e);
                onDragDone?.Invoke(ret);
            };
        }
Beispiel #8
0
 public DragHandler(IMouseDataSource source)
 {
     this.source = source;
 }
Beispiel #9
0
 public static IMouseDataSource Bind(this IMouseDataSource mon, Action <double, double> boundAction)
 {
     mon.MouseMoved += (s, e) => boundAction(e.TransformedPoint.X, e.TransformedPoint.Y);
     return(mon);
 }
Beispiel #10
0
 Transform(this IMouseDataSource mon, Func <double, double, (double X, double Y)> func) =>
Beispiel #11
0
 public static IMouseDataSource AsDeltas(this IMouseDataSource mon) =>
 LambdaMouseMonitor.FromFull(mon, CreateDeltaFilter());
Beispiel #12
0
 public static void Drag(this IMouseDataSource mon, IDataObject dataToDrag, DragDropEffects allowedEffects,
                         Action <DragDropEffects>?onDragDone = null) => Drag(mon, () => dataToDrag, allowedEffects, onDragDone);
Beispiel #13
0
 public static LambdaMouseMonitor FromFull(IMouseDataSource other, Func <LocalDragEventArgs, Point> lambda) =>
 new LambdaMouseMonitor(other, lambda);
Beispiel #14
0
 public static LambdaMouseMonitor FromPoint(IMouseDataSource other, Func <Point, Point> lambda) =>
 new LambdaMouseMonitor(other, lambda);
 public static IMouseDataSource BindLocalDragger(
     this IMouseDataSource source, Func <IMouseDataSource, ILocalDragger <Point> > dragger) =>
 BindLocalDragger(source, dragger(source));
Beispiel #16
0
 public DragHandler(IMouseDataSource source, LocalDragEventArgs mouseDownArgs)
 {
     this.source        = source;
     this.mouseDownArgs = mouseDownArgs;
 }