using System.Linq;
using PCUT.Extensions;
using Windows.Foundation;

namespace PCUT.DeepNestApi
{
    public class PolylineElement : DraftElement
    {
        public Point[] Points;

        public override double Length
        {
            get
            {
                double len = 0;
                for (int i = 1; i < Points.Length; i++)
                {
                    len += Points[i - 1].DistTo(Points[i]);
                }
                return len;
            }
        }

        public override Point[] GetPoints()
        {
            return Points;
        }

        public override void Reverse()
        {
            Points = Points.Reverse().ToArray();
            Start = Points[0];
            End = Points[Points.Length - 1];
        }

        internal override void Mult(double mult)
        {
            for (int i = 0; i < Points.Length; i++)
            {
                Points[i] = Points[i].Mult(mult);
            }
            Start = Points[0];
            End = Points[Points.Length - 1];
        }
    }
}
