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

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Start......");
            //Helper.FreightRulesHelper.GetData();

            //Test();
            Console.WriteLine("End......");
            Console.ReadLine();
        }

        public class FileModel
        { 
          public int Id { get; set; }

            public string FilePath { get; set; }
        }

        public static void Test()
        {
            //获取到pic下面的jpg图片
            List<FileModel> fileList = new List<FileModel>();
            string[] rs = System.IO.Directory.GetFiles(@"C:\Users\qiaoyajun\Desktop\ppt", "*.png");
            foreach (var item in rs)
            {
                var fileName = System.IO.Path.GetFileNameWithoutExtension(item);
                Int32.TryParse(fileName, out int FileNum);
                var fileModel = new FileModel()
                {
                    Id = FileNum,
                    FilePath = item
                };
                fileList.Add(fileModel);
            }
            var newFileList = fileList.OrderBy(qitem => qitem.Id).ToList();
            //最大宽度和高度
            int maL = 959, totalH = 18292;
 
            Bitmap map = new Bitmap(maL, totalH);//定义画布
            Graphics g = Graphics.FromImage(map);//定义画笔
            g.Clear(Color.White);//把画布更改为白色
            int y = 0;//y轴坐标
            for (int i = 0; i < newFileList.Count; i++)
            {
                Image image = Image.FromStream(new System.IO.MemoryStream(File.ReadAllBytes(newFileList[i].FilePath)));
                g.DrawImage(image, new Point(0, y));
                y = y + 538;//y的告诉 5是为了让画布有个缝隙
            }
            //把合并的图片进行保存为jpg格式
            map.Save(@"C:\Users\qiaoyajun\Desktop\HK\1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            for (int i = 0; i < rs.Length; i++)
            {
                //删除原先的2个jpg图片
                //File.Delete(rs[i]);
            }

        }
    }
}
