using System.Globalization;
using System.Windows.Forms;
using FastReport.Export;
using FastReport.Export.OoXML;
using FastReport.Utils;

namespace FastReport.Forms
{
    /// <summary>
    /// Form for <see cref="PowerPoint2007Export"/>.
    /// For internal use only.
    /// </summary>
    public partial class PowerPoint2007ExportForm : BaseExportForm
    {
        /// <inheritdoc/>
        public override void Init(ExportBase export)
        {
            base.Init(export);
            PowerPoint2007Export pptExport = Export as PowerPoint2007Export;
            comboBox1.SelectedIndex = (int)pptExport.ImageFormat;
            cbbLocalization.Enabled = pptExport.ExportLocale;
            cbLocalization.Checked = pptExport.ExportLocale;

            cbbLocalization.Items.Add(Res.Get("Export,Misc,UseDesigerLocale"));
            foreach (var lang in CultureInfo.GetCultures(CultureTypes.AllCultures))
                cbbLocalization.Items.Add(lang.DisplayName);

            if (pptExport.Locale != null)
                cbbLocalization.SelectedItem = pptExport.Locale.DisplayName;
            else
                cbbLocalization.SelectedIndex = 0;
        }
        
        /// <inheritdoc/>
        protected override void Done()
        {
            base.Done();
            PowerPoint2007Export pptExport = Export as PowerPoint2007Export;
            pptExport.ImageFormat = (PptImageFormat)comboBox1.SelectedIndex;
            pptExport.ExportLocale = cbLocalization.Checked;

            if (cbbLocalization.SelectedIndex == -1 || cbbLocalization.SelectedIndex == 0)
                pptExport.Locale = null;
            else
                pptExport.Locale = CultureInfo.GetCultures(CultureTypes.AllCultures)[cbbLocalization.SelectedIndex - 1];
        }

        private void CbLocalization_CheckedChanged(object sender, System.EventArgs e)
        {
            cbbLocalization.Enabled = cbLocalization.Checked;
        }

        /// <inheritdoc/>
        public override void Localize()
        {
            base.Localize();
            MyRes res = new MyRes("Export,Pptx");
            Text = res.Get("");
            res = new MyRes("Export,Misc");
            gbOptions.Text = res.Get("Options");
            cbLocalization.Text = res.Get("Localization");
            lblImageFormat.Text = res.Get("Pictures");
        }

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

