VAGSuite.HexViewer.LoadDataFromFile C# (CSharp) Méthode

LoadDataFromFile() public méthode

public LoadDataFromFile ( string filename, SymbolCollection symbols ) : void
filename string
symbols SymbolCollection
Résultat void
        public void LoadDataFromFile(string filename, SymbolCollection symbols)
        {
            _fileName = filename;
            _lastFilename = _fileName;
            m_symbolcollection = symbols;
            FileInfo fi = new FileInfo(filename);
            m_currentfile_size = (int)fi.Length;
            OpenFile(filename);

            // ???
            //            CloseFile();

            /*
            FileInfo fi = new FileInfo(filename);
            long numberoflines = fi.Length/16;
            StringBuilder sb = new StringBuilder();
            StringBuilder sbascii = new StringBuilder();
            using (BinaryReader br = new BinaryReader(new FileStream(filename, FileMode.Open)))
            {
                int current_address = 0;
                for (int lcount = 0; lcount < numberoflines; lcount++)
                {
                    byte[] readbytes = br.ReadBytes(16);
                    string line = current_address.ToString("X6") + " ";
                    for (int bcount = 0; bcount < readbytes.Length; bcount++)
                    {
                        byte b = (byte)readbytes.GetValue(bcount);
                        line += b.ToString("X2") + " ";
                    }
                    string line_ascii = string.Empty;
                    for (int bcount = 0; bcount < readbytes.Length; bcount++)
                    {
                        byte b = (byte)readbytes.GetValue(bcount);
                        if (b >= 0x20 && b <= 0x7f)
                        {
                            line_ascii += Convert.ToChar( b);
                        }
                        else
                        {
                            line_ascii += ".";
                        }
                    }
                    sb.AppendLine(line);
                    sbascii.AppendLine(line_ascii);
                    current_address += 16;
                }
            }
            richTextBox1.Text = sb.ToString();
            richTextBox2.Text = sbascii.ToString();

            //MessageBox.Show(richTextBox1.Find("ox1_filt_coef").ToString());*/
        }

Usage Example

Exemple #1
0
        private void StartHexViewer()
        {
            if (Tools.Instance.m_currentfile != "")
            {
                dockManager1.BeginUpdate();
                try
                {
                    DevExpress.XtraBars.Docking.DockPanel dockPanel;
                    //= dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right);
                    if (!m_appSettings.NewPanelsFloating)
                    {
                        dockPanel = dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right);
                    }
                    else
                    {
                        System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 10));
                        dockPanel = dockManager1.AddPanel(floatpoint);
                    }

                    dockPanel.Text = "Hexviewer: " + Path.GetFileName(Tools.Instance.m_currentfile);
                    HexViewer hv = new HexViewer();
                    hv.Issramviewer = false;
                    hv.Dock = DockStyle.Fill;
                    dockPanel.Width = 580;
                    hv.LoadDataFromFile(Tools.Instance.m_currentfile, Tools.Instance.m_symbols);
                    dockPanel.ClosedPanel += new DevExpress.XtraBars.Docking.DockPanelEventHandler(dockPanel_ClosedPanel);
                    dockPanel.Controls.Add(hv);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                }
                dockManager1.EndUpdate();
            }
        }