Exemplo n.º 1
0
    public Microsoft.Msagl.GraphViewerGdi.GViewer BuildGraph(List <PrimaryGraph.Verticle> new_graph, string verticle)
    {
        //create a viewer object
        Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
        //create a graph object
        Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
        //create the graph content
        for (int i = 0; i < new_graph.Count; i++)
        {
            for (int j = 0; j < new_graph[i].connections.Count; j++)
            {
                string verticle_out = new_graph[i].verticle_id;
                string verticle_in  = new_graph[i].connections[j].connectedTo;
                if (verticle_out == verticle || verticle_in == verticle)
                {
                    graph.AddEdge(verticle_out, new_graph[i].connections[j].strength.ToString(), verticle_in);
                }
            }
        }

        //graph.FindNode(verticle).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
        viewer.Graph  = graph;
        viewer.Height = 300;
        viewer.Width  = 930;

        return(viewer);
    }
Exemplo n.º 2
0
        Rectangle CreateRectForRubberEdge()
        {
            var    rect = new BBox(rubberLineStart, RubberLineEnd);
            double w    = gViewer.LineThicknessForEditing;
            var    del  = new P2(-w, w);

            rect.Add(rect.LeftTop + del);
            rect.Add(rect.RightBottom - del);
            return(GViewer.CreateScreenRectFromTwoCornersInTheSource(rect.LeftTop, rect.RightBottom));
        }
        private static void DisplayGraph(Graph g, Form form)
        {
            var gviewer = new GViewer {
                BuildHitTree = false
            };

            form.SuspendLayout();
            form.Controls.Add(gviewer);
            gviewer.Dock = DockStyle.Fill;


            var b = new Button {
                Text = "Save DebugCurves"
            };

            b.Click    += BClick;
            b.Left      = Screen.PrimaryScreen.WorkingArea.Size.Width * 3 / 8;
            b.AutoSize  = true;
            b.ForeColor = System.Drawing.Color.Blue;
            form.Controls.Add(b);

            var l = new System.Windows.Forms.Label()
            {
                Text = "no object"
            };

            l.Name     = "label";
            l.Dock     = DockStyle.Right;
            l.AutoSize = true;
            form.Controls.Add(l);
            gviewer.SendToBack();



            var statusStrip  = new StatusStrip();
            var toolStribLbl = new ToolStripStatusLabel("test");

            statusStrip.Items.Add(toolStribLbl);
            form.Controls.Add(statusStrip);
            form.ResumeLayout();
            gviewer.ObjectUnderMouseCursorChanged += DisplayGeometryGraph_ObjectUnderMouseCursorChanged;
            gviewer.MouseMove            += Draw.GviewerMouseMove;
            gviewer.NeedToCalculateLayout = false;
            gviewer.MouseClick           += GviewerMouseClick;

            form.Size = new Size(Screen.PrimaryScreen.WorkingArea.Size.Width * 3 / 4,
                                 Screen.PrimaryScreen.WorkingArea.Size.Height * 3 / 4);
            form.StartPosition = FormStartPosition.CenterScreen;
            form.TopLevel      = true;
            gviewer.Graph      = g;

            form.Text = Process.GetCurrentProcess().MainModule.FileName;

            form.ShowDialog();
        }
        public FormForCellTypeRelationships(FormForSimuGenerator Parent)
        {
            InitializeComponent();
            this.Parent = Parent;

            GraphView = new GViewer();
            graph = new Microsoft.Msagl.Drawing.Graph("graph");
            GraphView.Size = new System.Drawing.Size(panel.Width, panel.Height);
            GraphView.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);

            RefreshDisplay();
        }
 internal SaveInVectorFormatForm(GViewer gViewerControl) {
     InitializeComponent();
     saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     saveTotalView.Checked = !gViewerControl.SaveCurrentViewInImage;
     gViewer = gViewerControl;
     saveCurrentView.CheckedChanged += saveCurrentView_CheckedChanged;
     toolTip.SetToolTip(saveInTextBox, "The default file format is SVG");
     Text = "Save in the SVG format";
     saveInTextBox.Text = "*.svg";
     AcceptButton=okButton;
     CancelButton = cancelButton;            
 }
 internal SaveInVectorFormatForm(GViewer gViewerControl)
 {
     InitializeComponent();
     this.saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     this.saveTotalView.Checked   = !gViewerControl.SaveCurrentViewInImage;
     this.gViewer      = gViewerControl;
     this.CancelButton = this.cancelButton;
     this.saveCurrentView.CheckedChanged += new EventHandler(saveCurrentView_CheckedChanged);
     this.toolTip.SetToolTip(this.saveInTextBox, "The default file format is Emf");
     this.Text = "Save in EMF of WMF format";
     this.saveInTextBox.Text = "*.emf";
 }
Exemplo n.º 7
0
        internal void StopDrawingRubberEdge()
        {
            if (CurrentRubberEdge != null)
            {
                GViewer.Invalidate(
                    GViewer.CreateScreenRectFromTwoCornersInTheSource(
                        CurrentRubberEdge.BoundingBox.LeftTop,
                        CurrentRubberEdge.BoundingBox.RightBottom));
            }

            CurrentRubberEdge = null;
        }
Exemplo n.º 8
0
 public GraphPanel(State start)
 {
     viewer = new GViewer();
     Graph = new Graph("graph");
     Graph.AddNodes(start);
     viewer.ToolBarIsVisible = false;
     viewer.Graph = Graph;
     viewer.Dock = DockStyle.Fill;
     var magnificationCoeff = 560.0 / viewer.Height;
     Height = 560;
     Width = (int)(viewer.Width * magnificationCoeff);
     Controls.Add(viewer);
 }
 internal SaveInVectorFormatForm(GViewer gViewerControl)
 {
     InitializeComponent();
     saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     saveTotalView.Checked   = !gViewerControl.SaveCurrentViewInImage;
     gViewer = gViewerControl;
     saveCurrentView.CheckedChanged += saveCurrentView_CheckedChanged;
     toolTip.SetToolTip(saveInTextBox, "The default file format is SVG");
     Text = "Save in the SVG format";
     saveInTextBox.Text = "*.svg";
     AcceptButton       = okButton;
     CancelButton       = cancelButton;
 }
Exemplo n.º 10
0
        internal void DrawRubberEdge(EdgeGeometry edgeGeometry)
        {
            BBox rectToInvalidate = edgeGeometry.BoundingBox;

            if (CurrentRubberEdge != null)
            {
                BBox b = CurrentRubberEdge.BoundingBox;
                rectToInvalidate.Add(b);
            }
            CurrentRubberEdge = edgeGeometry;
            GViewer.Invalidate(GViewer.CreateScreenRectFromTwoCornersInTheSource(rectToInvalidate.LeftTop,
                                                                                 rectToInvalidate.RightBottom));
        }
 internal SaveInVectorFormatForm(GViewer gViewerControl)
 {
     InitializeComponent();
     saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     saveTotalView.Checked   = !gViewerControl.SaveCurrentViewInImage;
     gViewer = gViewerControl;
     saveCurrentView.CheckedChanged += saveCurrentView_CheckedChanged;
     toolTip.SetToolTip(saveInTextBox, "Стандартный формат файла: .svg");
     Text = "Сохранить в .svg";
     saveInTextBox.Text = "*.svg";
     AcceptButton       = okButton;
     CancelButton       = cancelButton;
 }
Exemplo n.º 12
0
        public void drawGraph()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");

            for (int i = 0; i < nodes.Count; i++)
            {
                Console.WriteLine("i:" + i);
                Console.WriteLine("children count: " + nodes[i].children.Count);
                for (int j = 0; j < nodes[i].children.Count; j++)
                {
                    Console.WriteLine("j:" + j);
                    Console.WriteLine("Parent node: " + nodes[i].getNodeName());
                    Console.WriteLine("node name: " + nodes[i].children[j].getNodeName());
                    int flow    = nodes[i].edges[j][0];
                    var newEdge = graph.AddEdge(nodes[i].getNodeName(), nodes[i].children[j].getNodeName());
                    Microsoft.Msagl.Drawing.Node childNode = graph.FindNode(nodes[i].getNodeName());
                    string cap = nodes[i].edges[j][0].ToString() + "/" + nodes[i].edges[j][1].ToString();
                    newEdge.LabelText        = cap;
                    childNode.Attr.Shape     = Microsoft.Msagl.Drawing.Shape.Circle;
                    childNode.Attr.FillColor = Microsoft.Msagl.Drawing.Color.White;
                    if (flow > 0)
                    {
                        string tempStringg = nodes[i].getNodeName() + nodes[i].children[j].getNodeName();
                        if (nameofnodes.Contains(tempStringg))
                        {
                            newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                        }
                        else
                        {
                            newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Orange;
                        }
                    }
                    else
                    {
                        newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Black;
                    }
                }
            }

            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.CurrentLayoutMethod = LayoutMethod.MDS;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
Exemplo n.º 13
0
        protected override void OnLoad(EventArgs e)
        {
            NetworkSelectBox.Text = "Seleccione Red";
            NetworkSelectBox.Items.Add("Red Simple");
            NetworkSelectBox.Items.Add("Red Media");
            NetworkSelectBox.Items.Add("Red Grande");
            NetworkSelectBox.Items.Add("Red Gigante");
            NetworkSelectBox.Items.Add("Red Masiva");
            NetworkSelectBox.Items.Add("Red Gargantua");

            _formViewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();

            Simulator = new InfectionSimulator(_simulationParameters);

            _formViewer.Graph = Simulator.SetCurrentNetworkSimulation("Red Simple");

            _formViewer.ToolBarIsVisible     = false;
            _formViewer.LayoutEditingEnabled = false;
            ////_formViewer.LayoutEditingEnabled = true;
            ////_formViewer.FitGraphBoundingBox();

            TextBoxAnalysis = ((RichTextBox)this.Controls.Find("AnalysisBox", true).First()).Lines;


            this.SuspendLayout();

            UpdateAnalysisTextBoxes();

            _formViewer.MouseClick += GraphPanel_MouseClick;
            _formViewer.Dock        = System.Windows.Forms.DockStyle.Fill;

            ////busco panel y agrego el viewer
            var panel = this.Controls.Find("GraphPanel", true).First();

            panel.Dock = DockStyle.Fill;
            panel.Controls.Add(_formViewer);

            InfectionChart = new Chart();
            InfectionChart.Series.Clear();

            var resultsPanel = this.Controls.Find("GraphResultsPanel", true).First();

            resultsPanel.Controls.Add(InfectionChart);
            InfectionChart.ChartAreas.Add(new ChartArea());
            InfectionChart.Legends.Add(new Legend("Infected Per Day"));


            this.ResumeLayout();
        }
 void ProcessPan(MouseEventArgs args)
 {
     if (ClientRectangle.Contains(args.X, args.Y))
     {
         if (args.Button == MouseButtons.Left)
         {
             gViewer.Transform[0, 2] = mouseDownTransform[0, 2] + args.X - mouseDownPoint.X;
             gViewer.Transform[1, 2] = mouseDownTransform[1, 2] + args.Y - mouseDownPoint.Y;
             gViewer.Invalidate();
         }
         else
         {
             GViewer.Hit(args);
         }
     }
 }
Exemplo n.º 15
0
        private void DrawZoomWindow(MouseEventArgs args)
        {
            mouseUpPoint.X = args.X;
            mouseUpPoint.Y = args.Y;

            if (this.NeedToEraseRubber)
            {
                DrawXORFrame();
            }

            if (ClientRectangle.Contains(PointToClient(Control.MousePosition)))
            {
                rubberRect = GViewer.RectFromPoints(PointToScreen(mouseDownPoint), PointToScreen(mouseUpPoint));
                DrawXORFrame();
            }
        }
Exemplo n.º 16
0
 public Form1()
 {
     InitializeComponent();
     GViewer gViewer = new GViewer() { Dock = DockStyle.Fill };
     SuspendLayout();
     Controls.Add(gViewer);
     ResumeLayout();
     Graph graph = new Graph();
     var sugiyamaSettings = (SugiyamaLayoutSettings)graph.LayoutAlgorithmSettings;
     sugiyamaSettings.NodeSeparation *= 2;
     graph.AddEdge("A", "B");
     graph.AddEdge("A", "C");
     graph.AddEdge("A", "D");
     graph.LayerConstraints.PinNodesToSameLayer(new[] { graph.FindNode("A"), graph.FindNode("B"), graph.FindNode("C") });
     gViewer.Graph = graph;
 }
 internal SaveViewAsImageForm(GViewer gViewerControl) {
     InitializeComponent();
     saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     saveTotalView.Checked = !gViewerControl.SaveCurrentViewInImage;
     gViewer = gViewerControl;
     CancelButton = cancelButton;
     imageScale.TickStyle = TickStyle.Both;
     imageScale.TickFrequency = 5;
     imageScale.Minimum = 10;
     imageScale.Maximum = 100;
     imageScale.Value = imageScale.Minimum;      
     SetScaleLabelTexts();
     imageScale.ValueChanged += imageScale_ValueChanged;
     saveCurrentView.CheckedChanged += saveCurrentView_CheckedChanged;
     toolTip.SetToolTip(saveInTextBox, "The default file format is JPG");
     saveInTextBox.Text = "*.jpg";
 }
Exemplo n.º 18
0
        public Form1()
        {
            InitializeComponent();
            gViewer = new GViewer() { Dock = DockStyle.Right, Width = this.Width - 160 };
            SuspendLayout();
            Controls.Add(gViewer);
            ResumeLayout();
            graph = new Graph();
            var sugiyamaSettings = (SugiyamaLayoutSettings)graph.LayoutAlgorithmSettings;
            sugiyamaSettings.NodeSeparation *= 2;

            gViewer.Graph = graph;
            loaded = true;

            reloadNodesCombobox();
            reloadEdgesCombobox();
        }
Exemplo n.º 19
0
 internal SaveViewAsImageForm(GViewer gViewerControl)
 {
     InitializeComponent();
     this.saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     this.saveTotalView.Checked   = !gViewerControl.SaveCurrentViewInImage;
     this.gViewer                  = gViewerControl;
     this.CancelButton             = this.cancelButton;
     this.imageScale.TickStyle     = TickStyle.Both;
     this.imageScale.TickFrequency = 5;
     this.imageScale.Minimum       = 10;
     this.imageScale.Maximum       = 100;
     this.imageScale.Value         = this.imageScale.Minimum;
     SetScaleLabelTexts();
     this.imageScale.ValueChanged        += new EventHandler(imageScale_ValueChanged);
     this.saveCurrentView.CheckedChanged += new EventHandler(saveCurrentView_CheckedChanged);
     this.toolTip.SetToolTip(this.saveInTextBox, "The default file format is JPG");
     this.saveInTextBox.Text = "*.jpg";
 }
 internal SaveViewAsImageForm(GViewer gViewerControl)
 {
     InitializeComponent();
     saveCurrentView.Checked = gViewerControl.SaveCurrentViewInImage;
     saveTotalView.Checked   = !gViewerControl.SaveCurrentViewInImage;
     gViewer                  = gViewerControl;
     CancelButton             = cancelButton;
     imageScale.TickStyle     = TickStyle.Both;
     imageScale.TickFrequency = 5;
     imageScale.Minimum       = 10;
     imageScale.Maximum       = 100;
     imageScale.Value         = imageScale.Minimum;
     SetScaleLabelTexts();
     imageScale.ValueChanged        += imageScale_ValueChanged;
     saveCurrentView.CheckedChanged += saveCurrentView_CheckedChanged;
     toolTip.SetToolTip(saveInTextBox, "The default file format is JPG");
     saveInTextBox.Text = "*.jpg";
 }
Exemplo n.º 21
0
        internal DEdge(DNode source, DNode target, DrawingEdge drawingEdgeParam, ConnectionToGraph connection,
                       GViewer gviewer) : base(gviewer) {
            DrawingEdge = drawingEdgeParam;
            Source = source;
            Target = target;

            if (connection == ConnectionToGraph.Connected) {
                if (source == target)
                    source.AddSelfEdge(this);
                else {
                    source.AddOutEdge(this);
                    target.AddInEdge(this);
                }
            }

            if (drawingEdgeParam.Label != null)
                Label = new DLabel(this, drawingEdge.Label, gviewer);
        }
Exemplo n.º 22
0
        protected override void OnMouseUp(MouseEventArgs args)
        {
            base.OnMouseUp(args);
            MsaglMouseEventArgs iArgs = CreateMouseEventArgs(args);

            gViewer.RaiseMouseUpEvent(iArgs);
            if (NeedToEraseRubber)
            {
                DrawXorFrame();
            }

            if (!iArgs.Handled)
            {
                if (gViewer.OriginalGraph != null && MouseDraggingMode == DraggingMode.WindowZoom)
                {
                    var    p = mouseDownPoint;
                    double f = Math.Max(Math.Abs(p.X - args.X), Math.Abs(p.Y - args.Y)) / GViewer.Dpi;
                    if (f > gViewer.ZoomWindowThreshold && zoomWindow)
                    {
                        mouseUpPoint = new Point(args.X, args.Y);
                        if (ClientRectangle.Contains(mouseUpPoint))
                        {
                            var r = GViewer.RectFromPoints(mouseDownPoint, mouseUpPoint);
                            r.Intersect(gViewer.DestRect);
                            if (GViewer.ModifierKeyWasPressed() == false)
                            {
                                mouseDownPoint.X = r.Left;
                                mouseDownPoint.Y = r.Top;
                                mouseUpPoint.X   = r.Right;
                                mouseUpPoint.Y   = r.Bottom;
                                P2     p1 = gViewer.ScreenToSource(mouseDownPoint);
                                P2     p2 = gViewer.ScreenToSource(mouseUpPoint);
                                double sc = Math.Min((double)ClientRectangle.Width / r.Width,
                                                     ClientRectangle.Height / (double)r.Height);
                                P2 center = 0.5f * (p1 + p2);
                                gViewer.SetTransformOnScaleAndCenter(sc, center);
                                Invalidate();
                            }
                        }
                    }
                }
            }
            zoomWindow = false;
        }
Exemplo n.º 23
0
        internal static void CreateDLabel(DObject parent, Drawing.Label label, out double width, out double height,
                                          GViewer viewer)
        {
            var dLabel = new DLabel(parent, label, viewer)
            {
                Font = new Font(label.FontName, (int)label.FontSize, (System.Drawing.FontStyle)(int) label.FontStyle)
            };

            StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height);

            if (width <= 0)
            {
                //this is a temporary fix for win7 where Measure fonts return negative lenght for the string " "
                StringMeasure.MeasureWithFont("a", dLabel.Font, out width, out height);
            }

            label.Width  = width;
            label.Height = height;
        }
Exemplo n.º 24
0
        public cFeedBackMessage Run()
        {
            this.CurrentPanel = new cExtendedControl();
            this.CurrentPanel.Title = this.Title;

            this.CurrentPanel.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
                                        | System.Windows.Forms.AnchorStyles.Left
                                        | System.Windows.Forms.AnchorStyles.Right);

            GViewer GraphView = new GViewer();

            GraphView.Graph = ComputeAndDisplayGraph(this.Input,false);
            GraphView.Dock = System.Windows.Forms.DockStyle.Fill;

               // this.panel.Controls.Add(GraphView);

            CurrentPanel.Controls.Add(GraphView);
            return base.FeedBackMessage;
        }
Exemplo n.º 25
0
        internal static DGraph CreateDGraphAndGeometryInfo(Graph drawingGraph, GeometryGraph geometryGraph,
                                                           GViewer viewer)
        {
            var dGraph = new DGraph(drawingGraph, viewer);
            //create dnodes and glee node boundary curves
            var nodeMapping = new Dictionary <GeometryNode, DNode>();

            if (geometryGraph.RootCluster != null)
            {
                foreach (var geomCluster in geometryGraph.RootCluster.AllClustersDepthFirstExcludingSelf())
                {
                    var   drawingNode = (Drawing.Node)geomCluster.UserData;
                    DNode dNode       = CreateDNodeAndSetNodeBoundaryCurveForSubgraph(drawingGraph, dGraph, geomCluster,
                                                                                      drawingNode, viewer);
                    nodeMapping[geomCluster] = dNode;
                }
            }

            foreach (GeometryNode geomNode in geometryGraph.Nodes)
            {
                var   drawingNode = (Drawing.Node)geomNode.UserData;
                DNode dNode       = CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, dGraph, geomNode, drawingNode, viewer);
                nodeMapping[geomNode] = dNode;
            }

            foreach (GeometryEdge gleeEdge in geometryGraph.Edges)
            {
                var dEdge = new DEdge(nodeMapping[gleeEdge.Source], nodeMapping[gleeEdge.Target],
                                      gleeEdge.UserData as DrawingEdge, ConnectionToGraph.Connected, viewer);
                dGraph.AddEdge(dEdge);
                DrawingEdge   drawingEdge = dEdge.Edge;
                Drawing.Label label       = drawingEdge.Label;

                if (label != null)
                {
                    double width, height;
                    CreateDLabel(dEdge, label, out width, out height, viewer);
                }
            }

            return(dGraph);
        }
Exemplo n.º 26
0
        private void btnFSM_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.WindowState = FormWindowState.Maximized;
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();

            //create a graph object
            var graph = new Graph("Finite State Machine");
            //create the graph content

            Dictionary <States.State, Node> dictionary = new Dictionary <States.State, Node>();

            foreach (States.State state in _lrZero.FiniteStateMachine.States)
            {
                Node node = new Node(state.ToStringCompact());
                node.Attr.FillColor = state.ReduceOnly ? Microsoft.Msagl.Drawing.Color.SeaGreen :
                                      (state.ShiftOnly ? Microsoft.Msagl.Drawing.Color.LightGreen : Microsoft.Msagl.Drawing.Color.Orange);

                dictionary.Add(state, node);
                graph.AddNode(node);
            }

            foreach (States.State state in _lrZero.FiniteStateMachine.States)
            {
                foreach (KeyValuePair <ISymbol, States.State> stateNextState in state.NextStates)
                {
                    var edge = new Edge(dictionary[state], dictionary[stateNextState.Value], ConnectionToGraph.Connected);
                    edge.LabelText = stateNextState.Key.ToString();
                    graph.AddPrecalculatedEdge(edge);
                }
            }

            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
Exemplo n.º 27
0
 public static Form CreateForm(GViewer gviewer) {
     GViewer=gviewer;
     var form = new Form();
     form.SuspendLayout();
     form.Controls.Add(gviewer);
     gviewer.Dock = DockStyle.Fill;
     gviewer.SendToBack();
     form.StartPosition = FormStartPosition.CenterScreen;
     form.Size = new System.Drawing.Size(Screen.PrimaryScreen.WorkingArea.Width,
                       Screen.PrimaryScreen.WorkingArea.Height);
     var statusStrip = new StatusStrip();
     var toolStribLbl = new ToolStripStatusLabel("test");
     statusStrip.Items.Add(toolStribLbl);
     form.Controls.Add(statusStrip);
     form.MainMenuStrip = GetMainMenuStrip();
     form.Controls.Add(form.MainMenuStrip);
     form.ResumeLayout();
     form.Load += form_Load;
     return form;
 }
Exemplo n.º 28
0
        public NetworkMapUserControl(CommonUi.NetworkContext networkContext)
        {
            InitializeComponent();
            _networkContext = networkContext;

            // Add MSAGL Graph control and register to click events.
            _dnsMappings        = new Dictionary <string, HashSet <string> >();
            _edges              = new HashSet <NetworkMapEdge>();
            _viewer             = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            _viewer.MouseClick += OnGraphMouseClick;
            _graph              = new Microsoft.Msagl.Drawing.Graph("graph");
            _viewer.Graph       = _graph;
            _viewer.Dock        = DockStyle.Fill;
            this.mainSplitContainer.Panel1.Controls.Add(_viewer);

            // There is a bit odd behavior of the controls in the second panel when the msagl is at
            // the first panel (not drawing the tree view). This force the second panel to refresh.
            this.mainSplitContainer.Panel2.Refresh();
            this.nodeTreeView.Click += (object sender, EventArgs e) => this.mainSplitContainer.Panel2.Refresh();
        }
        internal static GeometryGraph GetTestGeomGraph(string fileName)
        {
            GeometryGraph geomGraph = null;

            if (File.Exists(fileName))
            {
                int  line, column;
                bool msaglFile;
                var  dotGraph = CreateDrawingGraphFromFile(fileName, out line, out column, out msaglFile);

                var viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
                viewer.Graph = dotGraph;
                geomGraph    = dotGraph.GeometryGraph;
            }
            else
            {
                Console.WriteLine("Cannot find file '{0}'", fileName);
            }
            return(geomGraph);
        }
        private void DrawAutoma(AutomaFuzzy.Automa<Symbol> automma)
        {
            Graph graph = new Graph("Automa");
            //graph.GraphAttr.Backgroundcolor = Microsoft.Glee.Drawing.Color.Black;
            for (int i = 0; i < automma.States.Count; i++)
            {
                string str = automma.States[i].ToString();

                Node no = graph.AddNode(automma.States[i].Name);
                no.Attr.Shape = Shape.Box;
                no.LabelText = str;
            }

            foreach (var transition in automma.Transitions)
            {
                string symbol = ((CompilerWithFuzzy.AutomaFuzzy.Rules.SimpleIncludeRule<Symbol>)transition.Rule).Symbol.ToString();
                string label =
                    ((CompilerWithFuzzy.AutomaFuzzy.Rules.SimpleIncludeRule<Symbol>)transition.Rule).Symbol.ToString() +
                            " - " + transition.Rule.Pertinence.ToString();
                label = symbol;

                Edge arco = graph.AddEdge(transition.From.Name, label
                         , transition.To.Name);
                System.Drawing.Color c = Utils.GetColor(transition.Rule.Pertinence);
                var color = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
                arco.Attr.Color = color;
                //arco.Attr.Fontcolor = color;
                arco.Attr.AddStyle(Style.Bold);
                arco.Attr.LineWidth = 5;
            }

            GViewer viewer = new GViewer();
            viewer.NavigationVisible = false;
            viewer.OutsideAreaBrush = Brushes.White;
            viewer.ToolBarIsVisible = false;
            viewer.Graph = graph;
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            pnlAutoma.Controls.Clear();
            pnlAutoma.Controls.Add(viewer);
        }
Exemplo n.º 31
0
 private void ProcessPan(MouseEventArgs args)
 {
     if (ClientRectangle.Contains(args.X, args.Y))
     {
         if (args.Button == System.Windows.Forms.MouseButtons.Left)
         {
             double dx = (double)(args.X - mouseDownPoint.X);
             double dy = (double)(args.Y - mouseDownPoint.Y);
             dx /= gViewer.LocalScale;
             dy /= gViewer.LocalScale; //map it to real coord
             int dh = gViewer.ScaleFromSrcXToScroll(dx);
             int dv = gViewer.ScaleFromSrcYToScroll(dy);
             gViewer.HVal = mouseDownHVal - dh;
             gViewer.VVal = mouseDownVVal + dv;
             gViewer.Invalidate();
         }
         else
         {
             GViewer.Hit(args);
         }
     }
 }
        private void Draw(Automa<char> automa, int indexTable = -1)
        {
            Graph graphAutoma = new Graph("Automa");

            for (int i = 0; i < automa.States.Count; i++)
            {
                State<char> state = automa.States[i];
                Node no = graphAutoma.AddNode(state.Name);
                no.Attr.Shape = Shape.Circle;

                if (state.PertinenceFinal > 0)
                {
                    no.Attr.Shape = Shape.DoubleCircle;
                }
                if (indexTable > -1)
                {
                    System.Drawing.Color c = Utils.GetColor(regexFuzzy.TableAutomaProcessing[indexTable][i]);
                    no.Attr.FillColor = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
                }
                else if (state.PertinenceInitial > 0)
                {
                    no.Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightGray;
                }
            }
            foreach (var transition in automa.Transitions)
            {
                Edge arco = graphAutoma.AddEdge(transition.From.Name, transition.To.Name);
                arco.LabelText = transition.ToString();
            }
            GViewer viewer = new GViewer();
            viewer.NavigationVisible = false;
            viewer.OutsideAreaBrush = Brushes.White;
            viewer.ToolBarIsVisible = false;
            viewer.Graph = graphAutoma;
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            pnlAutoma.Controls.Clear();
            pnlAutoma.Controls.Add(viewer);
        }
        static void BClick(object sender, EventArgs e)
        {
            var     button  = sender as Button;
            GViewer gViewer = null;

            foreach (var f in (button.Parent as Form).Controls)
            {
                gViewer = f as GViewer;
                if (gViewer != null)
                {
                    break;
                }
            }
            if (gViewer == null)
            {
                MessageBox.Show("need to fix the debugging tool, sorry");
                return;
            }

            if (gViewer.Graph == null)
            {
                MessageBox.Show("graph is not set");
                return;
            }
            if (gViewer.Graph.DebugCurves == null)
            {
                MessageBox.Show("DebugCurves are not set");
                return;
            }

            var fileDialog = new SaveFileDialog();

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                DebugCurveCollection.WriteToFile(gViewer.Graph.DebugCurves, fileDialog.FileName);
            }
        }
Exemplo n.º 34
0
    public Microsoft.Msagl.GraphViewerGdi.GViewer BuildGraphBig(List <PrimaryGraph.Verticle> new_graph)
    {
        //create a viewer object
        Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
        //create a graph object
        Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
        //create the graph content
        for (int i = 0; i < new_graph.Count; i++)
        {
            for (int j = 0; j < new_graph[i].connections.Count; j++)
            {
                string verticle_out = new_graph[i].verticle_id;
                string verticle_in  = new_graph[i].connections[j].connectedTo;
                {
                    graph.AddEdge(verticle_out, new_graph[i].connections[j].strength.ToString(), verticle_in);
                }
            }
        }

        viewer.Graph = graph;
        viewer.ZoomF = 4;

        return(viewer);
    }
Exemplo n.º 35
0
        public void Display(VisualGraphGeneratedMessage message)
        {
            Controls.Clear();
            if(_gViewer != null) Controls.Remove(_gViewer); 
            _gViewer = new GViewer
                          {
                              Dock = DockStyle.Fill,
                              LayoutAlgorithmSettingsButtonVisible = false,
                              NavigationVisible = false,
                              ToolBarIsVisible = false,
                              SaveButtonVisible = false,
                              SaveGraphButtonVisible = false,
                              AutoSizeMode = AutoSizeMode.GrowOnly,
                              AutoScroll = false,
            };
            _gViewer.HorizontalScroll.Enabled = false;
            _gViewer.VerticalScroll.Enabled = false;
            _gViewer.HorizontalScroll.Visible = false;
            _gViewer.VerticalScroll.Visible = false;
            _gViewer.DoubleClick += AGLVisualizer_DoubleClick;
            if (_mode == DisplayMode.Dark)
            {

                BackColor = System.Drawing.Color.Black;
                _gViewer.OutsideAreaBrush = new SolidBrush(System.Drawing.Color.Black);
            }
            else
            {
                BackColor = System.Drawing.Color.LightGray;
                _gViewer.OutsideAreaBrush = new SolidBrush(System.Drawing.Color.LightGray);
            }
            _gViewer.CurrentLayoutMethod = LayoutMethod.UseSettingsOfTheGraph;
            _gViewer.Graph = BuildGraphFrom(message);
            Controls.Add(_gViewer);
            selectNode(FindSearchedNode(message).Id);
        }
Exemplo n.º 36
0
        /// <summary>
        /// creates DGraph from a precalculated drawing graph
        /// </summary>
        /// <param name="drawingGraph"></param>
        /// <param name="viewer">the owning viewer</param>
        /// <returns></returns>
        internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(Graph drawingGraph, GViewer viewer)
        {
            var dGraph = new DGraph(drawingGraph, viewer);

            //create dnodes and node boundary curves

            if (drawingGraph.RootSubgraph != null)
            {
                foreach (DrawingNode drawingNode in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf())
                {
                    var dNode = new DNode(drawingNode, viewer);
                    if (drawingNode.Label != null)
                    {
                        dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                    }
                    dGraph.AddNode(dNode);
                }
            }

            foreach (DrawingNode drawingNode in drawingGraph.Nodes)
            {
                var dNode = new DNode(drawingNode, viewer);
                if (drawingNode.Label != null)
                {
                    dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                }
                dGraph.AddNode(dNode);
            }


            foreach (DrawingEdge drawingEdge in drawingGraph.Edges)
            {
                dGraph.AddEdge(new DEdge(dGraph.GetNode(drawingEdge.SourceNode), dGraph.GetNode(drawingEdge.TargetNode),
                                         drawingEdge, ConnectionToGraph.Connected, viewer));
            }

            return(dGraph);
        }
Exemplo n.º 37
0
 internal DGraph(Graph drawingGraph, GViewer gviewer) : base(gviewer)
 {
     DrawingGraph = drawingGraph;
 }
Exemplo n.º 38
0
        public static void ReadGraphFromFile(string fileName, GViewer gViewer, bool verbose) {
            var tform = (TForm)gViewer.ParentForm;
            int eLine, eColumn;
            bool msaglFile;
            Graph graph = CreateDrawingGraphFromFile(fileName, out eLine, out eColumn, out msaglFile);
            tform.lastFileName = fileName;
            if (graph == null)
                MessageBox.Show(String.Format("{0}({1},{2}): cannot process the file", fileName, eLine, eColumn));

            else {

#if REPORTING
                graph.LayoutAlgorithmSettings.Reporting = Test.verbose;
#endif
                gViewer.FileName = fileName;
                Stopwatch sw = null;
                if (verbose) {
                    gViewer.AsyncLayout = false;
                    sw = new Stopwatch();
                    sw.Start();
                }
                
                if(gViewer.Graph!=null)
                    graph.LayoutAlgorithmSettings=gViewer.Graph.LayoutAlgorithmSettings;

                gViewer.Graph = graph;
                if (sw != null) {
                    sw.Stop();
                    Console.WriteLine("layout done for {0} ms", (double)sw.ElapsedMilliseconds / 1000);
                }
            }
        }
Exemplo n.º 39
0
        public void SetGViewer(GViewer gviewer) {

            GViewer=gviewer;
            SuspendLayout();
            Controls.Add(gviewer);
            gviewer.Dock = DockStyle.Fill;
            gviewer.SendToBack();
            StartPosition = FormStartPosition.CenterScreen;
            Size = new Size(Screen.PrimaryScreen.WorkingArea.Width,
                                                Screen.PrimaryScreen.WorkingArea.Height);

            var statusStrip = new StatusStrip();
            var toolStribLbl = new ToolStripStatusLabel("test");
            statusStrip.Items.Add(toolStribLbl);
            Controls.Add(statusStrip);
            MainMenuStrip = GetMainMenuStrip();
            Controls.Add(MainMenuStrip);
            SetMonotonicityCoefficientTrackBar();
            ResumeLayout();
            gviewer.GraphChanged += gviewer_GraphChanged;            
        }
/// <summary>
/// constructor
/// </summary>
/// <param name="viewer"></param>
        protected DObject(GViewer viewer) {
            Viewer = viewer;
        }
Exemplo n.º 41
0
        internal static DNode CreateDNodeAndSetNodeBoundaryCurve(Graph drawingGraph, DGraph dGraph, GeometryNode geomNode,
                                                                 DrawingNode drawingNode, GViewer viewer)
        {
            double width  = 0;
            double height = 0;
            var    dNode  = new DNode(drawingNode, viewer);

            dGraph.AddNode(dNode);
            Drawing.Label label = drawingNode.Label;
            if (label != null)
            {
                CreateDLabel(dNode, label, out width, out height, viewer);
                width  += 2 * dNode.DrawingNode.Attr.LabelMargin;
                height += 2 * dNode.DrawingNode.Attr.LabelMargin;
            }
            if (width < drawingGraph.Attr.MinNodeWidth)
            {
                width = drawingGraph.Attr.MinNodeWidth;
            }
            if (height < drawingGraph.Attr.MinNodeHeight)
            {
                height = drawingGraph.Attr.MinNodeHeight;
            }

            // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle
            // so that it can be used with ellipses too.
            //if (drawingNode.Attr.Shape == Shape.DoubleCircle)
            //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio;
            ICurve curve;

            if (drawingNode.NodeBoundaryDelegate != null &&
                (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) != null)
            {
                geomNode.BoundaryCurve = curve;
            }
            else if (geomNode.BoundaryCurve == null)
            {
                geomNode.BoundaryCurve =
                    NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height);
            }
            return(dNode);
        }
Exemplo n.º 42
0
        internal static DNode CreateDNodeAndSetNodeBoundaryCurve(Graph drawingGraph, DGraph dGraph, GeometryNode geomNode,
                                                                 DrawingNode drawingNode, GViewer viewer){
            double width = 0;
            double height = 0;
            var dNode = new DNode(drawingNode, viewer);
            dGraph.AddNode(dNode);
            Drawing.Label label = drawingNode.Label;
            if (label != null){
                CreateDLabel(dNode, label, out width, out height, viewer);
                width += 2*dNode.DrawingNode.Attr.LabelMargin;
                height += 2*dNode.DrawingNode.Attr.LabelMargin;
            }
            if (width < drawingGraph.Attr.MinNodeWidth)
                width = drawingGraph.Attr.MinNodeWidth;
            if (height < drawingGraph.Attr.MinNodeHeight)
                height = drawingGraph.Attr.MinNodeHeight;

            // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle
            // so that it can be used with ellipses too.
            //if (drawingNode.Attr.Shape == Shape.DoubleCircle)
            //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio;
            ICurve curve;
            if (drawingNode.NodeBoundaryDelegate != null &&
                (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) != null)
                geomNode.BoundaryCurve = curve;
            else if (geomNode.BoundaryCurve == null)
                geomNode.BoundaryCurve =
                    NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height);
            return dNode;
        }
Exemplo n.º 43
0
        internal static DGraph CreateDGraphAndGeometryInfo(Graph drawingGraph, GeometryGraph geometryGraph,
                                                           GViewer viewer) {
            var dGraph = new DGraph(drawingGraph, viewer);
            //create dnodes and glee node boundary curves
            var nodeMapping = new Dictionary<GeometryNode, DNode>();
            if (geometryGraph.RootCluster != null)
                foreach (var geomCluster in geometryGraph.RootCluster.AllClustersDepthFirstExcludingSelf()) {
                    var drawingNode = (Drawing.Node) geomCluster.UserData;
                    DNode dNode = CreateDNodeAndSetNodeBoundaryCurveForSubgraph(drawingGraph, dGraph, geomCluster,
                                                                                drawingNode, viewer);
                    nodeMapping[geomCluster] = dNode;
                }

            foreach (GeometryNode geomNode in geometryGraph.Nodes) {
                var drawingNode = (Drawing.Node) geomNode.UserData;
                DNode dNode = CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, dGraph, geomNode, drawingNode, viewer);
                nodeMapping[geomNode] = dNode;
            }

            foreach (GeometryEdge gleeEdge in geometryGraph.Edges) {
                var dEdge = new DEdge(nodeMapping[gleeEdge.Source], nodeMapping[gleeEdge.Target],
                                      gleeEdge.UserData as DrawingEdge, ConnectionToGraph.Connected, viewer);
                dGraph.AddEdge(dEdge);
                DrawingEdge drawingEdge = dEdge.Edge;
                Drawing.Label label = drawingEdge.Label;

                if (label != null) {
                    double width, height;
                    CreateDLabel(dEdge, label, out width, out height, viewer);
                }
            }

            return dGraph;
        }
Exemplo n.º 44
0
        internal static void CreateDLabel(DObject parent, Drawing.Label label, out double width, out double height,
                                          GViewer viewer){
            var dLabel = new DLabel(parent, label, viewer){Font = new Font(label.FontName, (int)label.FontSize)};
            StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height);

            if (width <= 0)
                //this is a temporary fix for win7 where Measure fonts return negative lenght for the string " "
                StringMeasure.MeasureWithFont("a", dLabel.Font, out width, out height);

            label.Width = width;
            label.Height = height;
        }
Exemplo n.º 45
0
        /// <summary>
        /// creates DGraph from a precalculated drawing graph
        /// </summary>
        /// <param name="drawingGraph"></param>
        /// <param name="viewer">the owning viewer</param>
        /// <returns></returns>
        internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(Graph drawingGraph, GViewer viewer){
            var dGraph = new DGraph(drawingGraph, viewer);
            //create dnodes and node boundary curves

            if (drawingGraph.RootSubgraph != null)
                foreach (DrawingNode drawingNode in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf())
                {
                    var dNode = new DNode(drawingNode, viewer);
                    if (drawingNode.Label != null)
                        dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                    dGraph.AddNode(dNode);
                }

            foreach (DrawingNode drawingNode in drawingGraph.Nodes){
                var dNode = new DNode(drawingNode, viewer);
                if (drawingNode.Label != null)
                    dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                dGraph.AddNode(dNode);
            }

            
            foreach (DrawingEdge drawingEdge in drawingGraph.Edges)
                dGraph.AddEdge(new DEdge(dGraph.GetNode(drawingEdge.SourceNode), dGraph.GetNode(drawingEdge.TargetNode),
                                      drawingEdge, ConnectionToGraph.Connected, viewer));

            return dGraph;
        }
Exemplo n.º 46
0
 static void ProcessFile(string fileName, ArgsParser.ArgsParser argsParser, GViewer gViewer, ref int nOfBugs) {
     Console.WriteLine("processing " + fileName);
     try {
         string extension = Path.GetExtension(fileName);
         if (extension == ".msagl")
             ProcessMsaglFile(fileName, argsParser);
         else if (extension == ".dot") {
             ProcessDotFile(gViewer, argsParser, fileName);
         }
         else if (extension == ".geom") {
             ProcessMsaglGeomFile(fileName, argsParser);
         }
     }
     catch (Exception e) {
         nOfBugs++;
         Console.WriteLine("bug " + nOfBugs);
         Console.WriteLine(e.ToString());
     }
 }
Exemplo n.º 47
0
 internal DNode(DrawingNode drawingNodeParam, GViewer gviewer) : base(gviewer)
 {
     DrawingNode = drawingNodeParam;
 }
Exemplo n.º 48
0
        static void ProcessDotFile(GViewer gviewer, ArgsParser.ArgsParser argsParser, string dotFileName) {
            int line;
            int col;
            string msg;
            Graph graph = Parser.Parse(dotFileName, out line, out col, out msg);
            if (graph == null) {
                Console.WriteLine("{0}({1},{2}): error: {3}", dotFileName, line, col, msg);
                Environment.Exit(1);
            }
            if (argsParser.OptionIsUsed(RecoverSugiyamaTestOption)) {
                gviewer.CalculateLayout(graph);
                graph.GeometryGraph.AlgorithmData = null;
                LayeredLayout.RecoverAlgorithmData(graph.GeometryGraph);

                Node node = graph.GeometryGraph.Nodes[1];
                node.BoundaryCurve = node.BoundaryCurve.Transform(new PlaneTransformation(3, 0, 0, 0, 3, 0));

                LayeredLayout.IncrementalLayout(graph.GeometryGraph, node);
                gviewer.NeedToCalculateLayout = false;
                gviewer.Graph = graph;
                gviewer.NeedToCalculateLayout = true;
                return;
            }

            if (argsParser.OptionIsUsed(MdsOption))
                graph.LayoutAlgorithmSettings = new MdsLayoutSettings();
            else if (argsParser.OptionIsUsed(FdOption))
                graph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings();

            if (argsParser.OptionIsUsed(BundlingOption)) {
                graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling;
                BundlingSettings bs = GetBundlingSettings(argsParser);
                graph.LayoutAlgorithmSettings.EdgeRoutingSettings.BundlingSettings = bs;
                string ink = argsParser.GetValueOfOptionWithAfterString(InkImportanceOption);
                if (ink != null) {
                    double inkCoeff;
                    if (double.TryParse(ink, out inkCoeff)) {
                        bs.InkImportance = inkCoeff;
                        BundlingSettings.DefaultInkImportance = inkCoeff;
                    }
                    else {
                        Console.WriteLine("cannot parse {0}", ink);
                        Environment.Exit(1);
                    }
                }

                string esString = argsParser.GetValueOfOptionWithAfterString(EdgeSeparationOption);
                if (esString != null) {
                    double es;
                    if (double.TryParse(esString, out es)) {
                        BundlingSettings.DefaultEdgeSeparation = es;
                        bs.EdgeSeparation = es;
                    }
                    else {
                        Console.WriteLine("cannot parse {0}", esString);
                        Environment.Exit(1);
                    }
                }
            }


            gviewer.Graph = graph;
        }
Exemplo n.º 49
0
        static void Main(string[] args) {
            var listFileNames = new List<string>();
            var geomFileNames = new List<string>();
            var dotFileSpecs = new List<string>();
            bool show = true;
            EdgeRoutingMode edgeRoutingMode = EdgeRoutingMode.SugiyamaSplines;
            bool useSparseVisibilityGraph = false;
            bool useObstacleRectangles = false;
#if DEBUG
            DisplayGeometryGraph.SetShowFunctions();
#endif
            const string badEdgeOption = "-edge";
            const string mdsOption = "-mds";
            const string initialLayoutOption = "-initl";

            const string phyloOption = "-phylo";
            bool phylo = false;

            const string multiedges = "-multi";
            bool multiedgesTest = false;

            const string testSaveOption = "-save";
            bool testSave = false;


            const string testConvexHullString = "-convexHull";
            bool testConvexHull = false;
            bool bundling = false;

            double bendPenalty = SsstRectilinearPath.DefaultBendPenaltyAsAPercentageOfDistance;

            int fileReps = 1;
            int randomShifts = 0;
            bool showForm = true;
            try {
                for (int iarg = 0; iarg < args.Length; ++iarg) {
                    string s = args[iarg].ToLower();

                    if ("converttogeom" == s) {
                        if (iarg > (args.Length - 3))
                            throw new ApplicationException(
                                "{0} option requires input .dot filename and output .geom filename");
                        ConvertDotToGeom(args[iarg + 1], args[iarg + 2]);
                        return;
                    }

                    if (s == "-devTrace") {
#if DEVTRACE
                        ++iarg;
                        if (iarg >= args.Length) {      // require one value
                            throw new ApplicationException("Missing filename for -" + s);
                        }

#if MSAGL_INTERNALS_NOT_VISIBLE
                        // Copied the one line from this method here because of access issues, signing, etc.
                        // with InternalsVisibleTo.
                        //DevTrace.AddListenerToFile(args[iarg]);
#else
                        // Use File.Create to overwrite any existing file.
                        Trace.Listeners.Add(new TextWriterTraceListener(File.Create(args[iarg])));
#endif

#else
                        Console.WriteLine("-devtrace requires the DEVTRACE build configuration");
                        return;
#endif
                    }

                    // Start with some specific tests that we'll just pass arguments to.
                    // These are not "-" prefixed.
                    if ("testbinaryqueue" == s) {
                        GenericBinaryHeapPriorityQueue<int>.Test();
                        showForm = false;
                    } else {
                        switch (s) {
                            case "deb11":
                                TestDeb11();
                                return;
                            case "treewithconstraints":
                                TreeWithConstraints();
                                return;
                            
                            case "testgrouprouting":
                                TestGroupRouting();
                                return;
                            case "-vdc":
                                if (iarg == args.Length - 1) {
                                    Console.WriteLine("argument is missing after -vdc");
                                    return;
                                }
#if DEBUG
                                ShowDebugCurves(args[iarg + 1]);
#endif
                                return;
                            case "-testportentry":
                                TestPortEntry();
                                return;
                            case "-geom": // must be before case "g":
                                geomFileNames.Add(args[iarg + 1]);
                                ++iarg;
                                showForm = false;
                                break;
                            case "-g": {
                                var edgeRoutingSettings = new EdgeRoutingSettings {
                                                                                      EdgeRoutingMode = edgeRoutingMode,
                                                                                      BundlingSettings =
                                                                                          bundling
                                                                                              ? new BundlingSettings()
                                                                                              : null,
                                                                                      UseObstacleRectangles =
                                                                                          useObstacleRectangles,
                                                                                      BendPenalty = bendPenalty
                                                                                  };

                                LoadGeomFiles(args.Skip(iarg + 1), edgeRoutingSettings, show);
                                return;
                            }
                            case "-drawinggraphs": {
                                var edgeRoutingSettings = new EdgeRoutingSettings {
                                                                                      EdgeRoutingMode = edgeRoutingMode,
                                                                                      BundlingSettings =
                                                                                          bundling
                                                                                              ? new BundlingSettings()
                                                                                              : null
                                                                                  };

                                LoadDrawingGraphs(args.Skip(iarg + 1), edgeRoutingSettings, bendPenalty);
                                return;
                            }
                            case "-gtest":
                                LoadGeomFilesTest(args.Skip(iarg + 1), edgeRoutingMode, useSparseVisibilityGraph,
                                                  useObstacleRectangles,
                                                  bendPenalty, 0.52359877559829882);
                                return;
                            case "-grouptest":
                                GroupRoutingTest();
                                return;
                            case "-groupbundling":
                                return;
                            case "-wbundling":
                                BundleWithWidths();
                                return;

                            case "-grouptestrect":
                                GroupRoutingTestRect();
                                return;
                            case "-grouptestspline":
                                GroupRoutingTestSpline();
                                return;
                            case "-geomtestcone":
                                LoadGeomFilesTest(args.Skip(iarg + 1), edgeRoutingMode, useSparseVisibilityGraph,
                                                  useObstacleRectangles,
                                                  bendPenalty, Math.PI/6);
                                return;
                            case "layerseparationwithtransform":
                                LayerSeparationWithTransform();
                                return;
                            case "testwaypoints":
                                TestWayPoints();
                                break;
                            case "-bundling":
                                bundling = true;
                                edgeRoutingMode = EdgeRoutingMode.SplineBundling;
                                break;
                            case "testsolver":
                                TestSolver();
                                showForm = false;
                                break;
                            case "testrouting":
                                TestRouting();
                                showForm = false;
                                break;
                            case "-rectsp":
                                edgeRoutingMode = EdgeRoutingMode.Rectilinear;
                                Console.WriteLine("setting rectsp");
                                break;
                            case "-sparsevg":
                                useSparseVisibilityGraph = true;
                                Console.WriteLine("setting sparseVg");
                                break;
                            case "-userect":
                                useObstacleRectangles = true;
                                Console.WriteLine("setting useRect");
                                break;
                            case "-bendpenalty":
                                bendPenalty = double.Parse(args[iarg + 1]);
                                Console.WriteLine("setting bendPenalty");
                                ++iarg;
                                break;
                            case "freespline":
                                edgeRoutingMode = EdgeRoutingMode.Spline;
                                Console.WriteLine("setting EdgeRoutingMode.Spline");
                                break;
                            case "-rectcenter":
                                edgeRoutingMode = EdgeRoutingMode.RectilinearToCenter;
                                Console.WriteLine("setting rectToCenter");
                                break;
                                //                            case "testspanner":
                                //#if TEST_MSAGL
                                //                                ConeSpannerTest.TestSpanner();
                                //#else
                                //                                Console.WriteLine("ConeSpannerTest is only available in TEST mode");
                                //#endif
                            default:
                                if (s.StartsWith(badEdgeOption)) {} else if (s.StartsWith(mdsOption)) {
                                    mds = true;
                                } else if (s.StartsWith(initialLayoutOption)) {
                                    FormStuff.initialLayout = true;
                                } else if (s.StartsWith("-bundling")) {
                                    bundling = true;
                                } else if (s.StartsWith(testConvexHullString)) {
                                    testConvexHull = true;
                                } else if (s == "-filereps")
                                    // This is probably used with -quiet.  Must come before StartsWith("-f") option.
                                    fileReps = Int32.Parse(args[++iarg]);
                                else if (s == "-randomshifts")
                                    randomShifts = Int32.Parse(args[++iarg]);
                                else if (s.StartsWith("-f")) {
                                    listFileNames.Add(GetFileSpec(args, ref iarg));
                                    showForm = false;
                                } else if (s.StartsWith("-p")) {
                                    dotFileSpecs.Add(GetFileSpec(args, ref iarg));
                                    showForm = false;
                                } else if ((s == "-noshow") || (s == "-quiet")) {
                                    show = false;
                                } else if (s == "-verbose") {
                                    Verbose = true;
                                } else if (s.StartsWith("-log:")) {
                                    // Microsoft.Msagl.Layout.LogFileName = s.Substring(5);
                                    Verbose = true;
                                } else if (s == multiedges) {
                                    multiedgesTest = true;
                                } else if (s == phyloOption) {
                                    phylo = true;
                                } else if (s == testSaveOption)
                                    testSave = true;
                                else Console.WriteLine("unknown option " + s);
                                break;
                        }
                    }
                }

                var sw = new Stopwatch();
                sw.Start();

                if (testConvexHull)
                    TestConvexHull();

                if (testSave)
                    TestSave();


                if (phylo)
                    TestPhylo();

                // if (useBrandes)
                // Layout.BrandesThreshold = 0;

                // if (verbose)
                // Microsoft.Msagl.Layout.Reporting = true;

                if (multiedgesTest)
                    TestMultiedges();

                // If both were specified, do listfiles first, then filespecs.
                foreach (string listFileName in listFileNames) {
                    ProcessFileList(listFileName, fileReps, show, mds, edgeRoutingMode, bendPenalty, bundling,
                                    randomShifts,
                                    useSparseVisibilityGraph, useObstacleRectangles);
                }
                foreach (string fileSpec in dotFileSpecs) {
                    ProcessFileSpec(fileSpec, fileReps, show, mds, edgeRoutingMode, bendPenalty, bundling, randomShifts,
                                    useSparseVisibilityGraph, useObstacleRectangles);
                }
                foreach (string geomFileName in geomFileNames) {
                    var edgeRoutingSettings = new EdgeRoutingSettings {
                                                                          EdgeRoutingMode = edgeRoutingMode,
                                                                          BundlingSettings =
                                                                              bundling ? new BundlingSettings() : null,
                                                                          UseObstacleRectangles = useObstacleRectangles,
                                                                          BendPenalty = bendPenalty
                                                                      };
                    LoadGeomFile(geomFileName, edgeRoutingSettings, show);
                }

                sw.Stop();
                var ts = sw.Elapsed;
                Console.WriteLine("  Elapsed time: {0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds,
                                  ts.Milliseconds);

                if (showForm) {
                    gViewer = new GViewer();
                    gViewer.MouseMove += Draw.GviewerMouseMove;
                    var form = FormStuff.CreateForm(gViewer);
                    Application.Run(form);
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
            return;
        }
Exemplo n.º 50
0
 static void ProcessListOfFiles(string listOfFilesFile, ArgsParser.ArgsParser argsParser) {
     StreamReader sr;
     try {
         sr = new StreamReader(listOfFilesFile);
     }
     catch (Exception e) {
         Console.WriteLine(e.Message);
         return;
     }
     string fileName;
     string dir = Path.GetDirectoryName(listOfFilesFile);
     var gviewer = new GViewer();
     Form form = FormStuff.CreateForm(gviewer);
     int nOfBugs = 0;
     while ((fileName = sr.ReadLine()) != null) {
         if (String.IsNullOrEmpty(fileName)) continue;
         fileName = Path.Combine(dir, fileName.ToLower());
         ProcessFile(fileName, argsParser, gviewer, ref nOfBugs);
         if (form != null && argsParser.OptionIsUsed(QuietOption) == false)
             form.ShowDialog();
     }
 }
Exemplo n.º 51
0
        static void BundleWithWidths() {
            bool msaglFile;
            int line;
            int column;
            var graph = Form2.CreateDrawingGraphFromFile("c:\\dev\\graphlayout\\graphs\\tail.dot", out line, out column, out msaglFile);
            var graph1 = Form2.CreateDrawingGraphFromFile("c:\\dev\\graphlayout\\graphs\\tail.dot", out line, out column, out msaglFile);

            double w = 0.3;
            foreach (var edge in graph.Edges) {
                edge.Attr.LineWidth = w;
                if (w == 0.3)
                    w = 0.4;
                else if (w == 0.4)
                    w = .5;
                else w = 0.3;
            }

            var gv = new GViewer();
            gv.Graph = graph1;
            graph.CreateGeometryGraph();
            var gg = graph.GeometryGraph;
            var gg1 = graph1.GeometryGraph;

            for (int i = 0; i < gg.Nodes.Count; i++)
                gg.Nodes[i].BoundaryCurve = gg1.Nodes[i].BoundaryCurve;

            var ss = new SugiyamaLayoutSettings();
            var ll = new LayeredLayout(graph.GeometryGraph, ss);
            ll.Run();

            var bundler = new SplineRouter(graph.GeometryGraph, ss.NodeSeparation * 2, ss.NodeSeparation / 3, Math.PI / 6, ss.EdgeRoutingSettings.BundlingSettings);

            bundler.Run();
            
            var f = new Form();
            f.SuspendLayout();
            f.Controls.Add(gv);
            gv.Dock = DockStyle.Fill;
            gv.NeedToCalculateLayout = false;
            gv.Graph = graph;
            f.ResumeLayout();

            f.ShowDialog();


        }
Exemplo n.º 52
0
 public Viewer() {
     InitializeComponent();
     gViewer = new GViewer();
     Controls.Add(gViewer);
     gViewer.Dock = DockStyle.Fill;
 }
Exemplo n.º 53
0
 internal DGraph(Graph drawingGraph, GViewer gviewer) : base(gviewer){
     DrawingGraph = drawingGraph;
 }
Exemplo n.º 54
0
        internal static DNode CreateDNodeAndSetNodeBoundaryCurveForSubgraph(Graph drawingGraph, DGraph dGraph, GeometryNode geomNode,
                                                                            DrawingNode drawingNode, GViewer viewer)
        {
            double width  = 0;
            double height = 0;
            var    dNode  = new DNode(drawingNode, viewer);

            dGraph.AddNode(dNode);
            Drawing.Label label = drawingNode.Label;
            if (label != null)
            {
                CreateDLabel(dNode, label, out width, out height, viewer);
            }
            if (width < drawingGraph.Attr.MinNodeWidth)
            {
                width = drawingGraph.Attr.MinNodeWidth;
            }
            if (height < drawingGraph.Attr.MinNodeHeight)
            {
                height = drawingGraph.Attr.MinNodeHeight;
            }

            var cluster = (Cluster)geomNode;
            var margin  = dNode.DrawingNode.Attr.LabelMargin;

            if (label != null)
            {
                CreateDLabel(dNode, label, out width, out height, viewer);
                width  += 2 * dNode.DrawingNode.Attr.LabelMargin + 2 * drawingNode.Attr.LineWidth;
                height += 2 * dNode.DrawingNode.Attr.LabelMargin + 2 * drawingNode.Attr.LineWidth;
            }
            if (cluster.RectangularBoundary == null)
            {
                var lp = dNode.DrawingNode.Attr.ClusterLabelMargin;
                cluster.RectangularBoundary = new RectangularClusterBoundary()
                {
                    BottomMargin = lp == LgNodeInfo.LabelPlacement.Bottom ? height : margin,
                    LeftMargin   = lp == LgNodeInfo.LabelPlacement.Left ? height : margin,
                    RightMargin  = lp == LgNodeInfo.LabelPlacement.Right ? height : margin,
                    TopMargin    = lp == LgNodeInfo.LabelPlacement.Top ? height : margin,
                    MinWidth     = lp == LgNodeInfo.LabelPlacement.Top || lp == LgNodeInfo.LabelPlacement.Bottom ? width : 0,
                    MinHeight    = lp == LgNodeInfo.LabelPlacement.Left || lp == LgNodeInfo.LabelPlacement.Right ? width : 0,
                };
            }
            // Filippo Polo: I'm taking this out because I've modified the drawing of a double circle
            // so that it can be used with ellipses too.
            //if (drawingNode.Attr.Shape == Shape.DoubleCircle)
            //width = height = Math.Max(width, height) * Draw.DoubleCircleOffsetRatio;
            ICurve curve;

            if (drawingNode.NodeBoundaryDelegate != null &&
                (curve = drawingNode.NodeBoundaryDelegate(drawingNode)) != null)
            {
                geomNode.BoundaryCurve = curve;
            }
            else if (geomNode.BoundaryCurve == null)
            {
                geomNode.BoundaryCurve =
                    NodeBoundaryCurves.GetNodeBoundaryCurve(dNode.DrawingNode, width, height);
            }
            return(dNode);
        }
Exemplo n.º 55
0
        static void ProcessMsaglFile(string fileName, ArgsParser.ArgsParser argsParser) {
            Graph graph = Graph.Read(fileName);
            if (graph == null) {
                Console.WriteLine("cannot read " + fileName);
                return;
            }

            if (graph.GeometryGraph != null && graph.BoundingBox.Width > 0) {
                //graph does not need a layout
                if (argsParser.OptionIsUsed(BundlingOption)) {
                    RouteBundledEdges(graph.GeometryGraph, argsParser);
                    if (!argsParser.OptionIsUsed(QuietOption)) {
                        var gviewer = new GViewer();
                        gviewer.MouseMove += Draw.GviewerMouseMove;
                        Form form = CreateForm(graph, gviewer);
                        form.ShowDialog(); // to block the thread
                    }
                }
            }
        }
Exemplo n.º 56
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="viewer"></param>
 public GraphPrinting(GViewer viewer)
 {
     this.gViewer = viewer;
 }
Exemplo n.º 57
0
/// <summary>
/// constructor
/// </summary>
/// <param name="viewer"></param>
        protected DObject(GViewer viewer)
        {
            Viewer = viewer;
        }
Exemplo n.º 58
0
        static void Main(string[] args) {
#if DEBUG
            DisplayGeometryGraph.SetShowFunctions();
#endif
            ArgsParser.ArgsParser argsParser = SetArgsParser(args);

            if (argsParser.OptionIsUsed(PolygonDistanceTestOption))
                TestPolygonDistance();
            else if (argsParser.OptionIsUsed(TestCdtThreaderOption))
                TestCdtThreader();
            else if (argsParser.OptionIsUsed(RandomBundlingTest))
                RandomBundlingTests.RsmContent();


            bundling = argsParser.OptionIsUsed(BundlingOption);

            var gviewer = new GViewer();
            gviewer.MouseMove += Draw.GviewerMouseMove;
            if(argsParser.OptionIsUsed(FdOption)) {
                TestFD();
                gviewer.CurrentLayoutMethod = LayoutMethod.IcrementalLayout;
            }
            Form form = CreateForm(null, gviewer);
            if (argsParser.OptionIsUsed(AsyncLayoutOption))
                gviewer.AsyncLayout = true;

            string listOfFilesFile = argsParser.GetValueOfOptionWithAfterString(ListOfFilesOption);
            if (listOfFilesFile != null) {
                ProcessListOfFiles(listOfFilesFile, argsParser);
                return;
            }
            string fileName = argsParser.GetValueOfOptionWithAfterString(FileOption);
            string ext = Path.GetExtension(fileName);
            if (ext != null) {
                ext = ext.ToLower();
                if (ext == ".dot") {
                    ProcessDotFile(gviewer, argsParser, fileName);
                }
                else {
                    if (ext == ".geom") {
                        GeometryGraph geometryGraph = GeometryGraphReader.CreateFromFile(fileName);
                        geometryGraph.Margins = 10;

                        FixHookPorts(geometryGraph);
                        // if (argsParser.OptionIsUsed(BundlingOption)) {
                        for (int i = 0; i < 1; i++) {
#if DEBUG
                            /*DisplayGeometryGraph.ShowGraph(geometryGraph);
                                var l = new List<DebugCurve>(); l.AddRange(geometryGraph.Nodes.Select(n=>new DebugCurve(100,1,"black",n.BoundaryCurve)));
                                l.AddRange(geometryGraph.Edges.Select(e=>new DebugCurve(100,1,"black", new LineSegment(e.Source.Center,e.Target.Center))));
                                foreach (var cl in geometryGraph.RootCluster.AllClustersDepthFirst()) {
                                    l.Add(new DebugCurve(100,2,"blue",cl.BoundaryCurve));
                                    foreach (var node in cl.Nodes)
                                        l.Add(new DebugCurve(100, 2, "brown", node.BoundaryCurve));
                                  
                                    foreach (var e in cl.Edges)
                                        l.Add(new DebugCurve(100, 2, "pink", new LineSegment(e.Source.Center, e.Target.Center)));
                                  
                                }

                                DisplayGeometryGraph.ShowDebugCurves(l.ToArray());*/

#endif
                            BundlingSettings bs = GetBundlingSettings(argsParser);

                            double loosePadding;
                            double tightPadding = GetPaddings(argsParser, out loosePadding);
                            if (argsParser.OptionIsUsed(MdsOption)) {
                                var mdsLayoutSettings = new MdsLayoutSettings
                                                        {RemoveOverlaps = true, NodeSeparation = loosePadding*3};
                                var mdsLayout = new MdsGraphLayout(mdsLayoutSettings, geometryGraph);
                                mdsLayout.Run();
                            }
                            else {
                                if (argsParser.OptionIsUsed(FdOption)) {
                                    var settings = new FastIncrementalLayoutSettings {AvoidOverlaps = true};
                                    (new InitialLayout(geometryGraph, settings)).Run();
                                }
                            }
                            var splineRouter = new SplineRouter(geometryGraph, geometryGraph.Edges, tightPadding,
                                                                loosePadding,
                                                                Math.PI/6, bs);
                            splineRouter.Run();
                        }
#if DEBUG
                        DisplayGeometryGraph.ShowGraph(geometryGraph);
#endif
                        return;
                    }
                    else {
                        if (ext == ".msagl") {
                            Graph graph = Graph.Read(fileName);
                            //           DisplayGeometryGraph.ShowGraph(graph.GeometryGraph);
                            if (graph != null) {
                                if (argsParser.OptionIsUsed(BundlingOption)) {
                                    BundlingSettings bs = GetBundlingSettings(argsParser);

                                    double loosePadding;
                                    double tightPadding = GetPaddings(argsParser, out loosePadding);
                                    var br = new SplineRouter(graph.GeometryGraph, tightPadding, loosePadding, Math.PI/6,
                                                              bs);
                                    br.Run();
                                    //                 DisplayGeometryGraph.ShowGraph(graph.GeometryGraph);
                                }
                            }
                            gviewer.NeedToCalculateLayout = false;
                            gviewer.Graph = graph;
                            gviewer.NeedToCalculateLayout = true;
                        }
                    }
                }
            }
            else if (argsParser.OptionIsUsed(TestCdtOption)) {
                Triangulation(argsParser.OptionIsUsed(ReverseXOption));
                Environment.Exit(0);
            }
            else if (argsParser.OptionIsUsed(TestCdtOption0)) {
                TestTriangulationOnSmallGraph(argsParser);
                Environment.Exit(0);
            }
            else if (argsParser.OptionIsUsed(TestCdtOption2)) {
                TestTriangulationOnPolys();
                Environment.Exit(0);
            }
            else if (argsParser.OptionIsUsed(TestCdtOption1)) {
                ThreadThroughCdt();
                Environment.Exit(0);
            }
            else if (argsParser.OptionIsUsed(ConstraintsTestOption))
                TestGraphWithConstraints();
            
            Application.Run(form);
            
        }
Exemplo n.º 59
0
        public virtual void Initialize(SimulationForm simForm, EventStepSim currentStep, string currentNode, ListView trace, Graph igraph)
        {
            //initialize the parameters
            isiTarget = simForm;

            initialStep = currentStep;
            initialString = currentNode;
            ListView_Trace = new ListView();
            if(trace.Items.Count > 0)
            {
                ListView_Trace.Items.Add(trace.Items[0].Clone() as ListViewItem);
            }

            HideTauTransition = simForm.HideTauTransition;
            visited = new Hashtable(simForm.visited);
            graph = CloneGraph(igraph);
            intGraph = CloneGraph(igraph);
            Mapping = new Dictionary<string, ProcessData>(simForm.Mapping);

            SimulatorViewer = new GViewer();
            this.SimulatorViewer.AsyncLayout = false;
            this.SimulatorViewer.BackwardEnabled = true;
            this.SimulatorViewer.BuildHitTree = true;
            this.SimulatorViewer.ForwardEnabled = true;
            this.SimulatorViewer.Graph = null;
            this.SimulatorViewer.LayoutAlgorithmSettingsButtonVisible = true;
            this.SimulatorViewer.MouseHitDistance = 0.05;
            this.SimulatorViewer.Name = "SimulatorViewer";
            this.SimulatorViewer.NavigationVisible = true;
            this.SimulatorViewer.NeedToCalculateLayout = true;
            this.SimulatorViewer.PanButtonPressed = false;
            this.SimulatorViewer.SaveAsImageEnabled = true;
            this.SimulatorViewer.SaveAsMsaglEnabled = true;
            this.SimulatorViewer.SaveButtonVisible = true;
            this.SimulatorViewer.SaveGraphButtonVisible = true;
            this.SimulatorViewer.SaveInVectorFormatEnabled = true;
            this.SimulatorViewer.ToolBarIsVisible = true;
            this.SimulatorViewer.ZoomF = 1;
            this.SimulatorViewer.ZoomFraction = 0.5;
            this.SimulatorViewer.ZoomWindowThreshold = 0.05;
            this.SimulatorViewer.Dock = DockStyle.Fill;
        }
Exemplo n.º 60
0
        static Form CreateForm(Graph graph, GViewer gviewer) {
            Form form = FormStuff.CreateForm(gviewer);
            form.SuspendLayout();
            SetEdgeSeparationBar(form);

            gviewer.GraphChanged += GviewerGraphChanged;

            if (graph != null)
                gviewer.Graph = graph;
            return form;
        }