Пример #1
0
 private void button_parameter_Click(object sender, EventArgs e)
 {
     try
     {
         if (m_clientSocket != null && m_clientSocket.GetSocketState())
         {
             if (m_pw == null || m_pw.IsDisposed)
             {
                 m_pw = new ParameterWindow(m_clientSocket);
                 m_pw.Show();
             }
             else
             {
                 m_pw.Activate();
             }
         }
         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("服务器异常退出, 请重新连接!");
     }
 }
Пример #2
0
 //参数设置按钮事件
 private void button_parameter_Click(object sender, EventArgs e)
 {
     try
     {
         //如果网络连接正常
         if (m_clientSocket != null && m_clientSocket.GetSocketState())
         {
             if (m_pw == null || m_pw.IsDisposed) //如果还未打开参数设置对话框
             {
                 m_pw = new ParameterWindow(m_clientSocket);
                 m_pw.Show(); //创建并显示参数设置对话框
             }
             else //如果已打开参数设置对话框
             {
                 m_pw.Activate(); //激活参数设置对话框
             }
         }
         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("服务器异常退出, 请重新连接!");
     }
 }
Пример #3
0
        private void RefreshVariableValues()
        {
            string strRecved = null;

            try
            {
                if (m_clientSocket != null && m_clientSocket.GetSocketState())
                {
                    m_clientSocket.ClientSend("?\n");
                    strRecved = m_clientSocket.ClientRecv();
                }
                else
                {
                    this.Close();
                    MessageBox.Show("请先连接到服务器!");
                    return;
                }
            }
            catch (System.Exception)
            {
            }

            JObject jObj = null;

            try
            {
                jObj = JObject.Parse(strRecved);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace.ToString());
                return;
            }
            ParseJsonData(jObj);
        }
Пример #4
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(); //关闭对话框
        }
Пример #5
0
        //更新所有控件变量的值
        private void RefreshVariableValues()
        {
            string strRecved = null;

            try
            {
                //如果网络连接正常
                if (m_clientSocket != null && m_clientSocket.GetSocketState())
                {
                    m_clientSocket.ClientSend("?\n");        //发送指令
                    strRecved = m_clientSocket.ClientRecv(); //接收数据
                }
                else  //如果网络连接不正常
                {
                    this.Close(); //关闭对话框
                    MessageBox.Show("请先连接到服务器!");
                    return;
                }
            }
            catch (System.Exception)  //如果发生错误
            {
            }

            JObject jObj = null;

            try
            {
                jObj = JObject.Parse(strRecved); //解析Json
            }
            catch (Exception ex)                 //如果发生错误
            {
                MessageBox.Show(ex.StackTrace.ToString());
                return;
            }
            ParseJsonData(jObj);  //处理已解析的Json对象
        }