Exemple #1
0
        private void ViewerOnEdgeAdded(object sender, EventArgs eventArgs)
        {
            var edge        = (Edge)sender;
            var form        = new Form();
            var tableLayout = new TableLayoutPanel {
                Dock = DockStyle.Fill
            };

            form.Controls.Add(tableLayout);

            // TODO: GetEdgeTypes or something
            foreach (var type in graph.GetNodeTypes())
            {
                if (type.InstanceMetatype != Repo.Metatype.Edge || type.IsAbstract)
                {
                    continue;
                }

                var edgeType = type as Repo.IEdge;

                tableLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 25));
                // TODO: We definitely need names for non-abstract edges. Maybe as attribute?
                var associationButton = new Button {
                    Text = "Link", Dock = DockStyle.Fill
                };
                associationButton.Click += (o, args) =>
                {
                    graph.CreateNewEdge(edgeType, edge);
                    viewer.Graph.AddPrecalculatedEdge(edge);
                    viewer.SetEdgeLabel(edge, edge.Label);
                    var ep = new EdgeLabelPlacement(viewer.Graph.GeometryGraph);
                    ep.Run();
                    viewer.Invalidate();
                    form.DialogResult = DialogResult.OK;
                };
                associationButton.Font = new Font(associationButton.Font.FontFamily, fontSize);
                tableLayout.Controls.Add(associationButton, 0, tableLayout.RowCount - 1);
                ++tableLayout.RowCount;
            }
            var result = form.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                viewer.Undo();
                viewer.Invalidate();
            }
        }
Exemple #2
0
        /// <summary>
        /// Changes an edge's label and updates the display
        /// </summary>
        /// <param name="e">The edge whose label has to be changed</param>
        /// <param name="newLabel">The new label</param>
        internal void RelabelEdge(Edge e, string newLabel)
        {
            if (e.Label == null)
            {
                e.Label = new Label(newLabel);
            }
            else
            {
                e.Label.Text = newLabel;
            }


            gViewer.SetEdgeLabel(e, e.Label);
            e.Label.GeometryLabel.InnerPoints = new List <Point>();
            var ep = new EdgeLabelPlacement(gViewer.Graph.GeometryGraph);

            ep.Run();
            gViewer.Graph.GeometryGraph.UpdateBoundingBox();
            gViewer.Invalidate();
        }