using Inspectron.Settings; using System.ComponentModel; using System.Globalization; using VisionBuilder.UI.Common.Utils; namespace VisionBuilder.UI.Common; public class UIConfiguration: ISettings { /// /// Max errors to be displayed in the UI. /// public int MaxErrorCount { get; set; } = 100; public string AdminPassword { get; set; } = ""; public List ErrorShortNames { get; set; } = new List(); public void RegisterSettings(InspectronSettings settings) { settings.RegisterSimple(this, () => this.MaxErrorCount, "Errors", "Max errors count", "UI"); settings.RegisterSimple(this, () => this.AdminPassword, "System", "Password", "UI"); settings.RegisterSimple(this, () => this.ErrorShortNames, "Errors", "Error short names", "UI"); } } public class ErrorShortName { public string FullName { get; set; } public string ShortName { get; set; } public override string ToString() { return $"{FullName} -> {ShortName}"; } } public class ErrorShortNameConverter : GeneralListTypeConverter { protected override ErrorShortName ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, string stringValue) { if (string.IsNullOrEmpty(stringValue)) return null; var parts = stringValue.Split(','); if (parts.Length == 2) { return new ErrorShortName { FullName = parts[0].Trim(), ShortName = parts[1].Trim() }; } return null; } protected override string ConvertToString(ITypeDescriptorContext context, CultureInfo culture, ErrorShortName errorShortName) { if (errorShortName == null) return null; return $"{errorShortName.FullName},{errorShortName.ShortName}"; } }