Example #1
0
 public void updateFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1)
 {
     addNodesFromGraphControl(graphControl1, false);
     addArcsFromGraphControl(graphControl1, false);
     internallyConnectGraph();
     removeNodesAndArcsFromGraphControl(graphControl1);
 }
Example #2
0
        public void showProperties(Netron.GraphLib.UI.GraphControl GC, grammarRule rule1, object[] props)
        {
            graphControl = GC;
            rule         = rule1;

            if (graphControl.Name == "graphControlLHS")
            {
                graph = rule.L;
            }
            else
            {
                graph = rule.R;
            }

            rule.updateFromGraphControl(graphControl);
            try
            {
                this.graphRulePropsTab.Text = "Rule Properties";
                if (rule.Bag == null)
                {
                    rule.initPropertiesBag();
                }
                this.graphRuleProps.SelectedObject = rule.Bag;
            }
            catch (Exception exc)
            {
                MessageBox.Show("The properties of the rule has thrown an exception and cannot be displayed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SearchIO.output(exc.Message, 2);
            }
            showDisplayProperties(graphControl, (Netron.GraphLib.PropertyBag)props[0]);
            showRuleNodeArcProperties((Netron.GraphLib.PropertyBag)props[0], graph);
        }
Example #3
0
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GraphTab));
     this.graphControl = new Netron.GraphLib.UI.GraphControl();
     this.SuspendLayout();
     //
     // graphControl
     //
     this.graphControl.AllowAddConnection    = true;
     this.graphControl.AllowAddShape         = true;
     this.graphControl.AllowDeleteShape      = true;
     this.graphControl.AllowDrop             = true;
     this.graphControl.AllowMoveShape        = true;
     this.graphControl.AutomataPulse         = 10;
     this.graphControl.AutoScroll            = true;
     this.graphControl.BackgroundColor       = System.Drawing.Color.WhiteSmoke;
     this.graphControl.BackgroundImagePath   = null;
     this.graphControl.BackgroundType        = Netron.GraphLib.CanvasBackgroundType.FlatColor;
     this.graphControl.DefaultConnectionEnd  = Netron.GraphLib.ConnectionEnd.NoEnds;
     this.graphControl.DefaultConnectionPath = "Default";
     this.graphControl.Dock                   = System.Windows.Forms.DockStyle.Fill;
     this.graphControl.DoTrack                = false;
     this.graphControl.EnableContextMenu      = true;
     this.graphControl.EnableLayout           = false;
     this.graphControl.EnableToolTip          = true;
     this.graphControl.FileName               = null;
     this.graphControl.GradientBottom         = System.Drawing.Color.White;
     this.graphControl.GradientMode           = System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal;
     this.graphControl.GradientTop            = System.Drawing.Color.LightSteelBlue;
     this.graphControl.GraphLayoutAlgorithm   = Netron.GraphLib.GraphLayoutAlgorithms.SpringEmbedder;
     this.graphControl.GridSize               = 20;
     this.graphControl.Location               = new System.Drawing.Point(0, 0);
     this.graphControl.Name                   = "graphControl";
     this.graphControl.RestrictToCanvas       = true;
     this.graphControl.ShowAutomataController = false;
     this.graphControl.ShowGrid               = false;
     this.graphControl.Size                   = new System.Drawing.Size(696, 589);
     this.graphControl.Snap                   = false;
     this.graphControl.TabIndex               = 0;
     this.graphControl.Zoom                   = 1F;
     this.graphControl.OnShowProperties      += new Netron.GraphLib.PropertiesInfo(this.OnShowProperties);
     this.graphControl.OnInfo                += new Netron.GraphLib.InfoDelegate(this.graphControl_OnInfo);
     this.graphControl.OnClear               += new System.EventHandler(this.graphControl_OnClear);
     this.graphControl.OnDiagramSaved        += new Netron.GraphLib.FileInfo(this.graphControl_OnDiagramSaved);
     this.graphControl.OnDiagramOpened       += new Netron.GraphLib.FileInfo(this.graphControl_OnDiagramOpened);
     //
     // GraphTab
     //
     this.AccessibleDescription = "This panel contains the Netron graph control. Drag-drop shapes from the library o" +
                                  "r use the context menu to add shapes.";
     this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
     this.ClientSize        = new System.Drawing.Size(696, 589);
     this.Controls.Add(this.graphControl);
     this.HideOnClose = true;
     this.Icon        = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name        = "GraphTab";
     this.TabText     = "Diagram";
     this.ResumeLayout(false);
 }
Example #4
0
 public static void saveGraphToXml
     (string filename, Netron.GraphLib.UI.GraphControl graphControl1, designGraph graph1)
 {
     graph1.updateFromGraphControl(graphControl1);
     graph1.checkForRepeatNames();
     saveGraphToXml(filename, graph1);
 }
Example #5
0
        public void addNodesFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1,
                                             Boolean ruleGraph)
        {
            node tempnode;

            foreach (Shape a in graphControl1.Shapes)
            {
                if (!nodes.Exists(delegate(node b) { return(b.displayShape == a); }))
                {
                    if (ruleGraph)
                    {
                        tempnode = new ruleNode(nameFromText(a.Text));
                    }
                    else
                    {
                        tempnode = new node(nameFromText(a.Text));
                    }
                    this.nodes.Add(tempnode);
                }
                else
                {
                    tempnode = nodes.Find(delegate(node b) { return(b.displayShape == a); });
                }

                if (a.Text != "[Not_set]")
                {
                    tempnode.name        = nameFromText(a.Text);
                    tempnode.localLabels = labelsFromText(a.Text);
                }
                tempnode.screenX      = a.X;
                tempnode.screenY      = a.Y;
                tempnode.displayShape = a;
                tempnode.setShapeKeyFromDisplayShape();
            }
        }
Example #6
0
        public void displayGraph(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText)
        {
            this.updateGraphControl(graphControl1, globalLabelsText);

            graphControl1.StartLayout();

            initPropertiesBag();
        }
Example #7
0
        private Shape addNullShape(Netron.GraphLib.UI.GraphControl graphControl1, int onRight)
        {
            Shape nullNode = graphControl1.AddShape("smallCircleNode", "null",
                                                    new PointF(graphControl1.Width * onRight, graphControl1.Height / 2));

            nullNode.ShapeColor = Color.White;
            nullNode.ZOrder     = 10;
            return(nullNode);
        }
Example #8
0
        public void addArcsFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1,
                                            Boolean ruleGraph)
        {
            Shape fromShape, toShape;
            arc   temparc;

            foreach (Connection a in graphControl1.Connections)
            {
                if (!arcs.Exists(delegate(arc b) { return(b.displayShape == a); }))
                {
                    if (ruleGraph)
                    {
                        temparc = new ruleArc(nameFromText(a.Text));
                    }
                    else
                    {
                        temparc = new arc(nameFromText(a.Text));
                    }
                    this.arcs.Add(temparc);
                }
                else
                {
                    temparc = arcs.Find(delegate(arc b) { return(b.displayShape == a); });
                }

                fromShape = a.From.BelongsTo;
                toShape   = a.To.BelongsTo;

                temparc.From = nodes.Find(delegate(node c)
                                          { return(sameName(c.name, fromShape.Text)); });
                temparc.To = nodes.Find(delegate(node c)
                                        { return(sameName(c.name, toShape.Text)); });

                for (int i = 0; i != fromShape.Connectors.Count; i++)
                {
                    if (fromShape.Connectors[i] == a.From)
                    {
                        temparc.fromConnector = i;
                    }
                }
                for (int i = 0; i != toShape.Connectors.Count; i++)
                {
                    if (toShape.Connectors[i] == a.To)
                    {
                        temparc.toConnector = i;
                    }
                }
                if (a.Text != "[Not_set]")
                {
                    temparc.name        = nameFromText(a.Text);
                    temparc.localLabels = labelsFromText(a.Text);
                }
                temparc.displayShape = a;
                temparc.setStyleKeyFromDisplayShape();
            }
        }
Example #9
0
        private Shape addNullShape(Netron.GraphLib.UI.GraphControl graphControl1, int onRight)
        {
            Shape nullNode = graphControl1.AddBasicShape(
                BasicShapeType.tinyZNode, "null",
                new PointF(graphControl1.Width * onRight, graphControl1.Height / 2));

            nullNode.ShapeColor = Color.White;
            nullNode.ZOrder     = 10;
            return(nullNode);
        }
Example #10
0
 private void showDisplayProperties(Netron.GraphLib.UI.GraphControl GC, PropertyBag shapeProps)
 {
     try
     {
         this.displayProps.SelectedObject = shapeProps;
     }
     catch (Exception exc)
     {
         MessageBox.Show("The display properties cannot be displayed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         SearchIO.output(exc.Message, 2);
     }
 }
Example #11
0
        public void updateGraphControl(Netron.GraphLib.UI.GraphControl graphControl1,
                                       Label globalLabelsText)
        {
            if (this.globalLabels.Count > 0)
            {
                globalLabelsText.Text = StringCollectionConverter.convert(this.globalLabels);
            }
            else
            {
                globalLabelsText.Text = " ";
            }

            foreach (node n in nodes)
            {
                n.displayShape.Text = textForNode(n);
                /* make sure node is of right type - if not call the replacement function */
                if ((n.nodeType != null) && (n.GetType() != typeof(GraphSynth.Representation.ruleNode)) &&
                    (n.GetType() != n.nodeType))
                {
                    replaceNodeWithInheritedType(n);
                }
            }
            foreach (arc a in arcs)
            {
                if (a.doublyDirected)
                {
                    a.displayShape.LineEnd = ConnectionEnd.BothFilledArrow;
                }
                else if (a.directed)
                {
                    a.displayShape.LineEnd = ConnectionEnd.RightFilledArrow;
                }
                else
                {
                    a.displayShape.LineEnd = ConnectionEnd.NoEnds;
                }
                a.displayShape.Text = textForArc(a);

                /* make sure node is of right type - if not call the replacement function */
                if ((a.arcType != null) && (a.GetType() != typeof(GraphSynth.Representation.ruleArc)) &&
                    (a.GetType() != a.arcType))
                {
                    replaceArcWithInheritedType(a, a.From, a.To);
                }
            }
        }
Example #12
0
 public void showProperties(Netron.GraphLib.UI.GraphControl GC, designGraph graph, object sender, object[] props)
 {
     if (props.GetLength(0) > 0)
     {
         if ((propWindow == null) || !propWindow.CanSelect)
         {
             propWindow = new PropertiesWindow();
         }
         if (this.ActiveMdiChild.WindowState.Equals(FormWindowState.Maximized))
         {
             propWindow.MdiParent = null;
         }
         propWindow.Show();
         propWindow.Activate();
         propWindow.showProperties(GC, graph, props);
     }
 }
Example #13
0
        public void removeNodesAndArcsFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1)
        {
            for (int i = nodes.Count - 1; i >= 0; i--)
            {
                if (!graphControl1.Shapes.Contains(nodes[i].displayShape))
                {
                    this.removeNode(i);
                }
            }

            for (int i = arcs.Count - 1; i >= 0; i--)
            {
                if (!graphControl1.Connections.Contains(arcs[i].displayShape))
                {
                    removeArc(i);
                }
            }
        }
 public void showProperties(Netron.GraphLib.UI.GraphControl GC, designGraph graph1, object[] props)
 {
     graphControl = GC;
     graph = graph1;
     rule = null;
     try
     {
         graph.updateFromGraphControl(graphControl);
         if (graph.Bag == null) graph.initPropertiesBag();
         this.graphRuleProps.SelectedObject = graph.Bag;
         this.graphRulePropsTab.Text = "Graph Properties";
     }
     catch (Exception exc)
     {
         MessageBox.Show("The properties of the graph has thrown an exception and cannot be displayed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         SearchIO.output(exc.Message, 2);
     }
     showDisplayProperties(graphControl, (Netron.GraphLib.PropertyBag)props[0]);
     showNodeArcProperties((Netron.GraphLib.PropertyBag)props[0], graph);
 }
Example #15
0
 public void showProperties(Netron.GraphLib.UI.GraphControl GC, designGraph graph1, object[] props)
 {
     graphControl = GC;
     graph        = graph1;
     rule         = null;
     try
     {
         graph.updateFromGraphControl(graphControl);
         if (graph.Bag == null)
         {
             graph.initPropertiesBag();
         }
         this.graphRuleProps.SelectedObject = graph.Bag;
         this.graphRulePropsTab.Text        = "Graph Properties";
     }
     catch (Exception exc)
     {
         MessageBox.Show("The properties of the graph has thrown an exception and cannot be displayed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         SearchIO.output(exc.Message, 2);
     }
     showDisplayProperties(graphControl, (Netron.GraphLib.PropertyBag)props[0]);
     showNodeArcProperties((Netron.GraphLib.PropertyBag)props[0], graph);
 }
        public void showProperties(Netron.GraphLib.UI.GraphControl GC, grammarRule rule1, object[] props)
        {
            graphControl = GC;
            rule = rule1;

            if (graphControl.Name == "graphControlLHS") graph = rule.L;
            else graph = rule.R;

            rule.updateFromGraphControl(graphControl);
            try
            {
                this.graphRulePropsTab.Text = "Rule Properties";
                if (rule.Bag == null) rule.initPropertiesBag();
                this.graphRuleProps.SelectedObject = rule.Bag;
            }
            catch (Exception exc)
            {
                MessageBox.Show("The properties of the rule has thrown an exception and cannot be displayed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SearchIO.output(exc.Message, 2);
            }
            showDisplayProperties(graphControl, (Netron.GraphLib.PropertyBag)props[0]);
            showRuleNodeArcProperties((Netron.GraphLib.PropertyBag)props[0], graph);
        }
Example #17
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.graphControl1         = new Netron.GraphLib.UI.GraphControl();
     this.contextMenu           = new System.Windows.Forms.ContextMenu();
     this.addSubClassMenu       = new System.Windows.Forms.MenuItem();
     this.addJoinedSubclassMenu = new System.Windows.Forms.MenuItem();
     this.removeMenu            = new System.Windows.Forms.MenuItem();
     this.menuItem5             = new System.Windows.Forms.MenuItem();
     this.showCodePreviewMenu   = new System.Windows.Forms.MenuItem();
     this.menuItem4             = new System.Windows.Forms.MenuItem();
     this.showPropertiesMenu    = new System.Windows.Forms.MenuItem();
     this.SuspendLayout();
     //
     // graphControl1
     //
     this.graphControl1.AllowAddConnection    = false;
     this.graphControl1.AllowAddShape         = true;
     this.graphControl1.AllowDeleteShape      = false;
     this.graphControl1.AllowDrop             = true;
     this.graphControl1.AllowMoveShape        = true;
     this.graphControl1.AutomataPulse         = 10;
     this.graphControl1.AutoScroll            = true;
     this.graphControl1.BackgroundColor       = System.Drawing.Color.Gray;
     this.graphControl1.BackgroundImagePath   = null;
     this.graphControl1.BackgroundType        = Netron.GraphLib.CanvasBackgroundTypes.Gradient;
     this.graphControl1.DefaultConnectionPath = "Default";
     this.graphControl1.DefaultLineEnd        = Netron.GraphLib.ConnectionEnds.NoEnds;
     this.graphControl1.Dock                 = System.Windows.Forms.DockStyle.Fill;
     this.graphControl1.DoTrack              = false;
     this.graphControl1.EnableContextMenu    = false;
     this.graphControl1.EnableLayout         = false;
     this.graphControl1.FileName             = null;
     this.graphControl1.GradientBottom       = System.Drawing.Color.DarkGray;
     this.graphControl1.GradientTop          = System.Drawing.Color.DimGray;
     this.graphControl1.GraphLayoutAlgorithm = Netron.GraphLib.GraphLayoutAlgorithms.SpringEmbedder;
     this.graphControl1.GridSize             = 15;
     this.graphControl1.Location             = new System.Drawing.Point(2, 2);
     this.graphControl1.Name                 = "graphControl1";
     this.graphControl1.RestrictToCanvas     = true;
     this.graphControl1.ShowGrid             = false;
     this.graphControl1.Size                 = new System.Drawing.Size(844, 390);
     this.graphControl1.Snap                 = false;
     this.graphControl1.TabIndex             = 0;
     this.graphControl1.Text                 = "graphControl1";
     this.graphControl1.Zoom                 = 1F;
     this.graphControl1.ShowNodeProperties  += new Netron.GraphLib.ShowPropsDelegate(this.graphControl1_ShowNodeProperties);
     this.graphControl1.MouseUp             += new System.Windows.Forms.MouseEventHandler(this.graphControl1_MouseUp);
     this.graphControl1.OnNewConnection     += new Netron.GraphLib.NewConnection(this.graphControl1_OnNewConnection);
     //
     // contextMenu
     //
     this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.addSubClassMenu,
         this.addJoinedSubclassMenu,
         this.removeMenu,
         this.menuItem5,
         this.showCodePreviewMenu,
         this.menuItem4,
         this.showPropertiesMenu
     });
     //
     // addSubClassMenu
     //
     this.addSubClassMenu.Index  = 0;
     this.addSubClassMenu.Text   = "Add SubClass";
     this.addSubClassMenu.Click += new System.EventHandler(this.addSubClassMenu_Click);
     //
     // addJoinedSubclassMenu
     //
     this.addJoinedSubclassMenu.Index  = 1;
     this.addJoinedSubclassMenu.Text   = "Add Joined SubClass";
     this.addJoinedSubclassMenu.Click += new System.EventHandler(this.addJoinedSubclassMenu_Click);
     //
     // removeMenu
     //
     this.removeMenu.Index  = 2;
     this.removeMenu.Text   = "Remove";
     this.removeMenu.Click += new System.EventHandler(this.removeMenu_Click);
     //
     // menuItem5
     //
     this.menuItem5.Index = 3;
     this.menuItem5.Text  = "-";
     //
     // showCodePreviewMenu
     //
     this.showCodePreviewMenu.Index  = 4;
     this.showCodePreviewMenu.Text   = "Preview code";
     this.showCodePreviewMenu.Click += new System.EventHandler(this.showCodePreviewMenu_Click);
     //
     // menuItem4
     //
     this.menuItem4.Index = 5;
     this.menuItem4.Text  = "-";
     //
     // showPropertiesMenu
     //
     this.showPropertiesMenu.Index  = 6;
     this.showPropertiesMenu.Text   = "Properties";
     this.showPropertiesMenu.Click += new System.EventHandler(this.showPropertiesMenu_Click);
     //
     // ActiveRecordGraphView
     //
     this.DockableAreas     = WeifenLuo.WinFormsUI.DockAreas.Document;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.BackColor         = System.Drawing.SystemColors.Control;
     this.ClientSize        = new System.Drawing.Size(848, 394);
     this.CloseButton       = false;
     this.Controls.Add(this.graphControl1);
     this.DockPadding.All = 2;
     this.Name            = "ActiveRecordGraphView";
     this.Text            = "ActiveRecord Graph";
     this.Load           += new System.EventHandler(this.ActiveRecordGraphView_Load);
     this.ResumeLayout(false);
 }
Example #18
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.graphControl1 = new Netron.GraphLib.UI.GraphControl();
			this.statusBar1 = new System.Windows.Forms.StatusBar();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.tabControl1 = new System.Windows.Forms.TabControl();
			this.tabPage1 = new System.Windows.Forms.TabPage();
			this.tabPage2 = new System.Windows.Forms.TabPage();
			this.panel1 = new System.Windows.Forms.Panel();
			this.stamper1 = new Netron.GraphLib.UI.Stamper();
			this.splitter2 = new System.Windows.Forms.Splitter();
			this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.tabControl1.SuspendLayout();
			this.tabPage1.SuspendLayout();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// graphControl1
			// 
			this.graphControl1.AllowAddConnection = true;
			this.graphControl1.AllowAddShape = true;
			this.graphControl1.AllowDeleteShape = true;
			this.graphControl1.AllowDrop = true;
			this.graphControl1.AllowMoveShape = true;
			this.graphControl1.AutomataPulse = 10;
			this.graphControl1.AutoScroll = true;
			this.graphControl1.BackgroundColor = System.Drawing.Color.Gray;
			this.graphControl1.BackgroundImagePath = null;
			this.graphControl1.BackgroundType = Netron.GraphLib.CanvasBackgroundTypes.FlatColor;
			this.graphControl1.DefaultConnectionPath = "Default";
			this.graphControl1.DefaultLineEnd = Netron.GraphLib.ConnectionEnds.NoEnds;
			this.graphControl1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.graphControl1.DoTrack = false;
			this.graphControl1.EnableContextMenu = false;
			this.graphControl1.EnableLayout = false;
			this.graphControl1.FileName = null;
			this.graphControl1.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.graphControl1.GradientBottom = System.Drawing.Color.White;
			this.graphControl1.GradientTop = System.Drawing.Color.LightSteelBlue;
			this.graphControl1.GraphLayoutAlgorithm = Netron.GraphLib.GraphLayoutAlgorithms.SpringEmbedder;
			this.graphControl1.GridSize = 20;
			this.graphControl1.Location = new System.Drawing.Point(0, 0);
			this.graphControl1.Name = "graphControl1";
			this.graphControl1.RestrictToCanvas = false;
			this.graphControl1.ShowGrid = true;
			this.graphControl1.Size = new System.Drawing.Size(424, 445);
			this.graphControl1.Snap = false;
			this.graphControl1.TabIndex = 4;
			this.graphControl1.Text = "graphControl1";
			this.graphControl1.Zoom = 1F;
			this.graphControl1.ShowNodeProperties += new Netron.GraphLib.ShowPropsDelegate(this.graphControl1_ShowNodeProperties);
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 471);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Size = new System.Drawing.Size(728, 22);
			this.statusBar1.TabIndex = 2;
			this.statusBar1.Text = "statusBar1";
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2});
			this.menuItem1.Text = "File";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "Exit";
			// 
			// tabControl1
			// 
			this.tabControl1.Controls.Add(this.tabPage1);
			this.tabControl1.Controls.Add(this.tabPage2);
			this.tabControl1.Dock = System.Windows.Forms.DockStyle.Left;
			this.tabControl1.Location = new System.Drawing.Point(0, 0);
			this.tabControl1.Name = "tabControl1";
			this.tabControl1.SelectedIndex = 0;
			this.tabControl1.Size = new System.Drawing.Size(432, 471);
			this.tabControl1.TabIndex = 5;
			// 
			// tabPage1
			// 
			this.tabPage1.Controls.Add(this.graphControl1);
			this.tabPage1.Location = new System.Drawing.Point(4, 22);
			this.tabPage1.Name = "tabPage1";
			this.tabPage1.Size = new System.Drawing.Size(424, 445);
			this.tabPage1.TabIndex = 0;
			this.tabPage1.Text = "Configuration";
			// 
			// tabPage2
			// 
			this.tabPage2.Location = new System.Drawing.Point(4, 22);
			this.tabPage2.Name = "tabPage2";
			this.tabPage2.Size = new System.Drawing.Size(424, 445);
			this.tabPage2.TabIndex = 1;
			this.tabPage2.Text = "Facilities";
			// 
			// panel1
			// 
			this.panel1.BackColor = System.Drawing.SystemColors.Control;
			this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.panel1.Controls.Add(this.propertyGrid1);
			this.panel1.Controls.Add(this.splitter2);
			this.panel1.Controls.Add(this.stamper1);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.Location = new System.Drawing.Point(432, 0);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(296, 471);
			this.panel1.TabIndex = 7;
			// 
			// stamper1
			// 
			this.stamper1.AutoScroll = true;
			this.stamper1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.stamper1.Location = new System.Drawing.Point(0, 259);
			this.stamper1.Name = "stamper1";
			this.stamper1.Size = new System.Drawing.Size(292, 208);
			this.stamper1.TabIndex = 2;
			this.stamper1.Zoom = 0.2F;
			// 
			// splitter2
			// 
			this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.splitter2.Location = new System.Drawing.Point(0, 256);
			this.splitter2.Name = "splitter2";
			this.splitter2.Size = new System.Drawing.Size(292, 3);
			this.splitter2.TabIndex = 3;
			this.splitter2.TabStop = false;
			// 
			// propertyGrid1
			// 
			this.propertyGrid1.CommandsVisibleIfAvailable = true;
			this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.propertyGrid1.LargeButtons = false;
			this.propertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar;
			this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
			this.propertyGrid1.Name = "propertyGrid1";
			this.propertyGrid1.Size = new System.Drawing.Size(292, 256);
			this.propertyGrid1.TabIndex = 4;
			this.propertyGrid1.Text = "propertyGrid1";
			this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;
			this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;
			// 
			// splitter1
			// 
			this.splitter1.Location = new System.Drawing.Point(432, 0);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(3, 471);
			this.splitter1.TabIndex = 8;
			this.splitter1.TabStop = false;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
			this.ClientSize = new System.Drawing.Size(728, 493);
			this.Controls.Add(this.splitter1);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.tabControl1);
			this.Controls.Add(this.statusBar1);
			this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.Text = "Form1";
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
Example #19
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.graphControl1 = new Netron.GraphLib.UI.GraphControl();
			this.contextMenu = new System.Windows.Forms.ContextMenu();
			this.addSubClassMenu = new System.Windows.Forms.MenuItem();
			this.addJoinedSubclassMenu = new System.Windows.Forms.MenuItem();
			this.removeMenu = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.showCodePreviewMenu = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.showPropertiesMenu = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// graphControl1
			// 
			this.graphControl1.AllowAddConnection = false;
			this.graphControl1.AllowAddShape = true;
			this.graphControl1.AllowDeleteShape = false;
			this.graphControl1.AllowDrop = true;
			this.graphControl1.AllowMoveShape = true;
			this.graphControl1.AutomataPulse = 10;
			this.graphControl1.AutoScroll = true;
			this.graphControl1.BackgroundColor = System.Drawing.Color.Gray;
			this.graphControl1.BackgroundImagePath = null;
			this.graphControl1.BackgroundType = Netron.GraphLib.CanvasBackgroundTypes.Gradient;
			this.graphControl1.DefaultConnectionPath = "Default";
			this.graphControl1.DefaultLineEnd = Netron.GraphLib.ConnectionEnds.NoEnds;
			this.graphControl1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.graphControl1.DoTrack = false;
			this.graphControl1.EnableContextMenu = false;
			this.graphControl1.EnableLayout = false;
			this.graphControl1.FileName = null;
			this.graphControl1.GradientBottom = System.Drawing.Color.DarkGray;
			this.graphControl1.GradientTop = System.Drawing.Color.DimGray;
			this.graphControl1.GraphLayoutAlgorithm = Netron.GraphLib.GraphLayoutAlgorithms.SpringEmbedder;
			this.graphControl1.GridSize = 15;
			this.graphControl1.Location = new System.Drawing.Point(2, 2);
			this.graphControl1.Name = "graphControl1";
			this.graphControl1.RestrictToCanvas = true;
			this.graphControl1.ShowGrid = false;
			this.graphControl1.Size = new System.Drawing.Size(844, 390);
			this.graphControl1.Snap = false;
			this.graphControl1.TabIndex = 0;
			this.graphControl1.Text = "graphControl1";
			this.graphControl1.Zoom = 1F;
			this.graphControl1.ShowNodeProperties += new Netron.GraphLib.ShowPropsDelegate(this.graphControl1_ShowNodeProperties);
			this.graphControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.graphControl1_MouseUp);
			this.graphControl1.OnNewConnection += new Netron.GraphLib.NewConnection(this.graphControl1_OnNewConnection);
			// 
			// contextMenu
			// 
			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						this.addSubClassMenu,
																						this.addJoinedSubclassMenu,
																						this.removeMenu,
																						this.menuItem5,
																						this.showCodePreviewMenu,
																						this.menuItem4,
																						this.showPropertiesMenu});
			// 
			// addSubClassMenu
			// 
			this.addSubClassMenu.Index = 0;
			this.addSubClassMenu.Text = "Add SubClass";
			this.addSubClassMenu.Click += new System.EventHandler(this.addSubClassMenu_Click);
			// 
			// addJoinedSubclassMenu
			// 
			this.addJoinedSubclassMenu.Index = 1;
			this.addJoinedSubclassMenu.Text = "Add Joined SubClass";
			this.addJoinedSubclassMenu.Click += new System.EventHandler(this.addJoinedSubclassMenu_Click);
			// 
			// removeMenu
			// 
			this.removeMenu.Index = 2;
			this.removeMenu.Text = "Remove";
			this.removeMenu.Click += new System.EventHandler(this.removeMenu_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 3;
			this.menuItem5.Text = "-";
			// 
			// showCodePreviewMenu
			// 
			this.showCodePreviewMenu.Index = 4;
			this.showCodePreviewMenu.Text = "Preview code";
			this.showCodePreviewMenu.Click += new System.EventHandler(this.showCodePreviewMenu_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 5;
			this.menuItem4.Text = "-";
			// 
			// showPropertiesMenu
			// 
			this.showPropertiesMenu.Index = 6;
			this.showPropertiesMenu.Text = "Properties";
			this.showPropertiesMenu.Click += new System.EventHandler(this.showPropertiesMenu_Click);
			// 
			// ActiveRecordGraphView
			// 
			this.DockableAreas = WeifenLuo.WinFormsUI.DockAreas.Document;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.ClientSize = new System.Drawing.Size(848, 394);
			this.CloseButton = false;
			this.Controls.Add(this.graphControl1);
			this.DockPadding.All = 2;
			this.Name = "ActiveRecordGraphView";
			this.Text = "ActiveRecord Graph";
			this.Load += new System.EventHandler(this.ActiveRecordGraphView_Load);
			this.ResumeLayout(false);

		}
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.graphControl1 = new Netron.GraphLib.UI.GraphControl();
     this.statusBar1    = new System.Windows.Forms.StatusBar();
     this.mainMenu1     = new System.Windows.Forms.MainMenu();
     this.menuItem1     = new System.Windows.Forms.MenuItem();
     this.menuItem2     = new System.Windows.Forms.MenuItem();
     this.tabControl1   = new System.Windows.Forms.TabControl();
     this.tabPage1      = new System.Windows.Forms.TabPage();
     this.tabPage2      = new System.Windows.Forms.TabPage();
     this.panel1        = new System.Windows.Forms.Panel();
     this.stamper1      = new Netron.GraphLib.UI.Stamper();
     this.splitter2     = new System.Windows.Forms.Splitter();
     this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
     this.splitter1     = new System.Windows.Forms.Splitter();
     this.tabControl1.SuspendLayout();
     this.tabPage1.SuspendLayout();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // graphControl1
     //
     this.graphControl1.AllowAddConnection    = true;
     this.graphControl1.AllowAddShape         = true;
     this.graphControl1.AllowDeleteShape      = true;
     this.graphControl1.AllowDrop             = true;
     this.graphControl1.AllowMoveShape        = true;
     this.graphControl1.AutomataPulse         = 10;
     this.graphControl1.AutoScroll            = true;
     this.graphControl1.BackgroundColor       = System.Drawing.Color.Gray;
     this.graphControl1.BackgroundImagePath   = null;
     this.graphControl1.BackgroundType        = Netron.GraphLib.CanvasBackgroundTypes.FlatColor;
     this.graphControl1.DefaultConnectionPath = "Default";
     this.graphControl1.DefaultLineEnd        = Netron.GraphLib.ConnectionEnds.NoEnds;
     this.graphControl1.Dock                 = System.Windows.Forms.DockStyle.Fill;
     this.graphControl1.DoTrack              = false;
     this.graphControl1.EnableContextMenu    = false;
     this.graphControl1.EnableLayout         = false;
     this.graphControl1.FileName             = null;
     this.graphControl1.Font                 = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.graphControl1.GradientBottom       = System.Drawing.Color.White;
     this.graphControl1.GradientTop          = System.Drawing.Color.LightSteelBlue;
     this.graphControl1.GraphLayoutAlgorithm = Netron.GraphLib.GraphLayoutAlgorithms.SpringEmbedder;
     this.graphControl1.GridSize             = 20;
     this.graphControl1.Location             = new System.Drawing.Point(0, 0);
     this.graphControl1.Name                 = "graphControl1";
     this.graphControl1.RestrictToCanvas     = false;
     this.graphControl1.ShowGrid             = true;
     this.graphControl1.Size                 = new System.Drawing.Size(424, 445);
     this.graphControl1.Snap                 = false;
     this.graphControl1.TabIndex             = 4;
     this.graphControl1.Text                 = "graphControl1";
     this.graphControl1.Zoom                 = 1F;
     this.graphControl1.ShowNodeProperties  += new Netron.GraphLib.ShowPropsDelegate(this.graphControl1_ShowNodeProperties);
     //
     // statusBar1
     //
     this.statusBar1.Location = new System.Drawing.Point(0, 471);
     this.statusBar1.Name     = "statusBar1";
     this.statusBar1.Size     = new System.Drawing.Size(728, 22);
     this.statusBar1.TabIndex = 2;
     this.statusBar1.Text     = "statusBar1";
     //
     // mainMenu1
     //
     this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.menuItem1
     });
     //
     // menuItem1
     //
     this.menuItem1.Index = 0;
     this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.menuItem2
     });
     this.menuItem1.Text = "File";
     //
     // menuItem2
     //
     this.menuItem2.Index = 0;
     this.menuItem2.Text  = "Exit";
     //
     // tabControl1
     //
     this.tabControl1.Controls.Add(this.tabPage1);
     this.tabControl1.Controls.Add(this.tabPage2);
     this.tabControl1.Dock          = System.Windows.Forms.DockStyle.Left;
     this.tabControl1.Location      = new System.Drawing.Point(0, 0);
     this.tabControl1.Name          = "tabControl1";
     this.tabControl1.SelectedIndex = 0;
     this.tabControl1.Size          = new System.Drawing.Size(432, 471);
     this.tabControl1.TabIndex      = 5;
     //
     // tabPage1
     //
     this.tabPage1.Controls.Add(this.graphControl1);
     this.tabPage1.Location = new System.Drawing.Point(4, 22);
     this.tabPage1.Name     = "tabPage1";
     this.tabPage1.Size     = new System.Drawing.Size(424, 445);
     this.tabPage1.TabIndex = 0;
     this.tabPage1.Text     = "Configuration";
     //
     // tabPage2
     //
     this.tabPage2.Location = new System.Drawing.Point(4, 22);
     this.tabPage2.Name     = "tabPage2";
     this.tabPage2.Size     = new System.Drawing.Size(424, 445);
     this.tabPage2.TabIndex = 1;
     this.tabPage2.Text     = "Facilities";
     //
     // panel1
     //
     this.panel1.BackColor   = System.Drawing.SystemColors.Control;
     this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
     this.panel1.Controls.Add(this.propertyGrid1);
     this.panel1.Controls.Add(this.splitter2);
     this.panel1.Controls.Add(this.stamper1);
     this.panel1.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.panel1.Location = new System.Drawing.Point(432, 0);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(296, 471);
     this.panel1.TabIndex = 7;
     //
     // stamper1
     //
     this.stamper1.AutoScroll = true;
     this.stamper1.Dock       = System.Windows.Forms.DockStyle.Bottom;
     this.stamper1.Location   = new System.Drawing.Point(0, 259);
     this.stamper1.Name       = "stamper1";
     this.stamper1.Size       = new System.Drawing.Size(292, 208);
     this.stamper1.TabIndex   = 2;
     this.stamper1.Zoom       = 0.2F;
     //
     // splitter2
     //
     this.splitter2.Dock     = System.Windows.Forms.DockStyle.Bottom;
     this.splitter2.Location = new System.Drawing.Point(0, 256);
     this.splitter2.Name     = "splitter2";
     this.splitter2.Size     = new System.Drawing.Size(292, 3);
     this.splitter2.TabIndex = 3;
     this.splitter2.TabStop  = false;
     //
     // propertyGrid1
     //
     this.propertyGrid1.CommandsVisibleIfAvailable = true;
     this.propertyGrid1.Dock          = System.Windows.Forms.DockStyle.Fill;
     this.propertyGrid1.LargeButtons  = false;
     this.propertyGrid1.LineColor     = System.Drawing.SystemColors.ScrollBar;
     this.propertyGrid1.Location      = new System.Drawing.Point(0, 0);
     this.propertyGrid1.Name          = "propertyGrid1";
     this.propertyGrid1.Size          = new System.Drawing.Size(292, 256);
     this.propertyGrid1.TabIndex      = 4;
     this.propertyGrid1.Text          = "propertyGrid1";
     this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;
     this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;
     //
     // splitter1
     //
     this.splitter1.Location = new System.Drawing.Point(432, 0);
     this.splitter1.Name     = "splitter1";
     this.splitter1.Size     = new System.Drawing.Size(3, 471);
     this.splitter1.TabIndex = 8;
     this.splitter1.TabStop  = false;
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
     this.ClientSize        = new System.Drawing.Size(728, 493);
     this.Controls.Add(this.splitter1);
     this.Controls.Add(this.panel1);
     this.Controls.Add(this.tabControl1);
     this.Controls.Add(this.statusBar1);
     this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.Menu = this.mainMenu1;
     this.Name = "Form1";
     this.Text = "Form1";
     this.tabControl1.ResumeLayout(false);
     this.tabPage1.ResumeLayout(false);
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Example #21
0
        public void updateGraphControl(Netron.GraphLib.UI.GraphControl graphControl1,
                                       Label globalLabelsText)
        {
            try
            {
                string  defaultShapeKey = "8ED1469D-90B2-43ab-B000-4FF5C682F530";
                Boolean isFixed         = true;
                Random  rnd             = new Random();

                #region Global Labels
                if (this.globalLabels.Count > 0)
                {
                    globalLabelsText.Text = StringCollectionConverter.convert(this.globalLabels);
                }
                else
                {
                    globalLabelsText.Text = " ";
                }
                #endregion
                #region display the nodes
                for (int i = nodes.Count - 1; i >= 0; i--)
                {
                    node n = nodes[i];
                    #region if it has no displayShape
                    if (n.displayShape == null)
                    {
                        if (n.shapekey == null)
                        {
                            n.shapekey = defaultShapeKey;
                        }
                        if (n.screenX == 0.0 && n.screenY == 0.0)
                        {
                            n.screenX = rnd.Next(50, graphControl1.Width - 100);
                            n.screenY = rnd.Next(20, graphControl1.Height - 20);
                            isFixed   = false;
                        }
                        else
                        {
                            isFixed = true;
                        }
                        n.displayShape = graphControl1.AddShape(n.shapekey, new PointF(n.screenX, n.screenY));

                        /* if the prev. statement didn't take, it's likely the shapekey wasn't recognized.
                         * there we try again with the default ShapeKey. */
                        if (n.displayShape == null)
                        {
                            n.displayShape = graphControl1.AddShape(defaultShapeKey, new PointF(n.screenX, n.screenY));
                        }
                    }
                    #endregion

                    else if (!graphControl1.Shapes.Contains(n.displayShape))
                    {
                        /* a shape is defined for the node but is not displayed */
                        n.displayShape = graphControl1.AddShape(n.displayShape);
                    }
                    n.displayShape.Text    = textForNode(n);
                    n.displayShape.IsFixed = isFixed;

                    /* make sure node is of right type - if not call the replacement function */
                    if ((n.nodeType != null) && (n.GetType() != typeof(GraphSynth.Representation.ruleNode)) &&
                        (n.GetType() != n.nodeType))
                    {
                        replaceNodeWithInheritedType(n);
                    }
                }
                #endregion
                #region display the arcs
                for (int i = arcs.Count - 1; i >= 0; i--)
                {
                    arc  a        = arcs[i];
                    node fromNode = a.From;
                    node toNode   = a.To;

                    Connector fromConnect = null;
                    Connector toConnect   = null;
                    if ((fromNode == null) || (fromNode.displayShape == null))
                    {
                        a.fromConnector = 0;
                        if (a.displayShape == null || a.displayShape.From.BelongsTo == null)
                        {
                            fromConnect = addNullShape(graphControl1, 0).Connectors[0];
                        }
                        else
                        {
                            fromConnect = a.displayShape.From;
                        }
                    }
                    else if ((a.fromConnector == -1) ||
                             (a.fromConnector >= fromNode.displayShape.Connectors.Count))
                    {
                        a.fromConnector = rnd.Next(fromNode.displayShape.Connectors.Count);
                        fromConnect     = fromNode.displayShape.Connectors[a.fromConnector];
                    }
                    else
                    {
                        fromConnect = fromNode.displayShape.Connectors[a.fromConnector];
                    }
                    /* now repeat same process for To */
                    if ((toNode == null) || (toNode.displayShape == null))
                    {
                        a.toConnector = 0;
                        if (a.displayShape == null || a.displayShape.To.BelongsTo == null)
                        {
                            toConnect = addNullShape(graphControl1, 1).Connectors[0];
                        }
                        else
                        {
                            toConnect = a.displayShape.To;
                        }
                    }
                    else if ((a.toConnector == -1) ||
                             (a.toConnector >= toNode.displayShape.Connectors.Count))
                    {
                        a.toConnector = rnd.Next(toNode.displayShape.Connectors.Count);
                        toConnect     = toNode.displayShape.Connectors[a.toConnector];
                    }
                    else
                    {
                        toConnect = toNode.displayShape.Connectors[a.toConnector];
                    }

                    if (((a.displayShape != null) && (!graphControl1.Connections.Contains(a.displayShape)) &&
                         ((a.displayShape.From == null) || (a.displayShape.To == null))) ||
                        ((a.displayShape == null) && (fromConnect == null) && (toConnect == null)))
                    {
                        removeArc(a);
                    }
                    else
                    {
                        if (a.displayShape == null)
                        {
                            a.displayShape = graphControl1.AddConnection(fromConnect, toConnect);
                        }
                        else if (!graphControl1.Connections.Contains(a.displayShape))
                        {
                            a.displayShape = graphControl1.AddConnection(a.displayShape.From, a.displayShape.To);
                        }

                        /* a shape is defined for the node but is not displayed
                         * Rectangular, Default, Bezier */
                        if (a.curveStyle != null)
                        {
                            a.displayShape.LinePath = a.curveStyle;
                        }
                        if (a.doublyDirected)
                        {
                            a.displayShape.LineEnd = ConnectionEnd.BothFilledArrow;
                        }
                        else if (a.directed)
                        {
                            a.displayShape.LineEnd = ConnectionEnd.RightFilledArrow;
                        }
                        else
                        {
                            a.displayShape.LineEnd = ConnectionEnd.NoEnds;
                        }
                        a.displayShape.Text      = textForArc(a);
                        a.displayShape.ShowLabel = true;
                    }

                    /* make sure node is of right type - if not call the replacement function */
                    if ((a.arcType != null) && (a.GetType() != typeof(GraphSynth.Representation.ruleArc)) &&
                        (a.GetType() != a.arcType))
                    {
                        replaceArcWithInheritedType(a, fromNode, toNode);
                    }
                }
                #endregion
            }
            catch (Exception e)
            {
                MessageBox.Show("There was an error displaying the graph. Please save work and re-open. (Error: " + e.ToString() + ")", "Error Displaying Graph", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #22
0
 public void displayGraph(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText)
 {
     this.initializeGraphControl(graphControl1, globalLabelsText);
     initPropertiesBag();
 }
Example #23
0
        public void initializeGraphControl(Netron.GraphLib.UI.GraphControl graphControl1,
                                           Label globalLabelsText)
        {
            Random rnd = new Random();

            #region display the nodes
            for (int i = nodes.Count - 1; i >= 0; i--)
            {
                node n = nodes[i];
                if (n.screenX == 0.0 && n.screenY == 0.0)
                {
                    n.screenX = rnd.Next(50, graphControl1.Width - 100);
                    n.screenY = rnd.Next(20, graphControl1.Height - 20);
                }
                List <string> shapeData = StringCollectionConverter.convert(n.shapekey);
                if (shapeData.Count == 0)
                {
                    shapeData.Add("");
                }
                n.displayShape = graphControl1.AddShape(shapeData[0], new PointF(n.screenX, n.screenY));
                if (shapeData.Count > 1)
                {
                    n.displayShape.ShapeColor = Color.FromArgb(int.Parse(shapeData[1]));
                    n.displayShape.Width      = float.Parse(shapeData[2]);
                    n.displayShape.Height     = float.Parse(shapeData[3]);
                }
            }
            #endregion
            #region display the arcs
            foreach (arc a in arcs)
            {
                node fromNode = a.From;
                node toNode   = a.To;

                Connector fromConnect = null;
                Connector toConnect   = null;
                if ((fromNode == null) || (fromNode.displayShape == null))
                {
                    a.fromConnector = 0;
                    fromConnect     = addNullShape(graphControl1, 0).Connectors[0];
                }
                else if ((a.fromConnector == -1) ||
                         (a.fromConnector >= fromNode.displayShape.Connectors.Count))
                {
                    a.fromConnector = rnd.Next(fromNode.displayShape.Connectors.Count);
                    fromConnect     = fromNode.displayShape.Connectors[a.fromConnector];
                }
                else
                {
                    fromConnect = fromNode.displayShape.Connectors[a.fromConnector];
                }
                /* now repeat same process for To */
                if ((toNode == null) || (toNode.displayShape == null))
                {
                    a.toConnector = 0;
                    toConnect     = addNullShape(graphControl1, 1).Connectors[0];
                }
                else if ((a.toConnector == -1) ||
                         (a.toConnector >= toNode.displayShape.Connectors.Count))
                {
                    a.toConnector = rnd.Next(toNode.displayShape.Connectors.Count);
                    toConnect     = toNode.displayShape.Connectors[a.toConnector];
                }
                else
                {
                    toConnect = toNode.displayShape.Connectors[a.toConnector];
                }

                a.displayShape           = graphControl1.AddConnection(fromConnect, toConnect);
                a.displayShape.ShowLabel = true;

                List <string> styleData = StringCollectionConverter.convert(a.styleKey);
                if (styleData.Count > 0)
                {
                    a.displayShape.LinePath = styleData[0];
                }
                if (styleData.Count > 1)
                {
                    a.displayShape.LineColor  = Color.FromArgb(int.Parse(styleData[1]));
                    a.displayShape.LineWeight = (ConnectionWeight)int.Parse(styleData[2]);
                    a.displayShape.LineStyle  = (System.Drawing.Drawing2D.DashStyle) int.Parse(styleData[3]);
                }
            }
            #endregion
            this.updateGraphControl(graphControl1, globalLabelsText);
        }
Example #24
0
        public void updateFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1)
        {
            try
            {
                node        tempnode;
                List <node> tempNodes = new List <node>();
                arc         temparc;
                List <arc>  tempArcs = new List <arc>();
                Shape       fromShape, toShape;

                foreach (Shape a in graphControl1.Shapes)
                {
                    if (!nodes.Exists(delegate(node b) { return(b.displayShape == a); }))
                    {
                        tempnode = new node(nameFromText(a.Text));
                        tempNodes.Add(tempnode);
                    }
                    else
                    {
                        tempnode = nodes.Find(delegate(node b) { return(b.displayShape == a); });
                        tempNodes.Add(tempnode);
                    }
                    if (a.Text != "[Not_set]")
                    {
                        tempnode.name        = nameFromText(a.Text);
                        tempnode.localLabels = labelsFromText(a.Text);
                    }
                    tempnode.screenX      = a.X;
                    tempnode.screenY      = a.Y;
                    tempnode.shapekey     = node.lookupShapeKey(a);
                    tempnode.displayShape = a;
                }
                nodes = tempNodes;
                foreach (Connection a in graphControl1.Connections)
                {
                    if (!arcs.Exists(delegate(arc b) { return(b.displayShape == a); }))
                    {
                        temparc = new arc(nameFromText(a.Text));
                        tempArcs.Add(temparc);
                    }
                    else
                    {
                        temparc = arcs.Find(delegate(arc b) { return(b.displayShape == a); });
                        tempArcs.Add(temparc);
                    }
                    fromShape = a.From.BelongsTo;
                    toShape   = a.To.BelongsTo;

                    temparc.From = nodes.Find(delegate(node c)
                                              { return(sameName(c.name, fromShape.Text)); });
                    temparc.To = nodes.Find(delegate(node c)
                                            { return(sameName(c.name, toShape.Text)); });

                    for (int i = 0; i != fromShape.Connectors.Count; i++)
                    {
                        if (fromShape.Connectors[i] == a.From)
                        {
                            temparc.fromConnector = i;
                        }
                    }
                    for (int i = 0; i != toShape.Connectors.Count; i++)
                    {
                        if (toShape.Connectors[i] == a.To)
                        {
                            temparc.toConnector = i;
                        }
                    }
                    if (a.Text != "[Not_set]")
                    {
                        temparc.name        = nameFromText(a.Text);
                        temparc.localLabels = labelsFromText(a.Text);
                    }
                    temparc.curveStyle = a.LinePath;
                    if (a.LineEnd == ConnectionEnd.NoEnds)
                    {
                        temparc.directed = false;
                    }
                    else if (a.LineEnd == ConnectionEnd.BothFilledArrow ||
                             a.LineEnd == ConnectionEnd.BothOpenArrow)
                    {
                        temparc.doublyDirected = true;
                    }
                    else
                    {
                        temparc.doublyDirected = false;
                        temparc.directed       = true;
                        if (a.LineEnd == ConnectionEnd.LeftFilledArrow ||
                            a.LineEnd == ConnectionEnd.LeftOpenArrow)
                        {
                            /* we have a little situation on our hands here. the user drew the arc
                             * from one node to another but now wants it to go the other way. */
                            tempnode     = temparc.To;
                            temparc.To   = temparc.From;
                            temparc.From = tempnode;
                        }
                    }
                    temparc.displayShape = a;
                }
                arcs = tempArcs;
                this.internallyConnectGraph();
            }
            catch (Exception e)
            {
                MessageBox.Show("There was an error updating graph from the display. Please save work and re-open. (Error: " + e.ToString() + ")", "Error Updating Graph", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }