using FastReport.Web.Application.Localizations;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using System.Collections.Generic;

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

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

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

        void OnWysiwygClick(MouseEventArgs e)
        {
            ChangeBoolValue("Wysiwyg");
        }

        void OnPageBreaksClick(MouseEventArgs e)
        {
            ChangeBoolValue("PageBreaks");
        }

      
        void OnPicturesChange(ChangeEventArgs e)
        {
            if ((e.Value as string) == "None")
            {
                ExportParameters.Remove("ImageFormat");
                ExportParameters["Pictures"] = "false";
            }
            else 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) == "Metafile")
            {
                ExportParameters["ImageFormat"] = "Metafile";
                ExportParameters["Pictures"] = "true";
            }
        }

        void OnRichObjectChange(ChangeEventArgs e)
        {
            if ((e.Value as string) == "Picture")
            {
                ExportParameters["EmbedRichObject"] = "false";
            }
            else if ((e.Value as string) == "EmbeddedRTF")
            {
                ExportParameters["EmbedRichObject"] = "true";
            }
        }
    }
}
