using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Camera
{
    public partial class Form1 : Form
    {
        private Asa.Camera.VisionLib lib;
        private string[] imagePath;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string path = @"C:\Neotel\DLL\Camera\Camera.json";
            lib = new Asa.Camera.VisionLib(path);
            //lib.SaveImage(@"C:\Users\asa\Downloads", "qq", System.Drawing.Imaging.ImageFormat.Bmp);


            //imagePath = System.IO.Directory.GetFiles(@"C:\Users\asa\Downloads\图像比较", "*.png");
            //for (int i = 0; i < imagePath.Length; i++)
            //    listBox1.Items.Add(System.IO.Path.GetFileName(imagePath[i]));
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            lib.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Bitmap bmp1 = new Bitmap(imagePath[listBox1.SelectedIndex]);
            //bool rtn1 = lib.FeatureSingleCompare(bmp1, "monitor", "C计划", out Dictionary<string, bool> exist);
            //KeyValuePair<string, bool> pair = exist.ElementAt(0);
            //label1.Text = pair.Value.ToString();

            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(aaa));
            thread.Start();
        }

        private void aaa()
        {
            int i= 0;
            while (i < 200)
            {
                using Bitmap bmp1 = new Bitmap(imagePath[0]);
                bool rtn1 = lib.FeatureSingleCompare(bmp1, "monitor", "C计划", out Dictionary<string, bool> exist);
                KeyValuePair<string, bool> pair = exist.ElementAt(0);
                Console.WriteLine(i.ToString() + "  " + pair.Value.ToString());
                System.Threading.Thread.Sleep(100);
                i++;
            }
        }
    }
}