steam-deck-tools/SteamController/ProfilesSettings/Helpers/ProfilesStringConverter.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2022-12-04 20:32:23 +01:00
using System.ComponentModel;
using System.Globalization;
namespace SteamController.ProfilesSettings.Helpers
{
internal class ProfileStringConverter : TypeConverter
2022-12-04 20:32:23 +01: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)
{
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)
{
return Profiles.Find((profile) => profile.Name == value?.ToString()) is not null;
2022-12-04 20:32:23 +01:00
}
}
}