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 WeifenLuo.WinFormsUI.Docking;
using GcDevicePc.Controls;

namespace GcDevicePc
{
    public partial class Test : DockContent
    {
        public Test()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int ret;
            string remoteFolder = "\\" + this.textBox1.Text + "\\"+ this.textBox3.Text + "\\";
            string getfile = this.textBox2.Text;
            string localfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.RunFolder+"\\Debugfile\\"+getfile;

            try
            {
                if (System.IO.File.Exists(localfile))
                {
                    System.IO.File.Delete(localfile);
                }
                if (globaldata.connection_ip != null && globaldata.connection_ip !="")
                {
                     FileServerClient mainclient = new FileServerClient();
                    mainclient.WtClientInit(globaldata.connection_ip, globaldata.fileserverport);
                    ret = mainclient.WtClientCopyfromServer(getfile, localfile, remoteFolder);
                    mainclient.WtClientClose();
                }

                if (System.IO.File.Exists(localfile))
                {
                    MessageBox.Show("获取成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch 
            {
                string message = "获取失败！";
                MessageBox.Show(message.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private bool useflag = false;
        private void button2_Click(object sender, EventArgs e)
        {
            if (!useflag)
            {
                this.pictureMenu1.StatusText = "连接";
                this.pictureMenu1.PMOptbtnstatus = 3;
                this.pictureMenu1.WaingShow = false;
                useflag = !useflag;
            }
            else
            {
                this.pictureMenu1.StatusText = "为连接";
                this.pictureMenu1.PMOptbtnstatus = 0;
                this.pictureMenu1.WaingShow = true;
                useflag = !useflag;
            }
        }

        private void pictureMenu1_PMOptBtnClicked(object sender, EventArgs e)
        {
            PictureBox btn = sender as PictureBox;
            MessageBox.Show(btn.Tag.ToString());
        }

        private void pictureMenu1_PMOrdBtnClicked(object sender, EventArgs e)
        {
            PictureBox btn = sender as PictureBox;
            MessageBox.Show(btn.Tag.ToString());
        }

        private bool sysflag = false;
        private void pictureMenu1_PMSysBtnClicked(object sender, EventArgs e)
        {
            if(!sysflag){
                this.pictureMenu1.PMSysbtnstatus = 1;
                sysflag = !sysflag;
            }else
            {
                this.pictureMenu1.PMSysbtnstatus = 0;
                sysflag = !sysflag;
            }
        }

    }
}
