-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hello, nice lib, can you also share an easy to use Generic Dropdown helper for ASP Core. I like your color and math parsers, often people type formulas on front end in text and I have to parse it in the backend so I am trying your lib.
Cascading/Related Drop Downs: Also, more often if you have two or three dropdown, where the second drop down depends on the first selection etc.. a flag/option to set that up would be nice. For e.g. country, state, city
Unique items: Another non trivial task with drop down, is when you want to make them unique, lets says they can only pick a combination items once, and not again like a seat reservations in different buses, if you pick the bus (DropDown 1) and pick a Seat (Drop Down 2) you cannot pick it again since its taken.
For color conversion, just wanted to share some ideas:
public static (double, double, double) HsvToHsl(double h, double s, double v)
{
s /= 100;
v /= 100;
double l = (2 - s) * v / 2;
if (l != 0)
{
if (l == 1) s = 0;
else if (l < 0.5) s = s * v / (l * 2);
else s = s * v / (2 - l * 2);
}
return (h, s * 100, l * 100);
}
//https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
public static string HslToHex((double, double, double) hsl) { return HslToHex(hsl.Item1, hsl.Item2, hsl.Item3); }
public static string HslToHex(double h, double s, double l)
{
l /= 100;
double a = s * Math.Min(l, 1 - l) / 100;
string ToHex(double n)
{
double k = (n + h / 30) % 12;
double colour = l - a * Math.Max(Math.Min(k - 3, Math.Min(9 - k, 1)), -1);
return ((int)Math.Round(255 * colour)).ToString("X2").PadLeft(2, '0');
}
return $"#{ToHex(0)}{ToHex(8)}{ToHex(4)}";
}
//http://ariya.blogspot.com/2008/07/converting-between-hsl-and-hsv.html
public static (double, double, double) HslToHsv((double, double, double) hsv) { return HslToHsv(hsv.Item1, hsv.Item2, hsv.Item3); }
public static (double, double, double) HslToHsv(double h, double s, double l)
{
l *= 2;
s *= l <= 1 ? l : 2 - l;
double v = (l + s) / 2;
s = (2 * s) / (l + s);
return (h, s, v);
}