using System;
using System.Windows.Forms;
using FastReport.Export;
using FastReport.Export.Html;
using FastReport.Utils;

namespace FastReport.Forms
{
    /// <summary>
    /// Form for <see cref="HTMLExport"/>.
    /// For internal use only.
    /// </summary>
    public partial class HTMLExportForm : BaseExportForm
    {
        /// <inheritdoc/>
        public override void Init(ExportBase export)
        {
            base.Init(export);
            HTMLExport htmlExport = Export as HTMLExport;
            cbWysiwyg.Checked = htmlExport.Wysiwyg;
            cbPictures.Checked = htmlExport.Pictures;
            cbSinglePage.Checked = htmlExport.SinglePage;
            cbSubFolder.Checked = htmlExport.SubFolder;
            cbNavigator.Checked = htmlExport.Navigator;
            cbLayers.Checked = htmlExport.Layers;
            cbEmbPic.Checked = htmlExport.EmbedPictures;
            cbNotRotateLandscapePage.Checked = htmlExport.NotRotateLandscapePage;
            cbHighQualitySVG.Checked = htmlExport.HighQualitySVG;
        }
        
        /// <inheritdoc/>
        protected override void Done()
        {
            base.Done();
            HTMLExport htmlExport = Export as HTMLExport;
            htmlExport.Layers = cbLayers.Checked;
            htmlExport.Wysiwyg = cbWysiwyg.Checked;
            htmlExport.Pictures = cbPictures.Checked;
            htmlExport.SinglePage = cbSinglePage.Checked;
            htmlExport.SubFolder = cbSubFolder.Checked;
            htmlExport.Navigator = cbNavigator.Checked;
            htmlExport.EmbedPictures = cbEmbPic.Checked;
            htmlExport.NotRotateLandscapePage = cbNotRotateLandscapePage.Checked;
            htmlExport.HighQualitySVG = cbHighQualitySVG.Checked;
        }
        
        /// <inheritdoc/>
        public override void Localize()
        {
            base.Localize();
            MyRes res = new MyRes("Export,Html");
            Text = res.Get("");
            cbLayers.Text = res.Get("Layers");
            cbSinglePage.Text = res.Get("SinglePage");
            cbSubFolder.Text = res.Get("SubFolder");
            cbNavigator.Text = res.Get("Navigator");
            cbEmbPic.Text = res.Get("EmbPic");
            cbHighQualitySVG.Text = res.Get("HighQualitySVG");
            cbNotRotateLandscapePage.Text = res.Get("NotRotateLandscapePage");
            res = new MyRes("Export,Misc");
            gbOptions.Text = res.Get("Options");
            cbWysiwyg.Text = res.Get("Wysiwyg");
            cbPictures.Text = res.Get("Pictures"); 
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="HTMLExportForm"/> class.
        /// </summary>
        public HTMLExportForm()
        {
            InitializeComponent();
        }

        private void cbPictures_CheckedChanged(object sender, EventArgs e)
        {
            if (cbPictures.Checked)
                cbEmbPic.Visible = true;
            else cbEmbPic.Visible = false;
        }
    }
}

