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 HOZProject
{
    public partial class FormShowImage : Form
    {
        #region 属性
        /// <summary>
        /// 显示的图像
        /// </summary>
        private Image showImg;
        public Image ShowImg { get => showImg; set => showImg = value; }
        /// <summary>
        /// 电压
        /// </summary>
        private string kv;
        public string Kv { get => kv; set => kv = value; }
        /// <summary>
        /// 放大倍数
        /// </summary>
        private string mag;
        public string Mag { get => mag; set => mag = value; }
        /// <summary>
        /// 属性信息(工作距离、消像散、亮度、对比度)
        /// </summary>
        private string content;
        public string Content { get => content; set => content = value; }

        /// <summary>
        /// Auto后显示的图像
        /// </summary>
        private Image showAutoImg;
        public Image ShowAutoImg { get => showAutoImg; set => showAutoImg = value; }
        /// <summary>
        /// Auto后电压
        /// </summary>
        private string autoKv;
        public string AutoKv { get => autoKv; set => autoKv = value; }
        /// <summary>
        /// Auto后放大倍数
        /// </summary>
        private string autoMag;
        public string AutoMag { get => autoMag; set => autoMag = value; }
        /// <summary>
        /// Auto后属性信息(工作距离、消像散、亮度、对比度)
        /// </summary>
        private string autoContent;
        public string AutoContent { get => autoContent; set => autoContent = value; }
        #endregion


        public FormShowImage()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;
        }

        #region 拖动窗体
        private Point mouseOff;//鼠标移动位置变量
        private bool leftFlag;//标签是否为左键
        private void FormShowImage_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mouseOff = new Point(-e.X, -e.Y); //得到变量的值
                leftFlag = true;                  //点击左键按下时标注为true;
            }
        }
        private void FormShowImage_MouseMove(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                Point mouseSet = Control.MousePosition;
                mouseSet.Offset(mouseOff.X, mouseOff.Y);  //设置移动后的位置
                Location = mouseSet;
            }
        }
        private void FormShowImage_MouseUp(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                leftFlag = false;//释放鼠标后标注为false;
            }
        }
        #endregion

        private void picexit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #region 设置当前图像参数
        public void SetParaInfo()
        {
            lblMag.Text = Mag;
            lblContent.Text = Content;
            
            lblAutoMag.Text = "";
            lblAutoContent.Text = "";
        }

        public void SetAutoParaInfo()
        {
            lblAutoMag.Text = AutoMag;
            lblAutoContent.Text = AutoContent;
        } 
        #endregion
    }
}
