示例#1
0
 public void NotifyInstanceAdded(InstanceTreeNode parent, InstanceTreeNode child)
 {
     if (InstanceAdded != null)
     {
         InstanceAdded(this, new InstanceAddedEventArgs(parent, child));
     }
 }
示例#2
0
 public void NotifyNodeNameChanged(InstanceTreeNode node)
 {
     if (NodeNameChanged != null)
     {
         NodeNameChanged(this, new NodeNameChangedEventArgs(node));
     }
 }
示例#3
0
 public override void AddChild(InstanceTreeNode instance)
 {
     _children.Add(instance);
     if (_notifyChildren)
     {
         GetInstanceTree().NotifyInstanceAdded(this, instance);
     }
 }
示例#4
0
 public override void AddChild(InstanceTreeNode instance)
 {
     _children.Add(instance);
     if (_notifyChildren)
     {
         GetInstanceTree().NotifyInstanceAdded(this, instance);
     }
 }
示例#5
0
 public StructInstance(StructDef def, InstanceTreeNode parent, Stream stream, long offset)
 {
     if (offset < 0) throw new ArgumentOutOfRangeException("offset");
     SequenceIndex = -1;
     _def = def;
     _parent = parent;
     _stream = stream;
     _offset = offset;
 }
示例#6
0
        public InstanceTree GetInstanceTree()
        {
            InstanceTreeNode parent = this;

            while (!(parent is InstanceTree))
            {
                parent = parent.Parent;
            }
            return((InstanceTree)parent);
        }
示例#7
0
 public StructInstance(StructDef def, InstanceTreeNode parent, Stream stream,
                       StructInstance followInstance, bool followChildren)
 {
     SequenceIndex   = -1;
     _def            = def;
     _parent         = parent;
     _stream         = stream;
     _followInstance = followInstance;
     _followChildren = followChildren;
 }
示例#8
0
 public StructInstance(StructDef def, InstanceTreeNode parent, Stream stream, 
     StructInstance followInstance, bool followChildren)
 {
     SequenceIndex = -1;
     _def = def;
     _parent = parent;
     _stream = stream;
     _followInstance = followInstance;
     _followChildren = followChildren;
 }
示例#9
0
        public static StructInstance EvaluateParent(StructInstance context, IConvertible[] parameters)
        {
            InstanceTreeNode parent = context.Parent;

            while (parent != null && !(parent is StructInstance))
            {
                parent = parent.Parent;
            }
            return((StructInstance)parent);
        }
示例#10
0
        private static IEvaluateContext EvaluateRoot(StructInstance context, IConvertible[] parameters)
        {
            InstanceTreeNode root = context;

            while (!(root.Parent is InstanceTree))
            {
                root = root.Parent;
            }
            return((StructInstance)root);
        }
示例#11
0
 private void CheckMatch(InstanceTreeNode node)
 {
     if (node is StructInstance)
     {
         var instance = (StructInstance) node;
         if (instance.Def == _def && (_expr == null || _expr.EvaluateBool(instance)))
         {
             _results.Add(instance);
         }
     }
 }
示例#12
0
 private void CheckMatch(InstanceTreeNode node)
 {
     if (node is StructInstance)
     {
         var instance = (StructInstance)node;
         if (instance.Def == _def && (_expr == null || _expr.EvaluateBool(instance)))
         {
             _results.Add(instance);
         }
     }
 }
示例#13
0
 public StructInstance(StructDef def, InstanceTreeNode parent, Stream stream, long offset)
 {
     if (offset < 0)
     {
         throw new ArgumentOutOfRangeException("offset");
     }
     SequenceIndex = -1;
     _def          = def;
     _parent       = parent;
     _stream       = stream;
     _offset       = offset;
 }
示例#14
0
        private static IEvaluateContext EvaluateChild(StructInstance context, IConvertible[] parameters)
        {
            int childIndex;
            InstanceTreeNode parent = context;

            context.NeedChildren();
            if (parameters.Length == 1)
            {
                childIndex = parameters[0].ToInt32(null);
            }
            else if (parameters.Length == 2)
            {
                string groupName  = parameters[0].ToString(null);
                bool   groupFound = false;
                foreach (InstanceTreeNode child in context.Children)
                {
                    if (child is GroupContainer && child.NodeName == groupName)
                    {
                        parent     = child;
                        groupFound = true;
                    }
                }
                if (!groupFound)
                {
                    throw new LoadDataException("Could not find child group " + groupName);
                }
                try
                {
                    childIndex = parameters[1].ToInt32(null);
                }
                catch (OverflowException e)
                {
                    throw new LoadDataException(e.Message);
                }
            }
            else
            {
                throw new LoadDataException("'child' context requires 1 or 2 parameters");
            }
            parent.NeedChildren();
            var children = parent.Children;

            if (childIndex < 0 || childIndex >= children.Count)
            {
                throw new LoadDataException("Invalid child index " + childIndex + ": child count " + children.Count);
            }
            return((IEvaluateContext)children[childIndex]);
        }
示例#15
0
        private void PreloadChildren()
        {
            int i = 0;

            while (i < _children.Count)
            {
                InstanceTreeNode child = _children [i];
                if (child is StructInstance)
                {
                    (child as StructInstance).Preloading = true;
                    try
                    {
                        child.NeedData();
                    }
                    finally
                    {
                        (child as StructInstance).Preloading = false;
                    }
                }
                i++;
            }
        }
示例#16
0
 private void SaveBlobCells(InstanceTreeNode node)
 {
     string name = null;
     foreach(StructCell cell in node.Cells)
     {
         if (cell.GetValue() is string)
         {
             name = (string) cell.GetValue();
         }
         else if (cell is BlobCell && name != null)
         {
             try
             {
                 SaveBlobCell((BlobCell) cell, name);
             }
             catch (Exception e)
             {
                 _errors.Add("Failed to extract data for " + name + ": " + e.Message);
             }
         }
     }
 }
示例#17
0
        private void SaveBlobCells(InstanceTreeNode node)
        {
            string name = null;

            foreach (StructCell cell in node.Cells)
            {
                if (cell.GetValue() is string)
                {
                    name = (string)cell.GetValue();
                }
                else if (cell is BlobCell && name != null)
                {
                    try
                    {
                        SaveBlobCell((BlobCell)cell, name);
                    }
                    catch (Exception e)
                    {
                        _errors.Add("Failed to extract data for " + name + ": " + e.Message);
                    }
                }
            }
        }
示例#18
0
 public abstract void AddChild(InstanceTreeNode instance);
示例#19
0
 public override void AddChild(InstanceTreeNode node)
 {
     _instances.Add(node);
     NotifyInstanceAdded(this, node);
 }
示例#20
0
 public NodeNameChangedEventArgs(InstanceTreeNode node)
 {
     _node = node;
 }
示例#21
0
        private void AddInstanceNode(TreeNode parent, InstanceTreeNode instance)
        {
            TreeNode node;
            if (parent == null)
            {
                string fileName = FindDataFile(instance).Name;
                node = _structTreeView.Nodes.Add(instance.NodeName + " (" + Path.GetFileName(fileName) + ")");
            }
            else
            {
                node = parent.Nodes.Add(AppendSequenceIndex(instance));
            }

            _nodeMap.Add(instance, node);
            node.Tag = instance;
            if (instance.HasChildren)
            {
                WindowsAPI.SetHasChildren(node, true);
            }
        }
示例#22
0
 public InstanceAddedEventArgs(InstanceTreeNode parent, InstanceTreeNode child)
 {
     _parent = parent;
     _child  = child;
 }
示例#23
0
 private void UpdateNodeName(InstanceTreeNode instance)
 {
     TreeNode node;
     if (_nodeMap.TryGetValue(instance, out node))
     {
         if (InvokeRequired)
         {
             _nameChangedNodes.Add(instance);
         }
         else
         {
             node.Text = AppendSequenceIndex(instance);
         }
     }
 }
示例#24
0
 private DataFile FindDataFile(InstanceTreeNode instance)
 {
     InstanceTree tree = instance.GetInstanceTree();
     return _dataFiles.Find(f => f.InstanceTree == tree);
 }
示例#25
0
 public NodeNameChangedEventArgs(InstanceTreeNode node)
 {
     _node = node;
 }
示例#26
0
 public InstanceAddedEventArgs(InstanceTreeNode parent, InstanceTreeNode child)
 {
     _parent = parent;
     _child = child;
 }
示例#27
0
 public void NotifyNodeNameChanged(InstanceTreeNode node)
 {
     if (NodeNameChanged != null)
     {
         NodeNameChanged(this, new NodeNameChangedEventArgs(node));
     }
 }
示例#28
0
 private static NodeUI FindNodeUI(InstanceTreeNode instance)
 {
     foreach(var cell in instance.Cells)
     {
         var ui = NodeUIRegistry.GetNodeUI(cell);
         if (ui != null) return ui;
     }
     return null;
 }
示例#29
0
 public abstract void AddChild(InstanceTreeNode instance);
示例#30
0
 public GroupContainer(InstanceTreeNode parent, string groupName)
 {
     _parent    = parent;
     _groupName = groupName;
 }
示例#31
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);
     }
 }
示例#32
0
 public override void AddChild(InstanceTreeNode node)
 {
     _instances.Add(node);
     NotifyInstanceAdded(this, node);
 }
示例#33
0
 public void NotifyInstanceAdded(InstanceTreeNode parent, InstanceTreeNode child)
 {
     if (InstanceAdded != null)
     {
         InstanceAdded(this, new InstanceAddedEventArgs(parent, child));
     }
 }
示例#34
0
 public GroupContainer(InstanceTreeNode parent, string groupName)
 {
     _parent = parent;
     _groupName = groupName;
 }
示例#35
0
 private static string AppendSequenceIndex(InstanceTreeNode node)
 {
     string name = node.NodeName;
     var structInstance = node as StructInstance;
     if (structInstance != null && structInstance.SequenceIndex >= 0)
     {
         name = structInstance.SequenceIndex + ". " + name;
     }
     return name;
 }