1

我正在尝试以胜利形式使用反应式框架。

IObservable<IEvent<MouseEventArgs>> mouseMoves = Observable.FromEvent<MouseEventArgs>(this, "MouseMove");
IObservable<IEvent<MouseEventArgs>> mouseDowns = Observable.FromEvent<MouseEventArgs>(this, "MouseDown");
IObservable<IEvent<MouseEventArgs>> mouseUps = Observable.FromEvent<MouseEventArgs>(this, "MouseUp");
var pointChanges = mouseMoves.Zip(mouseMoves.Skip(1), (prev, post) => new { Prev = prev, Post = post });
var mouseDrags = from d in mouseDowns
                 from p in pointChanges.TakeUntil(mouseUps)
                 select p;

我想过滤 mouseDrags,只需要在 MouseDowns 之后超过 1 秒的 MouseUps。如何?

4

1 回答 1

2
from d in mouseDowns.Timestamp()
from p in pointChanges
    .TakeUntil(mouseUps)
    .SkipUntil(Observable.Timer(d.Timestamp + TimeSpan.FromSeconds(1.0)))
select p;
于 2010-09-17T15:53:58.820 回答