Esempio n. 1
0
File: Form1.cs Progetto: BJFX/UWACN
        private void opennetfile_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    BinaryReader br = new BinaryReader(openFileDialog.OpenFile());

                    byte[] b = br.ReadBytes((int)openFileDialog.OpenFile().Length);

                    DataViewForm dvf = new DataViewForm();

                    dvf.str       = CRCHelper.ConvertCharToHex(b, b.Length);
                    dvf.Text      = openFileDialog.FileName;
                    dvf.MdiParent = this;
                    dvf.ShowData();
                    dvf.WindowState = FormWindowState.Maximized;

                    br.Close();
                }
                catch (Exception MyEx)
                {
                    MessageBox.Show("数据格式错误!" + MyEx.Message);
                }
            }
        }
Esempio n. 2
0
File: Form1.cs Progetto: BJFX/UWACN
        private void opensinglefile_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    BinaryReader br = new BinaryReader(openFileDialog.OpenFile());
                    int          a  = br.PeekChar();
                    if ((char)a == 0x45)
                    {
                        isCommType = true;
                    }
                    else
                    {
                        isCommType = false;//默认网络数据
                    }
                    byte[] b = br.ReadBytes((int)openFileDialog.OpenFile().Length);
                    if (isCommType)
                    {
                        int    NodeId;
                        string time;
                        byte[] data;
                        if (DepackData(b, out NodeId, out time, out data))
                        {
                            DataViewForm dvf = new DataViewForm();
                            dvf.str       = CRCHelper.ConvertCharToHex(data, data.Length);
                            dvf.Text      = openFileDialog.FileName;
                            dvf.MdiParent = this;
                            dvf.ShowData();
                            dvf.WindowState = FormWindowState.Maximized;
                        }
                        else
                        {
                            throw new Exception("数据校验错误!");
                        }
                    }
                    else
                    {
                        DataViewForm dvf = new DataViewForm();

                        dvf.str       = CRCHelper.ConvertCharToHex(b, b.Length);
                        dvf.Text      = openFileDialog.FileName;
                        dvf.MdiParent = this;
                        dvf.ShowData();
                        dvf.WindowState = FormWindowState.Maximized;
                    }
                    br.Close();
                }
                catch (Exception MyEx)
                {
                    MessageBox.Show("数据格式错误!" + MyEx.Message);
                }
            }
        }
Esempio n. 3
0
        private void FileList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.RowIndex;

            if (FileList.Rows[index].Cells[e.ColumnIndex].Value != null)
            {
                string       s    = FileList.Rows[index].Cells[e.ColumnIndex].Value.ToString();
                Byte[]       data = (Byte[])TimeData[s];
                DataViewForm dvf  = new DataViewForm();
                dvf.str       = CRCHelper.ConvertCharToHex(data, data.Length);
                dvf.MdiParent = this.ParentForm;
                dvf.ShowData();
                dvf.WindowState = FormWindowState.Maximized;
            }
        }