using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FCM0000
{
    public static class FPUtil
    {
        public static void printsheet(FarPoint.Win.Spread.FpSpread fpSpread1, string headerTitle)
        {



            FarPoint.Win.Spread.PrintInfo printset = fpSpread1.Sheets[0].PrintInfo; // new FarPoint.Win.Spread.PrintInfo();
            printset.Header = headerTitle;
            printset.Footer = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            printset.Orientation = FarPoint.Win.Spread.PrintOrientation.Auto;
            //  printset.PdfWriteTo = FarPoint.Win.Spread.PdfWriteTo.File;
            //  printset.PdfWriteMode = FarPoint.Win.Spread.PdfWriteMode.Append;
            // printset.PrintToPdf = true;
            printset.Preview = true;
            printset.UseSmartPrint = true;
            printset.BestFitCols = false;
            printset.BestFitRows = false;
            printset.BestFitWithSpan = true;
            printset.Centering = FarPoint.Win.Spread.Centering.Horizontal;
            printset.EnhancePreview = false;
            //   printset.PdfFileName = "C:\\\results.pdf";
            fpSpread1.Sheets[0].PrintInfo = printset;
            fpSpread1.PrintSheet(0);
        }

        public static void ColsizeSave(FarPoint.Win.Spread.FpSpread dv, string fn)
        {
            arUtil.INIHelper ini = new arUtil.INIHelper(fn);
            foreach (FarPoint.Win.Spread.Column col in dv.ActiveSheet.Columns)
                ini.set_Data("colsize", "index_" + col.Index.ToString(), col.Width.ToString());
            ini.Flush();
        }
        public static void ColSizeLoad(ref FarPoint.Win.Spread.FpSpread dv, string fn)
        {
            if (System.IO.File.Exists(fn) == false) return;
            arUtil.INIHelper ini = new arUtil.INIHelper(fn);
            foreach (FarPoint.Win.Spread.Column col in dv.ActiveSheet.Columns)
            {
                var width = ini.get_Data("colsize", "index_" + col.Index.ToString(), "0");
                col.Width = float.Parse(width);
            }
        }
    }
}
