private void mouseMoveHandler(object sender, MouseEventArgs e) { var startCtrl = sender as Control; var curCtrl = Utils.ApplyRecursiveControlFunc(this, FindControlWithMouse) as Control; TileWindow wnd = null; if (inputWnd.WindowIs(curCtrl)) { wnd = inputWnd; } else if (spriteWnd.WindowIs(curCtrl)) { wnd = spriteWnd; } int x = 0, y = 0; if (_drag != null && _drag.IsEdge) { x = e.X; y = e.Y; } else if (wnd != null) { // When the mouse is held, e.X and e.Y are relative to startCtrl.Location Point toCur = new Point( curCtrl.Location.X - startCtrl.Location.X, curCtrl.Location.Y - startCtrl.Location.Y ); x = e.X - toCur.X; y = e.Y - toCur.Y; } bool changed; if (_drag == null) { if (wnd == spriteWnd) { changed = spriteWnd.HighlightEdgeAt(x, y); } else { changed = spriteWnd.ClearMousedEdge(); } } else { Selection sel = _drag.Update(wnd, x, y); if (Transfer.Dest == null) { changed = sel != null; } else { changed = !Transfer.Dest.Equals(sel); } Transfer.Dest = sel; } if (wnd != null && changed) { wnd.Draw(); } }