using System;
using FastReport.Dialog;
using static FastReport.Web.Constants;

namespace FastReport.Web
{
    public partial class Dialog
    {

        private void RadioButtonClick(RadioButtonControl rb, string data)
        {
            bool oldValue = rb.Checked;
            rb.Checked = data == "true";
            rb.FilterData();
            rb.OnClick(null);
            if (oldValue != rb.Checked)
                rb.OnCheckedChanged(EventArgs.Empty);
        }

        private string GetRadioButtonHtml(RadioButtonControl control)
        {
            string id = GetControlID(control);
            string html = $"<span style=\"{GetRadioButtonStyle(control)}\">" +
                $"<input style=\"vertical-align:middle;width:{Zoom(10)}px;border:none;padding:0;margin:0 5px 0 0;\"" +
                $" type=\"radio\" name=\"{control.Name}\" value=\"{control.Text}\"" +
                $" onclick=\"{GetEvent(ONCLICK, control, SILENT_RELOAD, $"document.getElementById('{id}').checked")}\"" +
                $" id=\"{id}\" {(control.Checked ? "checked" : "")} {(control.Enabled ? "" : "disabled")}/>" +
                $"<label style=\"{GetControlFont(control.Font)}\" for=\"{id}\">{control.Text}</label></span>";
            return html;
        }

        private string GetRadioButtonStyle(RadioButtonControl control)
        {
            return GetStandardStyle(control);
        }

    }
}
