Пример #1
0
        /// <summary>
        /// Ищет точки по заданному lambda-выражению
        /// </summary>
        /// <param name="func">Lambda-выражение</param>
        /// <param name="maxCount">Максимальное число найденых элементов (-1 = все)</param>
        /// <param name="indexDefault">Если в коллекции по условию не будет найдено ни одного элемента, то вернется элемент с заданым индексом. Если ни чего не нужно вовращать, введите отрицательное значение</param>
        /// <returns>Найденные точки</returns>
        protected PointShape[] FindPoints(Func <PointShape, bool> func, int maxCount = -1, int indexDefault = 0)
        {
            PointsCollection foundPointsCollection = new PointsCollection();

            int counter = 0;

            foreach (PointShape p in AllPointsFigure().Where(func))
            {
                foundPointsCollection.AddPoint(p);
                counter++;
                if (maxCount > 0 && counter == maxCount)
                {
                    return(foundPointsCollection.AllPoints());
                }
            }

            if (foundPointsCollection.AllPoints().Length == 0 && indexDefault >= 0)
            {
                foundPointsCollection.AddPoint(AllPointsFigure()[indexDefault]);
            }

            return(foundPointsCollection.AllPoints());
        }
Пример #2
0
 /// <summary>
 /// Получает все координаты фигуры
 /// </summary>
 /// <returns>Массив точек</returns>
 public PointShape[] AllPointsFigure()
 {
     return(_pointsCollection.AllPoints());
 }