c# - Check time after a mousebuttondown before the mousebuttonup -
i think must little problem, can't clear thought on that. idea?
i have borders on canvas (filled images) , want click border (i onmouseleftbuttondown) border gets red (so user knows sure object had clicked) , then, after 1 or 2 seconds, when mousebutton still pushed down, drag'n'drop should start.
at first had borders inside buttons, clickevent seems conflict dragevent. got rid of buttons , did inside borders directly, works also. how can start drag after mousebuttondown , stop when mousebuttonup happens before time runs out.
someone idea clean solution?
private void onmouseleftbuttondown(object sender, mousebuttoneventargs e) { _source = sender border; mouse.capture(_source); } private void onmouseleftbuttonup(object sender, mousebuttoneventargs e) { _source = null; mouse.capture(null); }
and in event onmousemove can modify border margins depends on mouse position after checking if _source type of border.
var position = e.getposition(canvas);
edit: time can add property stopwatch _watch, , inside onmouseleftbuttondown event handler can it:
_watch = stopwatch.startnew();
in onmouseleftbuttonup:
_watch.stop();
and in onmousemove before code:
while (_watch.elapsedmilliseconds < 2000 && _watch.isrunning) { thread.sleep(100); }
Comments
Post a Comment