using FastReport.Web.Application.Localizations;

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace FastReport.Web.Blazor.Components.Internal.ExportSettings
{
    public partial class SvgExportSettings : ExportSettingsBase
    {
        SvgExportSettingsLocalization localization;

        protected override void LocalizeForm()
        {
            var res = WebReport.Res;
            localization = new SvgExportSettingsLocalization(res);
        }

        protected override void OnInitialized()
        {
            base.OnInitialized();
            ExportParameters["ImageFormat"] = "Jpeg";
            ExportParameters["Pictures"] = "true";
            ExportParameters["EmbedPictures"] = "true";
        }

        void OnEmbedPicturesClick(MouseEventArgs e)
        {
            ChangeBoolValue("EmbedPictures");
        }

        void OnHasMultipleFilesClick(MouseEventArgs e)
        {
            ChangeBoolValue("HasMultipleFiles");
        }

        void OnImageFormatChange(ChangeEventArgs e)
        {
            if ((e.Value as string) == "Png")
            {
                ExportParameters["ImageFormat"] = "Png";
                ExportParameters["Pictures"] = "true";
            }
            else if ((e.Value as string) == "Jpeg")
            {
                ExportParameters["ImageFormat"] = "Jpeg";
                ExportParameters["Pictures"] = "true";
            }
            else if ((e.Value as string) == "None")
            {
                ExportParameters.Remove("ImageFormat");
                ExportParameters["Pictures"] = "false";
            }
        }
    }
}
