예제 #1
0
        private void NodePairingGraph_Load(object sender, EventArgs e)
        {
            // create a Go view (a Control) and add to the form
            myView             = new GoView();
            myView.AllowDelete = false;
            myView.AllowInsert = false;
            myView.AllowLink   = false;
            myView.Dock        = DockStyle.Fill;
            this.Controls.Add(myView);
            myView.Show();
            SourceGraphMethodLbl.Text = _pairings.SourceGraph.First().Method.Name;
            ImageGraphMethodlbl.Text  = _pairings.ImageGraph.First().Method.Name;

            var frontLayer = myView.Document.Layers.CreateNewLayerAfter(myView.Document.LinksLayer);
            int column     = 0;
            int row        = 0;

            foreach (var imageNodeLabled in _pairings.Pairings.Keys.OrderByDescending(x => _pairings.Pairings[x].Count))
            {
                if (row > 100)
                {
                    row     = 0;
                    column += 2;
                }
                var imageNodeWrapper = ImageGraphNodes.First(x => x.LabledVertex == imageNodeLabled);
                SetShape(frontLayer, imageNodeWrapper);
                frontLayer.Add(imageNodeWrapper.Node);
                imageNodeWrapper.Node.Location = new PointF(column * ColumnOffset, row * RowOffset);
                foreach (var sourceNodePairing in _pairings.Pairings[imageNodeWrapper.LabledVertex])
                {
                    var sourceLabledVertex = new GoLabeledVertexWrapper(new GoTextNodeHoverable(), sourceNodePairing.SourceGraphVertex);
                    SetShape(frontLayer, sourceLabledVertex);
                    frontLayer.Add(sourceLabledVertex.Node);
                    sourceLabledVertex.Node.Location = new PointF((column + 1) * ColumnOffset, row * RowOffset);
                    DrawPairingEdge(sourceLabledVertex.Node, imageNodeWrapper.Node, sourceNodePairing.NormalizedScore, frontLayer);
                    row++;
                }
                row++;
            }
        }
예제 #2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            this.Text = InstructionNodes[0].Method.Name;
            // create a Go view (a Control) and add to the form
            myView                    = new GoView();
            myView.KeyPress          += MyView_KeyPress;
            myView.SelectionFinished += Node_Selected;
            myView.AllowDelete        = false;
            myView.AllowInsert        = false;
            myView.AllowLink          = false;
            myView.Dock               = DockStyle.Fill;
            this.Controls.Add(myView);
            myView.Show();

            nodeWrappers =
                InstructionNodes
                .Select(x => new GoNodeWrapper(new GoTextNodeHoverable(), x))
                .ToList();

            var frontLayer = myView.Document.Layers.CreateNewLayerAfter(myView.Document.LinksLayer);

            foreach (var goNodeWrapper in nodeWrappers)
            {
                goNodeWrapper.Node.Selected   += Node_Selected;
                goNodeWrapper.Node.UnSelected += Node_UnSelected;
                goNodeWrapper.Index            = nodeWrappers.IndexOf(goNodeWrapper);
                var shape = ((GoShape)goNodeWrapper.Node.Background);
                if (goNodeWrapper.InstructionNode is NonInlineableCallInstructionNode)
                {
                    shape.BrushColor = Color.Black;
                }
                shape.BrushColor = colorCode.GetColor(goNodeWrapper.InstructionNode.Instruction.OpCode.Code);
                if (shape.BrushColor.GetBrightness() < 0.4)
                {
                    goNodeWrapper.Node.Label.TextColor = Color.White;
                }
                shape.Size = new SizeF(400, 400);

                if (goNodeWrapper.InstructionNode.InliningProperties.Inlined || goNodeWrapper.InstructionNode.MarkForDebugging)
                {
                    if (goNodeWrapper.InstructionNode.SingleUnitNodes.Count > 0 || goNodeWrapper.InstructionNode.StackPopCount > 0)
                    {
                        goNodeWrapper.Node.Shape.PenColor = Color.Red;
                    }
                    else
                    {
                        goNodeWrapper.Node.Shape.PenColor = Color.Blue;
                    }
                    goNodeWrapper.Node.Shape.PenWidth = 3;
                    goNodeWrapper.Node.ToolTipText    = goNodeWrapper.InstructionNode.Method.FullName + "***";
                }

                goNodeWrapper.Node.Text = goNodeWrapper.InstructionNode.Instruction.OpCode.Code.ToString() + " index:" + goNodeWrapper.InstructionNode.InstructionIndex + " offset:" + goNodeWrapper.InstructionNode.Instruction.Offset + " ";

                if (new[] { Code.Call, Code.Calli, Code.Callvirt }.Contains(
                        goNodeWrapper.InstructionNode.Instruction.OpCode.Code))
                {
                    goNodeWrapper.Node.Text += ((MethodReference)goNodeWrapper.InstructionNode.Instruction.Operand).FullName ?? " ";
                }
                else if (goNodeWrapper.InstructionNode is FunctionArgNodeBase)
                {
                    //TODO remove
                    var ArgInstWrapper = (FunctionArgNodeBase)goNodeWrapper.InstructionNode;
                    goNodeWrapper.Node.Text += " " + ArgInstWrapper.ArgName + " " + ArgInstWrapper.ArgIndex;
                }
                else if (goNodeWrapper.InstructionNode.Instruction.Operand != null)
                {
                    //TODO remove
                    goNodeWrapper.Node.Text += goNodeWrapper.InstructionNode.Instruction.Operand.ToString();
                }

                if (goNodeWrapper.InstructionNode.InliningProperties.Recursive)
                {
                    //TODO remove
                    //goNodeWrapper.Node.Text += " RecIndex:" + goNodeWrapper.InstructionNode.InliningProperties.RecursionInstanceIndex;
                    //goNodeWrapper.Node.Text += " Recursive:" + goNodeWrapper.InstructionNode.InliningProperties.CallSequence;
                }
                frontLayer.Add(goNodeWrapper.Node);
            }
            //SetCoordinates(nodeWrappers, int.Parse(SetHightTxt.Text), int.Parse(SetWidthTxt.Text));
            SetCoordinates(nodeWrappers);
            DrawLinks(myView);
        }