recipe name filter
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using Inspectron.Settings;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using VisionBuilder.UI.Common.Utils;
|
||||
|
||||
namespace VisionBuilder.UI.Common;
|
||||
|
||||
@@ -11,11 +14,55 @@ public class UIConfiguration: ISettings
|
||||
|
||||
public string AdminPassword { get; set; } = "";
|
||||
|
||||
public List<ErrorShortName> ErrorShortNames { get; set; } = new List<ErrorShortName>();
|
||||
|
||||
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<ErrorShortName>
|
||||
{
|
||||
|
||||
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}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user