You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.1 KiB

@using BlazorLottoPicker.Utilities;
<div>
<select class="form-control" @bind="_selectedColor" style="display:flex;justify-content:center;text-align:center">
@foreach (var color in _colorPallets)
{
<option value="@color">
@color
</option>
}
</select>
<Ball BallColor="@this.SelectedHexColor" Value="@_value"></Ball>
</div>
@code {
List<string> _colorPallets = Utils.ColorPallets;
string _selectedColor = Utils.ColorPallets[0];
int _selectedIndex = 0;
int _value = 0;
string SelectedHexColor
{
get
{
_selectedIndex = _colorPallets.IndexOf(_selectedColor);
_value = Pick(_selectedIndex);
return Utils.HexColorPallets[_selectedIndex];
}
}
int Pick(int index)
{
return Utils.GetNumber(index);
}
void Shuffle()
{
_selectedColor = Utils.ColorPallets[new Random().Next(_value, Utils.ColorPallets.Count)];
}
protected override void OnInitialized()
{
base.OnInitialized();
Shuffle();
StateHasChanged();
}
}