using GcDevicePc.Common;
using GcDevicePc.ConfigMethod;
using GcDevicePc.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GcDevicePc
{
    public partial class TestForm : Form
    {
        private Button MyButton;//创建Button
        public TestForm()
        {
            InitializeComponent();
            //bgWorker.DoWork += BgWorker_DoWork;
            //title.Show();

            //bgWorker.RunWorkerCompleted += BgWorker_RunWorkerCompleted;
            this.FormClosed += CloseDialog;
            MyButton = new Button();//实例化Button
            MyButton.Left = 30;//设置控件离form左边的距离
            MyButton.Top = 130;//设置控件离form上边的距离
            MyButton.Width = 200;//设置控件的宽度
            MyButton.Text = "弹出对话框";//按钮显示名称
            MyButton.Click += ShowMessage;//按钮单机事件
            this.Controls.Add(MyButton);//将控件加入到form中
        }
        //GCTitle title = new GCTitle();

        /// <summary>
        /// 弹出对话框
        /// </summary>
        /// <param name="sender">出发事件的对象</param>
        /// <param name="e">事件信息</param>
        private void ShowMessage(object sender, EventArgs e)
        {
            MessageBox.Show("这是最简单的弹出框", "弹出对话框");
        }
        /// <summary>
        /// 关闭提示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CloseDialog(object sender, EventArgs e)
        {
            //创建我的提示框
            LMessageBox dialog = new LMessageBox(this.Location,this.Size, true, "123456", "11111111111111111111", LMessageBox.MessageBoxPosition.MBP_BottomRight);
            //注意提示框的返回值，是DialogResult这个枚举
            if (dialog.ShowDialog() == DialogResult.No)
            {
                ((System.ComponentModel.CancelEventArgs)e).Cancel = true;
            }
        }



        BackgroundWorker bgWorker = new BackgroundWorker();
        PrompBox loadingCtl = new PrompBox(162, true);//定义加载控件
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {

            System.Threading.Thread.Sleep(3000);

        }

        private void BgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            loadingCtl.Hide();

        }
        Form1 form1;

        private void btnShow_Click(object sender, EventArgs e)
        {

            //loadingCtl.TipsInfo = "提示信息";
            ////显示加载动画
            //loadingCtl.ShowLoading(this);
            //Application.DoEvents();
            //bgWorker.RunWorkerAsync();

            //this.pictureMenu1.PMOptbtnstatus = 3;
            //(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 4;
            //kailiang

            //if (form1 == null)
            //{
            //    form1 = new Form1("asdasdasdsa");
            //    form1.Show();

            //}
            //else if(form1.IsDisposed)
            //{
            //    form1 = new Form1("asdasdasdsa");
            //    form1.Show();
            //}
            //else
            //{
            //    form1.Activate();
            //}

            //string savefilename = "C:\\Users\\24042\\Pictures\\新建文件夹\\test11.hw";
            //TWFile twfile = new TWFile(savefilename);
            //twfile.TW_Open();

            //twfile.TW_Close(0);


        }

        private void button2_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("asd");
            //this.pictureMenu1.PMOptbtnstatus = 4;
            //(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 3;
            //tinfliang
            
            //LMessageBox box = new LMessageBox();
            //box.Show(100, 100, this.Location, true, "1230", "3214", LMessageBox.MessageBoxType.MBT_ButtonOK);
        }

        private void Button3_Click(object sender, EventArgs e)
        {

        }

        private void Button4_Click(object sender, EventArgs e)
        {

        }
    }
}
