Beispiel #1
0
        //--------------------------------------------------

        private void button2_Click(object sender, EventArgs e)
        {        //保存文件
            SaveFileDialog sfd    = new SaveFileDialog();
            WoDeWenJian    wwj    = new WoDeWenJian();
            string         strMsg = formatcommand();//发送设防命令

            sfd.InitialDirectory = "D:\\";
            sfd.Filter           = "文件(*.FON)|*.FON";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                wwj.CreateFile(sfd.FileName, strMsg);
            }
        }
Beispiel #2
0
        private void SevCsvTxk()
        {
            WoDeWenJian    WWJK            = new WoDeWenJian();
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            string[,] str = new string[3, 3];

            str[0, 0] = "t";
            str[0, 1] = "o";
            str[0, 2] = "m";
            str[1, 0] = "k";
            str[1, 1] = "f";
            str[1, 2] = "t";
            str[2, 0] = "y";
            str[2, 1] = "u";
            str[2, 2] = "n";

            string line = string.Empty;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    line += str[i, j] + ",";
                }
                line  = line.TrimEnd(',');
                line += "\r\n";
            }
            File.WriteAllText(@"F:\data.CSV", line);



            openFileDialog1.Filter = "CSV文件|*.CSV";
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                //this.dt.DataSource = null;
                // this.dgvShow.DataSource = null;
                //string fileName = openFileDialog1.FileName;
                // this.dgvShow.DataSource = OpenCSV(fileName);

                MessageBox.Show("成功显示CSV数据!");
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Server s = new Server();
            // s.BeginListening("192.168.1.102", "8555", listView1);
            // MessageBox.Show("服务器已开启");
            WoDeWenJian    wwj            = new WoDeWenJian();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "D:\\";
            openFileDialog.Filter           = "文件(*.txt)|*.txt|所有文件(*.*)|*.*|CSV文件(*.CSV)|*.csv";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(openFileDialog.FileName);
                textBox8.Text = wwj.Read(openFileDialog.FileName);
                //    textBox8.Text = "";
            }
        }
        //--------------------------------------------------

        private void button2_Click(object sender, EventArgs e)
        {        //保存文件

            SaveFileDialog sfd = new SaveFileDialog();
            WoDeWenJian wwj = new WoDeWenJian();
            string strMsg = formatcommand();//发送设防命令
            sfd.InitialDirectory = "D:\\";
            sfd.Filter = "文件(*.FON)|*.FON";
            if (sfd.ShowDialog() == DialogResult.OK)
            {


                wwj.CreateFile(sfd.FileName,strMsg);
            }
            
           
        }
        private void button4_Click(object sender, EventArgs e)
        {   //---------------读取置----------;
            WoDeWenJian wwj = new WoDeWenJian();
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = "D:\\";
            openFileDialog.Filter = "文件(*.FON)|*.FON";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex = 1;
            string stl = "";
            string stm = "";
           
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(openFileDialog.FileName);
                string command = wwj.Read(openFileDialog.FileName);
                if (command.IndexOf("+主机设防[") != -1)
                {
                    string zs = "";
                    zs = command.Substring((command.IndexOf("开始设定[") + 5), 7);
                   // MessageBox.Show(zs);
                    JieXiMingLing(zs);
                    //--------------------------------------------------
                    if (command.IndexOf("[常闭]") != -1) { radioButton2.Checked = true; radioButton1.Checked = false; }
                    if (command.IndexOf("[常开]") != -1) { radioButton1.Checked = true; radioButton2.Checked = false; }
                    stl = "授权[";
                    stm = "]报";
                    zs = ZiFuChn(command, stl, stm);

                        textBox15.Text = zs;
                //---------------------------------------------------------
                        stl = "报警[";
                        stm = "]地";
                        zs = ZiFuChn(command, stl, stm);
                        //MessageBox.Show(zs);
                        string[]sAry = zs.Split(';');
                        int i=0;
                        foreach (string we in sAry)
                        {
                         i = i + 1;
                        }
                        //MessageBox.Show("MPF[" + i+"]");
                        textBox14.Text = "";
                        textBox13.Text = "";
                        textBox10.Text = "";
                        textBox18.Text = "";
                        textBox16.Text = "";
                        for (int x = 0; x < i; x++)
                        {
                            switch (x)
                            {
                                case 0:
                                    textBox14.Text=sAry[x];
                                    break;
                                case 1:
                                    textBox13.Text = sAry[x];
                                    break;
                                case 2:
                                    textBox10.Text = sAry[x];
                                    break;
                                case 3:
                                    textBox18.Text = sAry[x];
                                    break;
                                case 4:
                                    textBox16.Text = sAry[x];
                                    break;

                            }
                        }
//-------------------------------------------------------------------------
  
                    stl = "温度[";
                    stm = "]延";
                    zs = ZiFuChn(command, stl, stm);
                    textBox2.Text = zs;
//-------------------------------------------------------------------------
                    stl = "延时[";
                    stm = "]响";
                    zs = ZiFuChn(command, stl, stm);
                    textBox4.Text = zs;
//------------------------------------------------------------------------------
                    stl = "响声[";
                    stm = "]发";
                    zs = ZiFuChn(command, stl, stm);
                    textBox3.Text = zs;
//---------------------------------------------------------------------------
                    stl = "发送[";
                    stm = "]修";
                    zs = ZiFuChn(command, stl, stm);
                    textBox6.Text = zs;
//------------------------------------------------------------------------
                  stl="地址[";
                  stm="][";
                  zs=ZiFuChn(command,stl,stm);
                  if (zs != "")
                  {
                      textBox1.Text = frmMain.Decode(zs);//
                  }
                  else
                  {
                      textBox1.Text = zs;//
                  }
//------------------------------------------------------------
                    
                } 
                
            }

        }
        private void button1_Click(object sender, EventArgs e)
        {
           // Server s = new Server();
           // s.BeginListening("192.168.1.102", "8555", listView1);
           // MessageBox.Show("服务器已开启");
            WoDeWenJian wwj = new WoDeWenJian();
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = "D:\\";
            openFileDialog.Filter = "文件(*.txt)|*.txt|所有文件(*.*)|*.*|CSV文件(*.CSV)|*.csv";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex = 1;
          
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(openFileDialog.FileName);
                textBox8.Text = wwj.Read(openFileDialog.FileName);
            //    textBox8.Text = "";
               
            }

        }
        private void SevCsvTxk()
        {
            WoDeWenJian WWJK = new WoDeWenJian();
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            string[,] str = new string[3, 3]; 
  
            str[0, 0] = "t"; 
            str[0, 1] = "o"; 
            str[0, 2] = "m"; 
            str[1, 0] = "k"; 
            str[1, 1] = "f"; 
            str[1, 2] = "t"; 
            str[2, 0] = "y"; 
            str[2, 1] = "u"; 
            str[2, 2] = "n"; 
  
            string line = string.Empty; 
            for (int i = 0; i < 3; i++) 
            { 
                  
                for (int j = 0; j < 3; j++) 
                { 
                    line += str[i, j] + ","; 
                } 
                line = line.TrimEnd(','); 
                line += "\r\n"; 
            }
            File.WriteAllText(@"F:\data.CSV", line); 
     

           
        
            openFileDialog1.Filter = "CSV文件|*.CSV";
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                //this.dt.DataSource = null;
               // this.dgvShow.DataSource = null;
                //string fileName = openFileDialog1.FileName;
               // this.dgvShow.DataSource = OpenCSV(fileName);
             
                MessageBox.Show("成功显示CSV数据!");
            }
        }
Beispiel #8
0
        private void button4_Click(object sender, EventArgs e)
        {   //---------------读取置----------;
            WoDeWenJian    wwj            = new WoDeWenJian();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "D:\\";
            openFileDialog.Filter           = "文件(*.FON)|*.FON";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            string stl = "";
            string stm = "";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(openFileDialog.FileName);
                string command = wwj.Read(openFileDialog.FileName);
                if (command.IndexOf("+主机设防[") != -1)
                {
                    string zs = "";
                    zs = command.Substring((command.IndexOf("开始设定[") + 5), 7);
                    // MessageBox.Show(zs);
                    JieXiMingLing(zs);
                    //--------------------------------------------------
                    if (command.IndexOf("[常闭]") != -1)
                    {
                        radioButton2.Checked = true; radioButton1.Checked = false;
                    }
                    if (command.IndexOf("[常开]") != -1)
                    {
                        radioButton1.Checked = true; radioButton2.Checked = false;
                    }
                    stl = "授权[";
                    stm = "]报";
                    zs  = ZiFuChn(command, stl, stm);

                    textBox15.Text = zs;
                    //---------------------------------------------------------
                    stl = "报警[";
                    stm = "]地";
                    zs  = ZiFuChn(command, stl, stm);
                    //MessageBox.Show(zs);
                    string[] sAry = zs.Split(';');
                    int      i    = 0;
                    foreach (string we in sAry)
                    {
                        i = i + 1;
                    }
                    //MessageBox.Show("MPF[" + i+"]");
                    textBox14.Text = "";
                    textBox13.Text = "";
                    textBox10.Text = "";
                    textBox18.Text = "";
                    textBox16.Text = "";
                    for (int x = 0; x < i; x++)
                    {
                        switch (x)
                        {
                        case 0:
                            textBox14.Text = sAry[x];
                            break;

                        case 1:
                            textBox13.Text = sAry[x];
                            break;

                        case 2:
                            textBox10.Text = sAry[x];
                            break;

                        case 3:
                            textBox18.Text = sAry[x];
                            break;

                        case 4:
                            textBox16.Text = sAry[x];
                            break;
                        }
                    }
//-------------------------------------------------------------------------

                    stl           = "温度[";
                    stm           = "]延";
                    zs            = ZiFuChn(command, stl, stm);
                    textBox2.Text = zs;
//-------------------------------------------------------------------------
                    stl           = "延时[";
                    stm           = "]响";
                    zs            = ZiFuChn(command, stl, stm);
                    textBox4.Text = zs;
//------------------------------------------------------------------------------
                    stl           = "响声[";
                    stm           = "]发";
                    zs            = ZiFuChn(command, stl, stm);
                    textBox3.Text = zs;
//---------------------------------------------------------------------------
                    stl           = "发送[";
                    stm           = "]修";
                    zs            = ZiFuChn(command, stl, stm);
                    textBox6.Text = zs;
//------------------------------------------------------------------------
                    stl = "地址[";
                    stm = "][";
                    zs  = ZiFuChn(command, stl, stm);
                    if (zs != "")
                    {
                        textBox1.Text = frmMain.Decode(zs);//
                    }
                    else
                    {
                        textBox1.Text = zs;//
                    }
//------------------------------------------------------------
                }
            }
        }