using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WheelApp
{
    public partial class MainForm : Form
    {
        private readonly Random random = new Random();
        private List<string> items = new List<string>();

        public MainForm()
        {
            InitializeComponent();
        }

        private void SpinButton_Click(object sender, EventArgs e)
        {
            string inputText = InputTextBox.Text;
            if (!string.IsNullOrEmpty(inputText))
            {
                items = new List<string>(inputText.Split(','));
                SpinWheel();
            }
            else
            {
                MessageBox.Show("Please enter a list of items separated by commas.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void SpinWheel()
        {
            if (items.Count > 0)
            {
                int randomIndex = random.Next(items.Count);
                string selectedItem = items[randomIndex];
                ResultLabel.Text = selectedItem;
            }
        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            SpinWheel();
        }
    }
}
