Beispiel #1
0
        private void tree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            hbMain.Highlights.Clear();
            contextTreeDump.Enabled = false;
            if (e.Node.Level == 0)
            {
                if (!(e.Node is RootInfoNode))
                {
                    return;
                }

                RootInfoNode rin = (RootInfoNode)e.Node;
                if (!File.Exists(rin.FilePath))
                {
                    throw new FileNotFoundException();
                }

                hbMain.ReadFile(rin.FilePath);
                fileloaded = rin.FilePath;

                double h = rnd.NextDouble();
                int    r, g, b;
                foreach (InfoNode inode in e.Node.Nodes)
                {
                    HSV.ToRGB(h * 360, 1.00d, 1d, out r, out g, out b);
                    hbMain.Highlights.Add(new HexBoxLib.Highlight((int)inode.DataStart, (int)inode.DataEnd, Color.FromArgb(r, g, b)));

                    //do
                    //{
                    h += Root.GOLDEN_RATIO;
                    h %= 1;
                    //} while (h > 0.15 && h < 0.525);
                }

                hbMain.Invalidate();

                Bridge.ShowInfo(rin.IType, rin.Info);
            }
            else
            {
                if (!(e.Node is InfoNode))
                {
                    return;
                }
                InfoNode inode = (InfoNode)e.Node;

                if (inode.IType == InfoType.Binary || inode.IType == InfoType.BinaryMainFocus)
                {
                    contextTreeDump.Enabled = true;
                }

                /* Get root node */
                TreeNode root   = this.tree.SelectedNode;
                TreeNode uncomp = null;
                while (root.Level > 0)
                {
                    root = root.Parent;
                    if (uncomp == null && root is InfoNode && ((InfoNode)root).IType == InfoType.BinaryMainFocus)
                    {
                        uncomp = root;
                    }
                }

                if (uncomp != null)
                {
                    this.hbMain.ReadBytes((byte[])((InfoNode)uncomp).Info);
                }
                else
                {
                    this.hbMain.ReadFile(((RootInfoNode)root).FilePath);
                }
                //TreeNode root = e.Node;
                //do
                //{
                //    root = root.Parent;
                //} while (root.Level > 0);

                //if (!(root is RootInfoNode)) return;

                //RootInfoNode rin = (RootInfoNode)root;
                //if (fileloaded != rin.FilePath)
                //{
                //    if (!File.Exists(rin.FilePath)) throw new FileNotFoundException();

                //    hbMain.ReadFile(rin.FilePath);
                //    fileloaded = rin.FilePath;
                //}

                Color ghost = Color.FromArgb(0xDD, 0xDD, 0xDD);
                foreach (InfoNode irn in inode.Parent.Nodes)
                {
                    hbMain.Highlights.Add(new HexBoxLib.Highlight((int)irn.DataStart, (int)irn.DataEnd, ghost));
                }

                hbMain.Highlights.Add(new HexBoxLib.Highlight((int)inode.DataStart, (int)inode.DataEnd, inode.HighlightColor));
                hbMain.ScrollTo((int)(inode.DataStart >> 4));
                hbMain.Invalidate();

                Bridge.ShowInfo(inode.IType, inode.Info);
            }
        }
Beispiel #2
0
        private void tree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            hexBox1.Highlights.Clear();
            if (e.Node.Level == 0)
            {
                if (!(e.Node is RootInfoNode))
                {
                    return;
                }

                RootInfoNode rin = (RootInfoNode)e.Node;
                if (!File.Exists(rin.FilePath))
                {
                    throw new FileNotFoundException();
                }

                hexBox1.ReadFile(rin.FilePath);
                fileloaded = rin.FilePath;

                double h = rnd.NextDouble();
                int    r, g, b;
                foreach (InfoNode inode in e.Node.Nodes)
                {
                    HSV.ToRGB(h * 360, 1.00d, 1d, out r, out g, out b);
                    hexBox1.Highlights.Add(new HexBoxLib.Highlight((int)inode.DataStart, (int)inode.DataEnd, Color.FromArgb(r, g, b)));

                    //do
                    //{
                    h += Root.GOLDEN_RATIO;
                    h %= 1;
                    //} while (h > 0.15 && h < 0.525);
                }

                //hexBox1.ScrollTo(0);
                hexBox1.Invalidate();

                Bridge.ShowInfo(rin.IType, rin.Info);
            }
            else
            {
                if (!(e.Node is InfoNode))
                {
                    return;
                }
                InfoNode inode = (InfoNode)e.Node;

                TreeNode root = e.Node;
                do
                {
                    root = root.Parent;
                } while (root.Level > 0);

                if (!(root is RootInfoNode))
                {
                    return;
                }

                RootInfoNode rin = (RootInfoNode)root;
                if (fileloaded != rin.FilePath)
                {
                    if (!File.Exists(rin.FilePath))
                    {
                        throw new FileNotFoundException();
                    }

                    hexBox1.ReadFile(rin.FilePath);
                    fileloaded = rin.FilePath;
                }

                Color ghost = Color.FromArgb(0xDD, 0xDD, 0xDD);
                foreach (InfoNode irn in inode.Parent.Nodes)
                {
                    hexBox1.Highlights.Add(new HexBoxLib.Highlight((int)irn.DataStart, (int)irn.DataEnd, ghost));
                }

                hexBox1.Highlights.Add(new HexBoxLib.Highlight((int)inode.DataStart, (int)inode.DataEnd, inode.HighlightColor));
                hexBox1.ScrollTo((int)(inode.DataStart >> 4));
                hexBox1.Invalidate();

                //foreach (Panel p in infopanels)
                //    p.Visible = false;

                //switch (inode.IType)
                //{
                //    case InfoType.Generic:
                //        lblInfoGenericTitle.Text = ((GenericInfo)inode.Info).Title;
                //        txtInfoGenericBody.Text = ((GenericInfo)inode.Info).Body;
                //        pInfoGeneric.Visible = true;
                //        break;
                //}

                Bridge.ShowInfo(inode.IType, inode.Info);
            }
        }