2022-12-04 20:32:23 +01:00
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace SteamController.ProfilesSettings.Helpers
|
|
|
|
|
{
|
2022-12-08 11:23:15 +01:00
|
|
|
internal class ProfileStringConverter : TypeConverter
|
2022-12-04 20:32:23 +01:00
|
|
|
{
|
2023-05-21 16:44:01 +02:00
|
|
|
public static List<Profiles.Profile> Profiles = new List<Profiles.Profile>();
|
2022-12-04 20:32:23 +01:00
|
|
|
|
|
|
|
|
private volatile StandardValuesCollection? collection;
|
|
|
|
|
|
|
|
|
|
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
|
|
|
|
|
{
|
2023-05-21 16:44:01 +02:00
|
|
|
return collection ??= new StandardValuesCollection(Profiles.
|
|
|
|
|
Where((profile) => profile.Visible).
|
|
|
|
|
Select((profile) => profile.Name).
|
|
|
|
|
ToArray());
|
2022-12-04 20:32:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsValid(ITypeDescriptorContext? context, object? value)
|
|
|
|
|
{
|
2023-05-21 16:44:01 +02:00
|
|
|
return Profiles.Find((profile) => profile.Name == value?.ToString()) is not null;
|
2022-12-04 20:32:23 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-08 11:23:15 +01:00
|
|
|
}
|