Ejemplo n.º 1
0
        private void SetShape(GoLayer frontLayer, GoLabeledVertexWrapper imageNode)
        {
            var shape = ((GoShape)imageNode.Node.Background);

            shape.BrushColor = colorCode.GetColor(imageNode.LabledVertex.Opcode);
            shape.PenWidth   = 3;
            shape.PenColor   = ImageGraphNodes.Contains(imageNode) ? Color.Green : Color.Orange;
            if (shape.BrushColor.GetBrightness() < 0.4)
            {
                imageNode.Node.Label.TextColor = Color.White;
            }
            shape.Size          = new SizeF(400, 400);
            imageNode.Node.Text = imageNode.LabledVertex.Opcode.ToString() + " index:" + imageNode.LabledVertex.Index;
            if (imageNode.LabledVertex is CompoundedLabeledVertex)
            {
                imageNode.Node.Text += "multi";
            }
            imageNode.Node.Selected   += Node_Selected;
            imageNode.Node.UnSelected += Node_UnSelected;
        }
Ejemplo n.º 2
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++;
            }
        }