Esempio n. 1
0
        private void _structTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            _activeInstance = (InstanceTreeNode)e.Node.Tag;
            if (_nodeControl != null)
            {
                _nodeControl.Parent.Controls.Remove(_nodeControl);
                _nodeControl.Dispose();
                _nodeControl = null;
            }
            _structTreeView.BeginUpdate();
            try
            {
                if (_activeInstance == null)
                {
                    _structGridView.DataSource = new List <StructCell>();
                }
                else
                {
                    NodeUI ui = FindNodeUI(_activeInstance);
                    if (ui != null)
                    {
                        _nodeControl      = ui.CreateControl();
                        _nodeControl.Dock = DockStyle.Fill;
                        splitContainer1.Panel2.Controls.Add(_nodeControl);
                        _structGridView.Visible = false;
                    }
                    else
                    {
                        _structGridView.Visible    = true;
                        _structGridView.DataSource = _activeInstance.Cells;
                    }
                    // while we're in BeginUpdate, pre-evaluate all cell values
                    _activeInstance.Cells.ToList().ForEach(cell => cell.Value.ToString());
                }
            }
            finally
            {
                _structTreeView.EndUpdate();
            }
            var instance = _activeInstance as StructInstance;

            if (instance == null)
            {
                InstanceTree tree = ActiveInstanceTree;
                if (tree != null)
                {
                    _hexDump.Stream = FindDataFile(tree).Stream;
                }
                _currentStructureHighlighter.SetRange(-1, -1);
            }
            else
            {
                _hexDump.Stream = instance.Stream;
                _currentStructureHighlighter.SetRange(instance.Offset, instance.EndOffset);
            }
        }
Esempio n. 2
0
        private void _structTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            _activeInstance = (InstanceTreeNode)e.Node.Tag;
            if (_nodeControl != null)
            {
                _nodeControl.Parent.Controls.Remove(_nodeControl);
                _nodeControl.Dispose();
                _nodeControl = null;
            }
            _structTreeView.BeginUpdate();
            try
            {
                if (_activeInstance == null)
                {
                    _structGridView.DataSource = new List <StructCell>();
                }
                else
                {
                    NodeUI ui = FindNodeUI(_activeInstance);
                    if (ui != null)
                    {
                        _nodeControl      = ui.CreateControl();
                        _nodeControl.Dock = DockStyle.Fill;
                        splitContainer1.Panel2.Controls.Add(_nodeControl);
                        _structGridView.Visible = false;
                    }
                    else
                    {
                        _structGridView.Visible = true;
                        // _structGridView.DataSource = _activeInstance.Cells;
                        if (_structGridView.DataSource == null)
                        {
                            _structGridView.DataSource = LoadDS(currentInstanceTree);
                        }
                    }
                    // while we're in BeginUpdate, pre-evaluate all cell values
                    _activeInstance.Cells.ToList().ForEach(cell => cell.Value.ToString());
                }
                if (!string.IsNullOrEmpty(this.parent.getFilterField()))
                {
                    (_structGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("{0} like '%{1}%'", this.parent.getFilterField(), this.parent.getFilterValue());
                }
            }
            finally
            {
                _structTreeView.EndUpdate();
            }
            var instance = _activeInstance as StructInstance;

            if (instance == null)
            {
                InstanceTree tree = ActiveInstanceTree;
                if (tree != null)
                {
                    _hexDump.Stream = FindDataFile(tree).Stream;
                }
                _currentStructureHighlighter.SetRange(-1, -1);
            }
            else
            {
                _hexDump.Stream = instance.Stream;
                _currentStructureHighlighter.SetRange(instance.Offset, instance.EndOffset);
            }
            // Re-select grid
            if (_structGridView.Rows.Count >= e.Node.Index && _structGridView.CurrentCell != null)
            {
                _structGridView.CurrentCell = _structGridView.Rows[e.Node.Index].Cells[_structGridView.CurrentCell.ColumnIndex];
            }
        }