private void HandleMouseMove(object sender, MouseEventArgs mouseEventArgs) { var hit = HitTest(mouseEventArgs.Location); var hitField = hit.HasValue ? hit.Value.Item1 : null; // jesli nie ma zmian - konczymy if (_HighlightedField == null && hitField == null) { return; } if (_HighlightedField != null && hitField != null && _HighlightedField.Equals(hitField)) { return; } var highlighted = (hitField != null && CanBeHighlighted(hitField)) ? hitField : null; var selected = _SelectedField; using (var canvas = Graphics.FromImage(_MainPictureBox.Image)) { ClearMarks(canvas); SetMarks(canvas, highlighted, selected); } _MainPictureBox.Invalidate(); }
private void SetMarks(Graphics canvas, FieldCoords highlighted, FieldCoords selected) { _HighlightedField = highlighted; _SelectedField = selected; if (highlighted == null && selected == null) { return; } if (highlighted?.Equals(selected) == true) { DrawField(canvas, highlighted, State[highlighted], FieldDrawType.Highlighted | FieldDrawType.Selected); return; } if (highlighted != null) { DrawField(canvas, highlighted, State[highlighted], FieldDrawType.Highlighted); } if (selected != null) { DrawField(canvas, selected, State[selected], FieldDrawType.Selected); } }