コード例 #1
0
ファイル: DataView.cs プロジェクト: hongha1412/structorian
 private void FillStructureTree(InstanceTree instanceTree)
 {
     foreach (InstanceTreeNode instance in instanceTree.Children)
     {
         AddInstanceNode(null, instance);
     }
 }
コード例 #2
0
 public void UpdateTree(ref Twinsanity.Instances INSTs, int Index)
 {
     InstanceTree.BeginUpdate();
     for (int i = 0; i <= INSTs._Item.Length - 1; i++)
         InstanceTree.Nodes.Add("ID: " + INSTs._Item[i].ID.ToString());
     InstanceTree.EndUpdate();
     IISIndex = Index;
 }
コード例 #3
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void LoadSibling()
        {
            InstanceTree tree = PrepareInstanceTree(
                "struct A { u8 a; sibling B; } struct B { u8 value; }",
                new byte[] { 17, 37 });

            Assert.AreEqual(1, tree.Children[0].Cells.Count);
            Assert.AreEqual(2, tree.Children.Count);
        }
コード例 #4
0
ファイル: DataView.cs プロジェクト: yole/structorian
        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);
            }
        }
コード例 #5
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void LoadSiblingDefault()
        {
            InstanceTree tree = PrepareInstanceTree(
                "struct A { u8 a; if (a > 0) { sibling; } }",
                new byte[] { 17, 0 });

            Assert.AreEqual(1, tree.Children[0].Cells.Count);
            Assert.AreEqual(2, tree.Children.Count);
            Assert.AreEqual(1, tree.Children[1].Cells.Count);
        }
コード例 #6
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void NodeName()
        {
            InstanceTree tree = PrepareInstanceTree(
                "struct A { enum8 e [enum=X]; nodename e; } enum X { q=12 }",
                new byte[] { 0x0C });
            InstanceTreeNode lastChangedNode = null;

            tree.NodeNameChanged += delegate(object sender, NodeNameChangedEventArgs e)
            {
                lastChangedNode = e.Node;
            };

            Assert.AreEqual(1, tree.Children [0].Cells.Count);
            Assert.AreEqual("q", tree.Children [0].NodeName);
            Assert.AreSame(tree.Children [0], lastChangedNode);
        }
コード例 #7
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void NotifyChild()
        {
            InstanceTree tree = PrepareInstanceTree(
                "struct A { u8 a; child B [offset=a]; } struct B { u8 value; } ",
                new byte[] { 2, 0, 17, 37 });
            InstanceTreeNode lastAddParent = null;
            InstanceTreeNode lastAddChild  = null;

            tree.InstanceAdded += delegate(object sender, InstanceAddedEventArgs e)
            {
                lastAddParent = e.Parent;
                lastAddChild  = e.Child;
            };
            tree.Children [0].NeedChildren();
            Assert.AreSame(tree.Children [0], lastAddParent);
            Assert.AreSame(tree.Children [0].Children[0], lastAddChild);
        }
コード例 #8
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void NotifyFromGroupContainer()
        {
            InstanceTree tree = PrepareInstanceTree(
                "struct A { u8 a; child B [group=X]; } struct B { u8 value; } ",
                new byte[] { 2, 17, 37 });
            InstanceTreeNode groupInstance = tree.Children[0].Children [0];

            InstanceTreeNode lastAddParent = null;
            InstanceTreeNode lastAddChild  = null;

            tree.InstanceAdded += delegate(object sender, InstanceAddedEventArgs e)
            {
                lastAddParent = e.Parent;
                lastAddChild  = e.Child;
            };
            groupInstance.NeedChildren();
            Assert.AreSame(groupInstance, lastAddParent);
            Assert.AreSame(groupInstance.Children[0], lastAddChild);
        }
コード例 #9
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void Preload()
        {
            InstanceTree tree = PrepareInstanceTree(
                "[preload] struct A { u8 a; child B [offset=a]; } [preload] struct B { nodename (\"Q\"); u8 value; child C [offset=Parent.a]; } struct C { u8 value; nodename(\"W\"); }",
                new byte[] { 2, 0, 17, 37 });
            InstanceTreeNode lastAddParent = null;
            InstanceTreeNode lastAddChild  = null;

            tree.InstanceAdded += delegate(object sender, InstanceAddedEventArgs e)
            {
                lastAddParent = e.Parent;
                lastAddChild  = e.Child;
            };
            tree.Children[0].NeedData();
            Assert.AreSame(tree.Children[0], lastAddParent);
            Assert.AreSame(tree.Children[0].Children[0], lastAddChild);
            Assert.AreEqual("Q", lastAddChild.NodeName);
            tree.Children[0].Children[0].NeedChildren();
            Assert.AreEqual("W", tree.Children[0].Children[0].Children[0].NodeName);
        }
コード例 #10
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        [Test] public void NotifySiblingInGroup()
        {
            InstanceTree tree = PrepareInstanceTree(
                "struct A { u8 a; child B [group=q]; } struct B { u8 c; if (c != 0) { sibling; } }",
                new byte[] { 17, 37, 2 });
            InstanceTreeNode lastAddChild = null;

            tree.InstanceAdded += delegate(object sender, InstanceAddedEventArgs e)
            {
                lastAddChild = e.Child;
            };
            InstanceTreeNode a = tree.Children[0];

            a.NeedChildren();
            InstanceTreeNode q = a.Children[0];

            q.NeedChildren();
            Assert.AreEqual(1, q.Children.Count);
            InstanceTreeNode b = q.Children[0];

            b.NeedChildren();
            Assert.AreEqual(2, q.Children.Count);
            Assert.AreSame(q.Children[1], lastAddChild);
        }
コード例 #11
0
ファイル: LoadDataTest.cs プロジェクト: yole/structorian
        public static StructInstance PrepareInstance(string structDefs, byte[] data)
        {
            InstanceTree tree = PrepareInstanceTree(structDefs, data);

            return((StructInstance)tree.Children [0]);
        }
コード例 #12
0
ファイル: DataView.cs プロジェクト: hongha1412/structorian
        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];
            }
        }
コード例 #13
0
ファイル: DataView.cs プロジェクト: hongha1412/structorian
        private DataFile FindDataFile(InstanceTreeNode instance)
        {
            InstanceTree tree = instance.GetInstanceTree();

            return(_dataFiles.Find(f => f.InstanceTree == tree));
        }