0
画面にいくつかの点を描き、マウスの左ボタンを押したままドラッグできるコードがあります。マウスイベントが発射を停止し、ドラッグされているポイントが動きを止めることを除いて、これはちょっとしたことです。キャプチャされた要素のマウスイベントは、ドラッグ中に発砲を停止します。
すべてのイベントが(何らかの不明な理由により)捕捉されなくなるため、ユーザーは何も起こることなくマウスの左ボタンを放すことができます。
奇妙なことは、ポイント上でマウスの位置を変えることができ、マウスの左ボタンを押さなくても再びドラッグを開始できることです。これは非常に貧弱なユーザーエクスペリエンスになります。
何が起こっていますか?
pinPoint.MouseLeftButtonDown += Point_MouseLeftButtonDown;
pinPoint.MouseLeftButtonUp += Point_MouseLeftButtonUp;
pinPoint.MouseMove += Point_MouseMove;
.
.
.
void Point_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
((UIElement)sender).CaptureMouse();
if (_isDragging == false)
{
_isDragging = true;
}
}
void Point_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
_isDragging = false;
((UIElement)sender).ReleaseMouseCapture();
}
void Point_MouseMove(object sender, MouseEventArgs e)
{
//where the point gets moved and some other logic
//possibly this logic takes too long?
}