public static void saveGraphToXml
     (string filename, Netron.GraphLib.UI.GraphControl graphControl1, designGraph graph1)
 {
     graph1.updateFromGraphControl(graphControl1);
     graph1.checkForRepeatNames();
     saveGraphToXml(filename, graph1);
 }
        public static void addConnectionText(DDTRelation rel, Netron.NetronLight.DDTConnection connection, Netron.NetronLight.Win.DiagramControl diagramControl)
        {
            string from = rel.text.from;
            string mid = rel.text.middle;
            string to = rel.text.to;

            connection.setText(from, mid, to);
            //add 3 text blocks

            if (connection.Tfrom != null || connection.Tfrom.Length>0)
            {
                ConnectionText ctfrom = new ConnectionText(connection, TextPosition.From);
                diagramControl.controller.Model.AddShape(ctfrom);
            }
            if (connection.Tmid != null || connection.Tmid.Length > 0)
            {
                ConnectionText ctmid = new ConnectionText(connection, TextPosition.Mid);
                diagramControl.controller.Model.AddShape(ctmid);
            }
            if (connection.Tto != null || connection.Tto.Length > 0)
            {
                ConnectionText ctto = new ConnectionText(connection, TextPosition.To);
                diagramControl.controller.Model.AddShape(ctto);
            }
        }
        public GraphUserControl(Netron.NAF.Core.Plugin.NAFRootMediator root)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            graphControl1.LoadLibraries();
            this.dockState = NAFDockState.Fill;
            this.panelText = "Grapher";
            this.graphControl1.Root = root;
        }
Exemple #4
0
 void ucGraph1_OnShapeMenuItemClick(object sender, Netron.GraphLib.Shape shape)
 {
     MenuItem menu = sender as MenuItem;
     switch (menu.Text) {
         case "��λ��������Ϣͼ":
             if (OnLoactionXL != null)
                 OnLoactionXL(((BaseShape)shape).DeviceID,null);
             break;
     }
 }
Exemple #5
0
 void graphControl1_OnShapeMenuItemClick(object sender, Netron.GraphLib.Shape shape) {
     MenuItem menu = sender as MenuItem;
     switch (menu.Text) {
         case "设备参数":
             showData(shape);
             break;
         case "投入运行":
             //setDeviceStatus((shape as BaseShape).DeviceID, 0);
             break;
         case "退出运行":
             //setDeviceStatus((shape as BaseShape).DeviceID,1);
             break;
     }
     if (OnShapeMenuItemClick != null)
         OnShapeMenuItemClick(sender, shape);
 }
        public void Connect(
            IEdge e,
            Netron.Connection conn,
            Netron.Shape source,
            Netron.Shape target
            )
        {
            // get ports
            EdgeKeysEventArgs args = (EdgeKeysEventArgs)layouter.EdgeArgs[e];

            if (args.Keys.Count<2)
                throw new ArgumentException("not enough keys");
            // find best from
            conn.From = FindNearestConnector(source, args.Keys[0]);
            conn.To = FindNearestConnector(target, args.Keys[args.Keys.Count-1]);
        }
 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 Connector FindNearestConnector(Netron.Shape shape, PointF p)
        {
            Connector best = null;
            double distBest = double.MaxValue;
            double dist;

            foreach(Connector c in shape.Connectors)
            {
                dist = PointMath.SqrDistance(shape.ConnectionPoint(c),p);
                if (dist<distBest)
                {
                    distBest = dist;
                    best = c;
                }
            }

            if (best==null)
                throw new Exception("could not find port");

            return best;
        }
        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);
        }
 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);
     }
 }
Exemple #11
0
 public PyNetronServiceClient(string HostURL, string RoutePrefix, int[] PortRangeInUse)
 {
     NetronTool = new Netron(HostURL, RoutePrefix, PortRangeInUse);
 }
		private void graphControl1_ShowNodeProperties(object sender, Netron.GraphLib.PropertyBag props)
		{
			ShowShapeProperties(props.Owner as Shape);
		}
		private bool graphControl1_OnNewConnection(object sender, Netron.GraphLib.ConnectionEventArgs e)
		{
			return true;
		}
        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);
        }
 public void displayGraph(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText)
 {
     this.initializeGraphControl(graphControl1, globalLabelsText);
     initPropertiesBag();
 }
        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();
            }
        }
        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();
            }
        }
        public override PointF ConnectionPoint(Netron.Connector c)
        {
            RectangleF r = Rectangle;

            if (c == this.west)
                return new PointF(r.Left, r.Top + r.Height/2);
            if (c == this.east)
                return new PointF(r.Right, r.Top + r.Height/2);
            if (c == this.north)
                return new PointF(r.Left+r.Width/2, r.Top);
            if (c == this.south)
                return new PointF(r.Left+r.Width/2, r.Bottom);
            if (c==this.southWest)
                return new PointF(r.Left, r.Bottom);
            if (c==this.northWest)
                return new PointF(r.Left, r.Top);
            if (c==this.southEast)
                return new PointF(r.Right, r.Bottom);
            if (c==this.northEast)
                return new PointF(r.Right, r.Top);

            throw new Exception("Unknown connector");
        }
Exemple #19
0
 /// <summary>
 /// 显示设备属性
 /// </summary>
 /// <param name="shape"></param>
 private void showData(Netron.GraphLib.Shape shape) {
     if (shape is BaseShape) {
         BaseShape bs = shape as BaseShape;
         
     }
 }
 public static void setDDTConnection(Netron.NetronLight.DDTConnection conn)
 {
     DDTConnection = conn;
 }
Exemple #21
0
		private void graphControl1_ShowNodeProperties(object sender, Netron.GraphLib.PropertyBag props)
		{
			propertyGrid1.SelectedObject = props;
		}
		private void graphControl1_OnShapeAdded(object sender, Netron.GraphLib.Shape shape)
		{
			graphControl1.Nodes.Remove(shape);

			if (shape is ActiveRecordShape)
			{
				ActiveRecordShape arshape = shape as ActiveRecordShape;
				
				_actionSet.DoNewARWizard();
			}
			else if (shape is ActiveRecordBaseClassShape)
			{
				ActiveRecordBaseClassShape arshape = shape as ActiveRecordBaseClassShape;

//				if (_actionSet.DoAssociateDatabase(arshape))
//				{
//				}
			}
		}
 public void updateGraphControl(Netron.GraphLib.UI.GraphControl graphControlLHS,
     Netron.GraphLib.UI.GraphControl graphControlRHS, Label LglobalLabelsText, Label RglobalLabelsText)
 {
     try
     {
         numElementsInK = 0;
         #region check for same names in R and L and turn orange
         // first turn all nodes in R white
         foreach (node a in R.nodes)
             a.displayShape.ShapeColor = System.Drawing.Color.White;
         foreach (node a in L.nodes)
         {
             int rIndex = R.nodes.FindIndex(delegate(node b) { return (b.name == a.name); });
             if (rIndex >= 0)
             {
                 numElementsInK++;
                 a.displayShape.ShapeColor = System.Drawing.Color.FromArgb(214, 145, 82);
                 R.nodes[rIndex].displayShape.ShapeColor = System.Drawing.Color.FromArgb(214, 145, 82);
             }
             else
             {
                 a.displayShape.ShapeColor = System.Drawing.Color.White;
             }
         }
         #endregion
         #region check for same arcs in R and L and turn orange
         foreach (arc a in R.arcs)
         {
             a.displayShape.LineColor = System.Drawing.Color.Black;
             a.displayShape.LineWeight = ConnectionWeight.Medium;
         }
         foreach (arc a in L.arcs)
         {
             int rIndex = R.arcs.FindIndex(delegate(arc b) { return (b.name == a.name); });
             if (rIndex >= 0)
             {
                 numElementsInK++;
                 a.displayShape.LineColor = System.Drawing.Color.FromArgb(214, 145, 82);
                 R.arcs[rIndex].displayShape.LineColor = System.Drawing.Color.FromArgb(214, 145, 82);
                 a.displayShape.LineWeight = ConnectionWeight.Fat;
                 R.arcs[rIndex].displayShape.LineWeight = ConnectionWeight.Fat;
             }
             else
             {
                 a.displayShape.LineColor = System.Drawing.Color.Black;
                 a.displayShape.LineWeight = ConnectionWeight.Medium;
             }
         }
         #endregion
         L.updateGraphControl(graphControlLHS, LglobalLabelsText);
         R.updateGraphControl(graphControlRHS, RglobalLabelsText);
     }
     catch (Exception e)
     {
         MessageBox.Show("There was an error displaying the graphs. Please save work and re-open." +
             " (Error: " + e.ToString() + ")", "Error Displaying Graphs", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
 }
        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 displayGraph(Netron.GraphLib.UI.GraphControl graphControl1, Label globalLabelsText)
        {
            this.updateGraphControl(graphControl1, globalLabelsText);

            graphControl1.StartLayout();

            initPropertiesBag();
        }
 public static void setIDDTObject(Netron.NetronLight.IDDTObject obj)
 {
     IDDT = obj;
 }
 public void updateFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1)
 {
     addNodesFromGraphControl(graphControl1, false);
     addArcsFromGraphControl(graphControl1, false);
     internallyConnectGraph();
     removeNodesAndArcsFromGraphControl(graphControl1);
 }
        public void updateFromGraphControl(Netron.GraphLib.UI.GraphControl graphControl1)
        {
            try
            {
                designGraph graph;

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

                graph.addNodesFromGraphControl(graphControl1, true);
                graph.addArcsFromGraphControl(graphControl1, true);
                graph.internallyConnectGraph();
                graph.removeNodesAndArcsFromGraphControl(graphControl1);
            }
            catch (Exception e)
            {
                MessageBox.Show("There was an error updating the rule from the display. Please save work and re-open. (Error: " + e.ToString() + ")", "Error Updating Rule", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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);
            }
        }
 private void netronPanel_SelectEvent(object sender, Netron.StatusEventArgs e)
 {
     if (e.Entity is PropertyGridShape)
     {
         PropertyGridShape shape = (PropertyGridShape)e.Entity;
         switch(e.Status)
         {
             case EnumStatusType.Selected:
                 shape.CollapseRows=false;
                 this.netronPanel.MoveToFront(shape);
                 break;
             case EnumStatusType.Deselected:
                 shape.CollapseRows=true;
                 break;
         }
     }
 }
 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;
 }