using System;
using System.Windows.Forms;

namespace Elfisa.UI.Theming
{
    public sealed class ThemeService
    {
        private readonly ThemeRenderer _renderer = new ThemeRenderer();

        public void Initialize(Form rootForm)
        {
            ThemeManager.ThemeChanged += (_, __) => Apply(rootForm);
            Apply(rootForm);
        }

        public void Apply(Control root)
        {
            if (root == null)
            {
                return;
            }

            _renderer.Apply(root, ThemeManager.Colors);
        }

        public void SetVariant(ThemeVariant variant, Form rootForm)
        {
            ThemeManager.CurrentVariant = variant;
            Apply(rootForm);
        }
    }
}
