//Calculate Current MousePosition & relative Cell Value, Calculate Selection Rectangle public void ScorePictureBox_MouseMove(object sender, MouseEventArgs e) { //Give the Score focus, to allow mouse scroll Up/Down. ScorePanel.Focus(); try { CurrentMousePosition.X = MousePosition.X - this.Parent.Location.X - ScorePictureBox.Location.X - 73; CurrentMousePosition.Y = MousePosition.Y - this.Parent.Location.Y - ScorePictureBox.Location.Y - 98; CurrentCellXPosition = (CurrentMousePosition.X / CellWidth); CurrentCellYPosition = (CurrentMousePosition.Y / CellHeight); if (CurrentAction == "note" && SnapperTool == true && CurrentNoteLength != 0) { //If Snapper is on, Snap to nearest musically relevant position CurrentCellXPosition = (CurrentCellXPosition - CurrentCellXPosition % CurrentNoteLength); CurrentMousePosition.X = CurrentCellXPosition * CellWidth; } } catch { /*do nothing*/ } // Create the selection rectangle from my selection start and end points. if (CurrentAction == "select" && SelectStartPoint.Y != POINT_FLAG_VALUE) { SelectEndPoint = CurrentMousePosition; RectStartPoint = SelectStartPoint; RectEndPoint = SelectEndPoint; if (SelectStartPoint.X <= SelectEndPoint.X) { //Do not swap X's if (SelectStartPoint.Y <= SelectEndPoint.Y) { /*Leave them*/ } else {/*Swap Y's*/ RectStartPoint = new Point(RectStartPoint.X, SelectEndPoint.Y); RectEndPoint = new Point(RectEndPoint.X, SelectStartPoint.Y); } } else {//Swap X's RectStartPoint = new Point(SelectEndPoint.X, RectStartPoint.Y); RectEndPoint = new Point(SelectStartPoint.X, RectEndPoint.Y); if (SelectStartPoint.Y <= SelectEndPoint.Y) { /*Leave them*/ } else { /*Swap Y's*/ RectStartPoint = new Point(RectStartPoint.X, SelectEndPoint.Y); RectEndPoint = new Point(RectEndPoint.X, SelectStartPoint.Y); } } ScorePictureBox.Refresh(); } }