// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Collections.Generic; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Common.Forms.Helpers { /// /// Helper class for displaying . /// public static class FailureMechanismSectionPresentationHelper { /// /// Creates presentation objects for the provided , /// taking into account the start and the end of the sections in relation to the beginning of /// the reference line. /// /// The type of the presentation objects. /// The failure mechanism sections to create presentation /// objects for. /// /// for creating the presentation objects of type , in which: /// /// T1 represents the failure mechanism section at stake; /// T2 represents the start of the section in relation to the beginning of the reference line; /// T3 represents the end of the section in relation to the beginning of the reference line. /// /// /// The created presentation objects. /// Thrown when or /// is null. public static T[] CreatePresentableFailureMechanismSections(IEnumerable failureMechanismSections, Func createPresentableFailureMechanismSectionFunc) { if (failureMechanismSections == null) { throw new ArgumentNullException(nameof(failureMechanismSections)); } if (createPresentableFailureMechanismSectionFunc == null) { throw new ArgumentNullException(nameof(createPresentableFailureMechanismSectionFunc)); } double start = 0; var presentableFailureMechanismSections = new List(); foreach (FailureMechanismSection failureMechanismSection in failureMechanismSections) { double end = start + failureMechanismSection.Length; presentableFailureMechanismSections.Add(createPresentableFailureMechanismSectionFunc(failureMechanismSection, start, end)); start = end; } return presentableFailureMechanismSections.ToArray(); } } }