// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved. // // This file is part of Riskeer. // // Riskeer is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser 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 Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser 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.ComponentModel; using System.Drawing; using Core.Components.Chart.Data; using Core.Components.Chart.Styles; using OxyPlot; namespace Core.Components.OxyPlot.Converter { /// /// Helper methods related to instances. /// public static class ChartDataHelper { /// /// Converts to . /// /// The to convert. /// The converted . /// Thrown when /// is not a valid enum value of . /// Thrown when /// is not supported for the conversion. public static LineStyle Convert(ChartLineDashStyle dashStyle) { if (!Enum.IsDefined(typeof(ChartLineDashStyle), dashStyle)) { throw new InvalidEnumArgumentException(nameof(dashStyle), (int) dashStyle, typeof(ChartLineDashStyle)); } var lineStyle = LineStyle.Solid; switch (dashStyle) { case ChartLineDashStyle.Solid: break; case ChartLineDashStyle.Dash: lineStyle = LineStyle.Dash; break; case ChartLineDashStyle.Dot: lineStyle = LineStyle.Dot; break; case ChartLineDashStyle.DashDot: lineStyle = LineStyle.DashDot; break; case ChartLineDashStyle.DashDotDot: lineStyle = LineStyle.DashDotDot; break; default: throw new NotSupportedException(); } return lineStyle; } /// /// Converts to . /// /// The to convert. /// The converted . /// Thrown when /// is not a valid enum value of . /// Thrown when /// is not supported for the conversion. public static MarkerType Convert(ChartPointSymbol symbol) { if (!Enum.IsDefined(typeof(ChartPointSymbol), symbol)) { throw new InvalidEnumArgumentException(nameof(symbol), (int) symbol, typeof(ChartPointSymbol)); } MarkerType markerType; switch (symbol) { case ChartPointSymbol.Circle: markerType = MarkerType.Circle; break; case ChartPointSymbol.Square: markerType = MarkerType.Square; break; case ChartPointSymbol.Diamond: markerType = MarkerType.Diamond; break; case ChartPointSymbol.Triangle: markerType = MarkerType.Triangle; break; case ChartPointSymbol.Star: markerType = MarkerType.Star; break; case ChartPointSymbol.Cross: markerType = MarkerType.Cross; break; case ChartPointSymbol.Plus: markerType = MarkerType.Plus; break; default: throw new NotSupportedException(); } return markerType; } /// /// Converts to . /// /// The to convert. /// The converted . public static OxyColor Convert(Color color) { return OxyColor.FromArgb(color.A, color.R, color.G, color.B); } } }