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

namespace GcDevicePc
{
    public delegate void Fireport(int flag,ushort futime,ushort hvtime);  //点火委托
    public partial class FormUser : Form
    {
        public FormUser()
        {
          
            InitializeComponent();
           
        }

        private void FormUser_Load(object sender, EventArgs e)
        {
          //  userCtl1.Systemtype = CKVocAnalyzer.GlobalCKV.Systemtype;
         
        }

        private void FormUser_Activated(object sender, EventArgs e)  //激活
        {
            Console.WriteLine("激活");

        }

        private void FormUser_Deactivate(object sender, EventArgs e) //停用
        {
            // MessageBox.Show("停用");
            Console.WriteLine("停用");
        }
        //public bool isFire;
        //public double time;
        public event Fireport autofire;
        //点火操作
        private void buttonFID_Click(object sender, EventArgs e)
        {
            //if (isFire)
            {
                if (globaldata.m_dpbuffer.ShowList.showDet.fDetStatue != 2)
                    autofire(0, 10, 5);
                else
                    MessageBox.Show("点火操作禁止，FID已经点火成功");
            }
            //else
            //{
            //    MessageBox.Show("请"+ time + "分钟后在点火");
            //}
            //if (globaldata.m_dpbuffer.ShowList.showDet.fDetStatue != 2)
            //    autofire(0, 10, 5);
            //else
            //    MessageBox.Show("点火操作禁止，FID已经点火成功");

        }
        public CKVocAnalyzer.AutoAdjust auto;

        //自动校准
        private void buttonauto_Click(object sender, EventArgs e)  
        {
            //DialogResult dr = new CK_UI.LandIn("calibration", DateTime.Now.ToString("HHmm")).ShowDialog();

            //if (dr == DialogResult.OK)
            //{
            //    if (CK_UI.LandIn.Island)
                {
                //CKVocAnalyzer.CtrlUserAdjust auto = new CKVocAnalyzer.CtrlUserAdjust(CKVocAnalyzer.CtrlUserAdjust.AdjustType.AT_Yang);
                if (auto == null)
                {
                    auto = new CKVocAnalyzer.AutoAdjust();
                    auto.Isadmin = false;
                    auto.Show();
                }
                else if (auto.IsDisposed)
                {
                    auto = null;
                    auto = new CKVocAnalyzer.AutoAdjust();
                    auto.Isadmin = false;

                    auto.Show();
                }
                else
                {
                    //auto.Activate();
                    if (!auto.Visible)
                    {
                        auto.Isadmin = false;

                        auto.Show();
                        auto.IsinitShow();
                        //auto.ShowKB();
                    }
                }

                //if (!globaldata.usable)//表示上位机处于运行状态下不可进行自动校准
                //{
                    
                //}
                    
                    //Trace.WriteLine(string.Format("用户{0}，进入自动校准模式", "calibration"), "sys");
                }
            //else
            //    {
            //        MessageBox.Show("无权限操作！！！！");
            //    }
            //}

            //if (dr == DialogResult.No)
            //{
            //   // MessageBox.Show("无权限操作！！！！");
            //}


        }
      
    }
}
