private Cell GetCellFoLine(PointF firstPointF, PointF secondPointF) { var centerPointF = firstPointF.CenterBetweenThisAndAnotherPointF(secondPointF); var cells = matrixCells.Where(cell => centerPointF.IsBetweenTwoPointFs(new PointF(cell.leftBoarder, cell.lowerBoarder), new PointF(cell.rightBoarder, cell.upperBoarder))); var tmpcount = cells.Count(); var res = ((firstPointF.X == secondPointF.X || firstPointF.Y == secondPointF.Y) && cells.Count() > 1) ? cells.Where(cell => cell.lowerBoarder == centerPointF.Y || cell.leftBoarder == centerPointF.X).Single() : cells.Single(); return(res); }