using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

using ClosedXML;
using ClosedXML.Utils;
using ClosedXML.Excel;
using ClosedXML.Excel.Drawings;

using ImageMagick;

using Common;

namespace BarcodeXlsx
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("BarcodeXlsx v0.1");

                DecodeArgumentParamaters param = new DecodeArgumentParamaters(args);

                if (param.enabledVerbose)
                {
                    Console.WriteLine("--source {0}", param.sourceFileName);
                }

                BarcodeXlsxImporter barcodeXlsx = new BarcodeXlsxImporter();
                barcodeXlsx.preChars = param.preChars;
                barcodeXlsx.postChars = param.postChars;
                barcodeXlsx.enabledVerbose = param.enabledVerbose;
                barcodeXlsx.enabledProgress = param.enabledProgress;
                barcodeXlsx.enabledLabel = param.enabledLabel;
                barcodeXlsx.enabledRemoveTag = param.enabledRemoveTag;
                barcodeXlsx.imageWidth = param.imageWidht;
                barcodeXlsx.imageHeight = param.imageHeight;

                if (param.destinationFileName == null)
                {
                    barcodeXlsx.Convert(param.sourceFileName);
                }
                else
                {
                    barcodeXlsx.Convert(param.sourceFileName, param.destinationFileName);
                }
            }
            catch (Exception exp)
            {
                Console.Error.WriteLine("{0}", exp.Message);
            }
        }
    }
}
