Exemple #1
0
 private void button_restart_Click(object sender, EventArgs e)
 {
     try
     {
         if (m_clientSocket != null && m_clientSocket.GetSocketState())
         {
             m_clientSocket.ClientSend("os.exit()\n");
             m_clientSocket.CloseSocket();
             m_clientSocket = null;
             this.button_parameter.Enabled = false;
             this.button_RunOnce.Enabled   = false;
             this.button_restart.Enabled   = false;
         }
         else
         {
             this.button_parameter.Enabled = false;
             this.button_RunOnce.Enabled   = false;
             this.button_restart.Enabled   = false;
             MessageBox.Show("请先连接服务器!");
         }
     }
     catch (System.Exception)
     {
         this.button_parameter.Enabled = false;
         this.button_RunOnce.Enabled   = false;
         this.button_restart.Enabled   = false;
         MessageBox.Show("服务器异常退出, 请重新连接!");
     }
 }
 //服务器重启按钮事件
 private void button_restart_Click(object sender, EventArgs e)
 {
     try
     {
         //如果网络连接正常
         if (m_clientSocket != null && m_clientSocket.GetSocketState())
         {
             m_clientSocket.ClientSend("os.exit()\n"); //向服务器发送指令
             m_clientSocket.CloseSocket();             //关闭套接字
             m_clientSocket = null;
             this.button_parameter.Enabled = false;    //参数设置按钮无效
             this.button_RunOnce.Enabled   = false;    //运行一次按钮无效
             this.button_restart.Enabled   = false;    //服务器重启按钮无效
         }
         else //如果网络连接不正常
         {
             this.button_parameter.Enabled = false; //参数设置按钮无效
             this.button_RunOnce.Enabled   = false; //运行一次按钮无效
             this.button_restart.Enabled   = false; //服务器重启按钮无效
             MessageBox.Show("请先连接服务器!");
         }
     }
     catch (System.Exception)                   //如果发生错误
     {
         this.button_parameter.Enabled = false; //参数设置按钮无效
         this.button_RunOnce.Enabled   = false; //运行一次按钮无效
         this.button_restart.Enabled   = false; //服务器重启按钮无效
         MessageBox.Show("服务器异常退出, 请重新连接!");
     }
 }
Exemple #3
0
        //点击确定按钮
        private void button_OKSet_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_strText.Equals("草地")) //如果选择了草地
                {
                    //获取三个系数
                    this.m_fR = Convert.ToDouble(this.textBox_r1.Text.ToString());
                    this.m_fG = Convert.ToDouble(this.textBox_g1.Text.ToString());
                    this.m_fB = Convert.ToDouble(this.textBox_b1.Text.ToString());
                }
                else if (m_strText.Equals("沙土地")) //如果选择了沙土地
                {
                    //获取三个系数
                    this.m_fR = Convert.ToDouble(this.textBox_r2.Text.ToString());
                    this.m_fG = Convert.ToDouble(this.textBox_g2.Text.ToString());
                    this.m_fB = Convert.ToDouble(this.textBox_b2.Text.ToString());
                }
                else if (m_strText.Equals("水泥地")) //如果选择了水泥地
                {
                    //获取三个系数
                    this.m_fR = Convert.ToDouble(this.textBox_r3.Text.ToString());
                    this.m_fG = Convert.ToDouble(this.textBox_g3.Text.ToString());
                    this.m_fB = Convert.ToDouble(this.textBox_b3.Text.ToString());
                }
                else if (m_strText.Equals("林地")) //如果选择了林地
                {
                    //获取三个系数
                    this.m_fR = Convert.ToDouble(this.textBox_r4.Text.ToString());
                    this.m_fG = Convert.ToDouble(this.textBox_g4.Text.ToString());
                    this.m_fB = Convert.ToDouble(this.textBox_b4.Text.ToString());
                }
            }
            catch (System.Exception) //如果发生错误
            {
                MessageBox.Show("输入数据不合法!");
            }

            //如果网络连接正常
            if (m_clientSocket != null && m_clientSocket.GetSocketState())
            {
                //向服务器发送指令
                string strTemp = String.Format("AjustRgbs({0},{1},{2})\n", m_fR, m_fG, m_fB);
                m_clientSocket.ClientSend(strTemp);
                strTemp = m_clientSocket.ClientRecv(); //接收数据
            }
            else //如果网络连接不正常
            {
                MessageBox.Show("请先连接到服务器!");
            }
            this.Close(); //关闭对话框
        }
Exemple #4
0
        private void button_connect_Click(object sender, EventArgs e)
        {
            string strIP = this.textBox_address.Text.ToString();

            if (strIP.Trim().Equals(""))
            {
                MessageBox.Show("IP地址不能为空!");
                return;
            }
            string strPort = this.textBox_port.Text.ToString();

            if (strPort.Trim().Equals(""))
            {
                MessageBox.Show("端口号不能为空!");
                return;
            }

            int intPort = Convert.ToInt32(strPort);

            m_clientSocket = new ClientSocket(strIP, intPort);
            m_bConnected   = m_clientSocket.ConnectServer();
            string strRecved = null;

            if (m_bConnected)
            {
                try
                {
                    m_clientSocket.ClientSend("?config.IsNetCamera\n");
                    strRecved = m_clientSocket.ClientRecv();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.StackTrace.ToString());
                }
                this.button_parameter.Enabled = true;
                this.button_RunOnce.Enabled   = true;
                this.button_restart.Enabled   = true;
                if (strRecved.Equals("false\n"))
                {
                    this.button_EnvironmentSetting.Enabled = false;
                    MessageBox.Show("已成功连接至服务器, \n\n您正在使用Logitech摄像头!");
                    //SelfMessageBox smb = new SelfMessageBox(m_clientSocket);
                    //smb.ShowDialog(this);
                }
                else if (strRecved.Equals("true\n"))
                {
                    this.button_EnvironmentSetting.Enabled = true;
                    SelfMessageBox smb = new SelfMessageBox(m_clientSocket);
                    smb.ShowDialog(this);
                }
                InitializeTimer(5000);
            }
            else
            {
                this.button_parameter.Enabled = false;
                this.button_RunOnce.Enabled   = false;
                this.button_restart.Enabled   = false;
                m_clientSocket = null;
                MessageBox.Show("连接失败, 请正确配置服务器!");
            }
        }
        //系统连接按钮事件
        private void button_connect_Click(object sender, EventArgs e)
        {
            string strIP = this.textBox_address.Text.ToString(); //获取IP地址

            if (strIP.Trim().Equals(""))                         //如果IP地址为空
            {
                MessageBox.Show("IP地址不能为空!");                    //弹出对话框
                return;
            }
            string strPort = this.textBox_port.Text.ToString(); //获取端口号

            if (strPort.Trim().Equals(""))                      //如果端口号为空
            {
                MessageBox.Show("端口号不能为空!");
                return;
            }

            int intPort = Convert.ToInt32(strPort);            //得到端口号

            m_clientSocket = new ClientSocket(strIP, intPort); //创建套接字
            m_bConnected   = m_clientSocket.ConnectServer();   //连接服务器
            string strRecved = null;                           //接收到的数据

            if (m_bConnected)                                  //如果服务器连接成功
            {
                try
                {
                    //向服务器发送状态查询指令
                    m_clientSocket.ClientSend("?config.IsNetCamera\n");
                    strRecved = m_clientSocket.ClientRecv(); //从服务器接收返回结果
                }
                catch (Exception ex)
                {
                    //如果通信异常, 给出错误信息
                    MessageBox.Show(ex.StackTrace.ToString());
                }
                this.button_parameter.Enabled = true;               //参数设置按钮有效
                this.button_RunOnce.Enabled   = true;               //运行一次按钮有效
                this.button_restart.Enabled   = true;               //服务器重启按钮有效
                if (strRecved.Equals("false\n"))                    //如果使用的是罗技摄像头
                {
                    this.button_EnvironmentSetting.Enabled = false; //环境设置按钮无效
                    MessageBox.Show("已成功连接至服务器, \n\n您正在使用Logitech摄像头!");
                    //SelfMessageBox smb = new SelfMessageBox(m_clientSocket);
                    //smb.ShowDialog(this);
                }
                else if (strRecved.Equals("true\n"))               //如果使用的是网口摄像头
                {
                    this.button_EnvironmentSetting.Enabled = true; //环境设置按钮有效
                    SelfMessageBox smb = new SelfMessageBox(m_clientSocket);
                    smb.ShowDialog(this);                          //创建并显示环境设置对话框
                }
                InitializeTimer(5000);                             //初始化定时器
            }
            else  //如果服务器连接失败
            {
                this.button_parameter.Enabled = false; //参数设置按钮无效
                this.button_RunOnce.Enabled   = false; //运行一次按钮无效
                this.button_restart.Enabled   = false; //服务器重启按钮无效
                m_clientSocket = null;                 //清理套接字
                MessageBox.Show("连接失败, 请正确配置服务器!");
            }
        }
        private void button_CamereSetOK_Click(object sender, EventArgs e)
        {
            string strTemp = "config.camera='" + this.m_strCamera + "'\n";

            m_clientSocket.ClientSend(strTemp);
            strTemp = m_clientSocket.ClientRecv();
            if (this.checkBox_midresult.Checked)
            {
                m_clientSocket.ClientSend("config.debug=true\n");
                strTemp = m_clientSocket.ClientRecv();
            }
            else
            {
                m_clientSocket.ClientSend("config.debug=false\n");
                strTemp = m_clientSocket.ClientRecv();
            }
        }
Exemple #7
0
        //基本参数设置按钮事件
        private void button_CamereSetOK_Click(object sender, EventArgs e)
        {
            //构造相机参数字符串
            string strTemp = "config.camera='" + this.m_strCamera + "'\n";

            m_clientSocket.ClientSend(strTemp);    //发送指令
            strTemp = m_clientSocket.ClientRecv(); //接收数据
            //如果是否输出中间结果复选框被选中
            if (this.checkBox_midresult.Checked)
            {
                m_clientSocket.ClientSend("config.debug=true\n"); //发送指令
                strTemp = m_clientSocket.ClientRecv();            //接收数据
            }
            else  //如果是否输出中间结果复选框没被选中
            {
                m_clientSocket.ClientSend("config.debug=false\n"); //发送指令
                strTemp = m_clientSocket.ClientRecv();             //接收数据
            }
        }