public GoBasicNode InsertNode(PointF pt, string title, GoShape shape = null, int userFlag = 0, Object userObj = null) { if (shape == null) { shape = new GoRectangle(); } GoDocument doc = goView.Document; doc.StartTransaction(); GoBasicNode n = new GoBasicNode(); n.UserFlags = userFlag; n.UserObject = userObj; n.LabelSpot = GoObject.Middle; n.Text = title; n.Shape = shape; // specify the position and colors n.Location = pt; n.Brush = new SolidBrush(Color.White); n.Shape.PenColor = Color.Red; n.Shape.PenWidth = 2; // allow the user to edit the text in-place n.Label.Editable = true; doc.Add(n); doc.FinishTransaction("Insert node finished"); return(n); }
private GoBasicNode Drowing_Node(string lotID, Int32 xLevelNo , string yLevelNo, LotHistoryItem lotInfo, string seletedLotID) { int denominator = Convert.ToInt32(yLevelNo.Split('@')[0]); int numerator = Convert.ToInt32(yLevelNo.Split('@')[1]); GoBasicNode node = new GoBasicNode(); node.Shape = new GoRoundedRectangle(); node.Location = new PointF(xLevelNo * 250 + 150, 100 * numerator); node.Text = lotInfo.GetNodeText(lotID); node.Label.Multiline = true; if (seletedLotID.Equals(lotID)) { node.Shape.BrushColor = Color.LightPink; } else { node.Shape.BrushColor = Color.LightGray; } node.LabelSpot = GoObject.MiddleCenter; goView1.Document.Add(node); return(node); }
private void DrawingLotPath(List <string> lotMappingList , Dictionary <string, LotHistoryItem> lotHistoryInfoFromLot , Dictionary <string, LotHistoryItem> lotHistoryInfoToLot , string seletedLotID) { this.goView1.Document.Clear(); Dictionary <string, GoBasicNode> nodeInfo = new Dictionary <string, GoBasicNode>(); Dictionary <string, int> xLevelInfo = GetXLevelInfo(lotMappingList); Dictionary <string, string> yLevelInfo = GetYLevelInfo(xLevelInfo); List <string> printedLotList = new List <string>(); foreach (string fromToLotID in lotMappingList) { string fromLotID = fromToLotID.Split('@')[0]; string toLotID = fromToLotID.Split('@')[1]; int foreachIdx = 0; foreach (string lotID in new List <string>() { fromLotID, toLotID }) { foreachIdx++; int xLevelNo = xLevelInfo[lotID]; string yLevelNo = yLevelInfo[lotID]; LotHistoryItem lotInfo = GetLotHistoryItem(lotHistoryInfoFromLot, lotHistoryInfoToLot, lotID); if (printedLotList.Contains(lotID) == false || (fromLotID.Equals(toLotID) && foreachIdx == 2)) { if (fromLotID.Equals(toLotID)) { lotInfo.SetLotHistoryInfoKey(LotHistoryInfoKey.ISToLot); xLevelNo++; } GoBasicNode node = Drowing_Node(lotID, xLevelNo, yLevelNo, lotInfo, seletedLotID); printedLotList.Add(lotID); if (fromLotID.Equals(toLotID) && nodeInfo.ContainsKey(CommonHelper.CreateKey(lotID, "M")) == false) { nodeInfo.Add(CommonHelper.CreateKey(lotID, "M"), node); } else if (nodeInfo.ContainsKey(lotID) == false) { nodeInfo.Add(lotID, node); } } } if (fromLotID.Equals(toLotID)) { toLotID = CommonHelper.CreateKey(toLotID, "M"); } DrawingLink(nodeInfo[fromLotID], nodeInfo[toLotID]); } }
private void goView1_ObjectDoubleClicked(object sender, GoObjectEventArgs e) { GoBasicNode bn = e.GoObject.ParentNode as GoBasicNode; string seletedLotID = bn.Text.Split('\n')[0].Trim(); seletedLotID = seletedLotID.Split(':')[1].Trim(); DrawingLotPath(seletedLotID); }
private void DrawingLink(GoBasicNode fromNode, GoBasicNode toNode) { GoLink link = new GoLink(); link.ToArrow = true; link.PenColor = Color.Red; link.FromPort = fromNode.Port; link.ToPort = toNode.Port; goView1.Document.Add(link); }
private void goView1_ObjectDoubleClicked(object sender, GoObjectEventArgs e) { setStatus(false); GoBasicNode node = e.GoObject.TopLevelObject as GoBasicNode; if (node != null) { createZedgraph(node); } else { setStatus(true); } }
private GoBasicNode getNodes(string name) { GoBasicNode node = null; foreach (GoObject obj in goView1.Document) { node = obj as GoBasicNode; if (node != null) { if (node.Text == name) { break; } } } return(node); }
private bool isNodes(string name) { bool flag = false; foreach (GoObject obj in goView1.Document) { GoBasicNode node = obj as GoBasicNode; if (node != null) { if (node.Text == name) { flag = true; break; } } } return(flag); }
private void craeteNodeLine() { if (msd != null && !isLoad) { if (this.InvokeRequired) { Action a = craeteNodeLine; this.Invoke(a); } else { goView1.StartTransaction(); GoLayoutRandom l = new GoLayoutRandom(); RectangleF r = goView1.DisplayRectangle; l.Document = goView1.Document; l.MinX = (int)((r.X / goView1.DocScale) + 100); l.MaxX = (int)((r.Width - r.X) / goView1.DocScale - 100); l.MinY = (int)((r.Y / goView1.DocScale) + 100); l.MaxY = (int)((r.Height - r.Y) / goView1.DocScale - 100); foreach (var s in msd.svrinfos) { GoBasicNode state = StateChartDocument.NewNode(); state.ToolTipText = ""; state.Text = s.ServiceName; state.UserFlags = 0; if (!isNodes(s.ServiceName)) { goView1.Document.Add(state); } } foreach (var s in msd.svrrefs) { addLine(s, Color.Green); } l.PerformLayout(); goView1.FinishTransaction("added node"); } } }
private void nodeWarn() { goView1.Document.SkipsUndoManager = true; foreach (GoObject obj in goView1.Document) { GoBasicNode n = obj as GoBasicNode; if (n != null) { if (n.UserFlags == 0) { n.Shape.PenColor = Color.Red; if (n.Shape.PenWidth == 2) { n.Shape.PenWidth = 4; } else { n.Shape.PenWidth = 2; } isWarn = true; //device.addSecondaryBufferAndPlay(Consts.SoundLocation, n.Text); } else { n.Shape.PenColor = Color.White; n.Shape.PenWidth = 2; //device.stopSecondaryBufferByName(n.Text); } if (n.ToolTipText.Contains("备")) { n.Shape.BrushForeColor = Color.Yellow; } else if (n.ToolTipText.Contains("主")) { n.Shape.FillShapeHighlight(Color.FromArgb(80, 180, 240), Color.FromArgb(255, 255, 255)); } } } goView1.Document.SkipsUndoManager = false; }
private void timerShakeBorder_Tick(object sender, System.EventArgs e) { goView.Document.SkipsUndoManager = true; foreach (GoObject obj in goView.Document) { GoBasicNode n = obj as GoBasicNode; if (n != null) { if (n.Shape.PenWidth == 2) { n.Shape.PenWidth = 4; } else { n.Shape.PenWidth = 2; } } } goView.Document.SkipsUndoManager = false; }
public FormDiagram(List <string[]> pre_data, List <KeyValuePair <int, float> > time_sequence) { InitializeComponent(); this.Text = Application.ProductName + " - Precedence Diagram"; rawData = pre_data; indexNumber = time_sequence.Count; nodes = new GoBasicNode[indexNumber]; links = new GoLink[rawData.Count]; timeSeq = time_sequence; createDiagram(rawData); #region Graph Data Test #region Adding Transformer GoBasicNode node = new GoBasicNode(); GoXmlBindingTransformer x = new GoXmlBindingTransformer("node", node); x.IdAttributeUsedForSharedObjects = true; x.TreeStructured = true; x.TreeLinkPrototype = new GoLink(); x.TreeLinksToChildren = true; x.AddBinding("label", "Text"); x.AddBinding("parent", "TreeParentNode"); #endregion GoXmlWriter w = new GoXmlWriter(); w.AddTransformer(x); w.Objects = goViewDiagram.Document; using (StreamWriter writer = new StreamWriter("output.xml")) { w.Generate(writer); } #endregion }
/// <summary> /// Create a GoBasicNode with random colors and editable middle label, /// and add it to the document at the given point. /// </summary> /// <param name="pt">the location of the new node (the center of the shape)</param> /// <param name="rectangular">whether the node has a rectangle shape instead of elliptical</param> /// <returns>a GoBasicNode</returns> private GoBasicNode InsertNode(PointF pt, bool rectangular, string title) { GoDocument doc = goView1.Document; doc.StartTransaction(); GoBasicNode n = new GoBasicNode(); n.LabelSpot = GoObject.Middle; n.Text = title; //(++myNodeCounter).ToString(); //if (rectangular) //n.Shape = new GoRectangle(); ; // specify the position and colors n.Location = pt; n.Brush = new SolidBrush(GetRandomColor(100)); n.Shape.PenColor = GetRandomColor(130); n.Shape.PenWidth = 3; // allow the user to edit the text in-place //n.Label.Editable = true; doc.Add(n); doc.FinishTransaction("inserted node"); return(n); }
public static GoBasicNode NewNode() { GoBasicNode state = new GoBasicNode(); state.LabelSpot = GoObject.Middle; state.Shape = new GoRoundedRectangle(); state.Shape.FillShapeHighlight(Color.FromArgb(80, 180, 240), Color.FromArgb(255, 255, 255)); state.Editable = false; state.Text = "state"; // state.Brush = new SolidBrush(Color.Black); state.Shape.PenColor = Color.White; state.Shape.PenWidth = 2; state.Label.EditableWhenSelected = false; state.Label.Editable = false; state.Label.Multiline = true; state.Port.IsValidDuplicateLinks = false; state.Port.IsValidSelfNode = false; state.Port.Editable = false; return(state); }
private void createZedgraph(GoBasicNode node) { LogHelper.Debug("create node:" + node.Text); form = new Form(); form.WindowState = FormWindowState.Maximized; zedgraph = new ZedgraphDemo(node.Text, logHelper); zedgraph.Ip = ip; zedgraph.Port = port; zedgraph.sendResult += new ZedgraphDemo.SendResult(zedgraph_sendResult); zedgraph.Dock = DockStyle.Fill; zedgraph.RequestSvrId = node.Text; zedgraph.IsPrintFillPage = false; zedgraph.IsPrintKeepAspectRatio = false; zedgraph.IsPrintScaleAll = false; zedgraph.IsShowCopyMessage = false; form.Controls.Add(zedgraph); zedgraph.connect(); form.Width = 100; form.Height = 100; //form.Show(this); }
private void createDiagram(List <string[]> rawData) { PointF ref_point = new PointF(100, 100); // Nodes Creation for (int i = 0; i < indexNumber; i++) { GoBasicNode node = new GoBasicNode(GoFigure.Circle); node.Text = timeSeq.ElementAt(i).Key.ToString(); node.Location = new PointF(ref_point.X + (i * 100), ref_point.Y); nodes[i] = node; } //Links Creation for (int i = 0; i < rawData.Count; i++) { GoLink link = new GoLink(); link.ToArrow = true; // getting associated node string[] dt = rawData.ElementAt(i); var nodesAquired = Array.FindAll(nodes, s => s.Text == dt[0]); var nodeTo = nodesAquired[0]; nodesAquired = Array.FindAll(nodes, s => s.Text == dt[1] && s.Text != "0"); if (nodesAquired.Length > 0) { var nodeFrom = nodesAquired[0]; link.FromPort = nodeFrom.Port; link.ToPort = nodeTo.Port; links[i] = link; } } // Add All Nodes to doc foreach (var item in nodes) { goViewDiagram.Document.Add(item); } // Add All Links to doc foreach (var item in links) { if (item != null) { goViewDiagram.Document.Add(item); } } // Perform layout GoLayoutTree layout = new GoLayoutTree(); layout.Document = goViewDiagram.Document; layout.PerformLayout(); foreach (var item in nodes) { PointF current = item.Location; item.Location = new PointF(current.X + 50, current.Y + 250); } }
public BasePort(GoBasicNode node, bool inverseShape) : this() { _inverseShape = inverseShape; BrushColor = Color.FromArgb(128, node.Shape.BrushColor); }
private void DFA_Painter(object sender, PaintEventArgs e) { GoView myView = new GoView(); myView.Dock = DockStyle.Fill; this.Controls.Add(myView); MFA myMFA = Program.globalMFA; //获取MFA的所有状态 String[] stateSet = getAllStateOfMFA(myMFA); int stateNum = stateSet.Length; //椭圆的个数 int[] startIDArray = new int[10]; //每一列的开始状态编号 startIDArray[0] = 0; for (int i = 1; i < 10; i++) { startIDArray[i] = startIDArray[i - 1] + i; //MessageBox.Show(startIDArray[i].ToString()); } GoBasicNode[] myNode = new GoBasicNode[stateNum]; for (int i = 0; i < stateNum; i++) { //创建节点 myNode[i] = new GoBasicNode(); myNode[i].Text = i.ToString(); myNode[i].Height = 50; myNode[i].Width = 50; myNode[i].Editable = false; myNode[i].Shape.BrushColor = Color.White; if (i == 0) { myNode[i].Shape.BrushColor = Color.Thistle; myNode[i].Height = 55; myNode[i].Width = 55; } //标记终态 if (myMFA.MFA_END.Contains(i.ToString())) { myNode[i].Shape.BrushColor = Color.Green; myNode[i].Height = 55; myNode[i].Width = 55; } //设置节点位置 int row = getPositionOfState(startIDArray, i)[0]; int column = getPositionOfState(startIDArray, i)[1]; float X = 0; float Y = 0; if (row % 2 != 0) { X = column * intervalHorizonal + row * 20; } else { X = column * intervalHorizonal - row * 20; } if (column % 2 == 0) { Y = row * intervalVertical + column * 20; } else { Y = row * intervalVertical - column * 20; } myNode[i].Position = new PointF(X, Y); //向GO视图中添加node控件 myView.Document.Add(myNode[i]); } //遍历MFA转换函数,向对应两个状态之间添加连线 foreach (transformFunction TF in myMFA.MFA_Transform) { //MessageBox.Show(TF.tranformInfo()); int from = int.Parse(TF.from); String by = TF.by; int to = int.Parse(TF.to); if (from == 34) { #region GoBasicNode node = new GoBasicNode(); node.Size = new SizeF(0, 0); node.Text = by; node.Shape.BrushColor = Color.White; //设置中间节点位置在from和to节点中间 node.Position = new PointF((myNode[from].Position.X + myNode[to].Position.X) / 2, (myNode[from].Position.Y + myNode[to].Position.Y) / 2); myView.Document.Add(node); #endregion GoLink link1 = new GoLink(); link1.ToArrow = false; link1.FromPort = myNode[from].Port; link1.ToPort = node.Port; link1.Style = GoStrokeStyle.RoundedLineWithJumpOvers; myView.Document.Add(link1); GoLink link2 = new GoLink(); link2.ToArrow = true; link1.Style = GoStrokeStyle.Bezier; link2.FromPort = node.Port; link2.ToPort = myNode[to].Port; link2.Style = GoStrokeStyle.RoundedLineWithJumpOvers; myView.Document.Add(link2); } else { GoLabeledLink link = new GoLabeledLink(); link.ToArrow = true; link.FromPort = myNode[from].Port; link.ToPort = myNode[to].Port; GoText text = new GoText(); text.Text = by; link.MidLabel = text; myView.Document.Add(link); } } GoText MFAInfoText = new GoText(); StringBuilder SB = new StringBuilder(); SB.Append("项目编号 项目族信息\r\n"); for (int i = 0; i < myMFA.stateSet.Length; i++) { SB.Append(i.ToString()); SB.Append(" "); foreach (String item in myMFA.stateSet[i].state) { SB.Append(item); SB.Append(";"); } SB.Append("\r\n"); } SB.Append("\r\n"); SB.Append("DFA转换函数"); SB.Append("\r\n"); foreach (transformFunction TF in myMFA.MFA_Transform) { SB.Append(TF.tranformInfo()); SB.Append("\r\n"); } MFAInfoText.Text = SB.ToString(); MFAInfoText.Multiline = true; MFAInfoText.Bold = true; MFAInfoText.AutoRescales = true; MFAInfoText.Position = new PointF(10, 50); myView.Document.Add(MFAInfoText); }
private string SvrRunInfo(CedaObject co) { string str = ""; if (co.Topic.Contains("YM.M.SI")) { SvrRunInfo sri = MsgHelper.Deserialize <SvrRunInfo>(co.MessageBody); if (!dicSvrRunInfo.ContainsKey(co.Topic)) { dicSvrRunInfo.Add(co.Topic, sri); } else { dicSvrRunInfo[co.Topic] = sri; } GoBasicNode node = getNodes(sri.ServiceName); if (node != null) { if (sri.WorkDes == "working" || sri.Connectioned == "ok") { node.UserFlags = 1; } else { node.UserFlags = 0; } node.ToolTipText = sri.Info; } List <string> lines = getNodeLines(sri.ServiceName); List <Line> cLines = sri.getClientLine(); foreach (var line in cLines) { if (lines.Contains(line.Key)) { AnimatedLink link = getLines(line.Key); if (link != null) { link.ToolTipText = line.Info; link.UserFlags = 1; lines.Remove(line.Key); } } else { TSvrRef s = new TSvrRef() { Servername_From = line.Servername_From, Servername_To = line.Servername_To }; addLine(s, Color.Yellow); } } foreach (var line in lines) { AnimatedLink link = getLines(line); if (link != null) { link.UserFlags = 0; link.ToolTipText = "已断开"; } } str = string.Format("Topic={0},MessageBody={1}", co.Topic, co.MessageBody); } return(str); }
private static List <WorkflowComponent> DefaultSccScheduleProvider(List <WorkflowComponent> components) { var allData = components.GetAllData(); // Nodes var dataNodes = new Dictionary <string, GoBasicNode>(); GoView tempView = new GoView(); foreach (Data data in allData) { var node = new GoBasicNode { Text = data.Id }; tempView.Document.Add(node); dataNodes[data.Id] = node; } foreach (Model model in components) { var node = new GoBasicNode { Text = model.Id }; tempView.Document.Add(node); // Links foreach (Data data in model.ModelDataInputs) { tempView.Document.Add(new GoLink { ToArrow = true, FromPort = dataNodes[data.Id].Port, ToPort = node.Port }); } foreach (Data data in model.ModelDataOutputs) { tempView.Document.Add(new GoLink { ToArrow = true, FromPort = node.Port, ToPort = dataNodes[data.Id].Port }); } } // automatically layout the graph GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph { Document = tempView.Document, DirectionOption = GoLayoutDirection.Down, SetsPortSpots = false, // for nicer looking links near single-Port nodes when not Orthogonal ColumnSpacing = 15, LayerSpacing = 10 }; layout.PerformLayout(); var modelLayersDictionary = new Dictionary <WorkflowComponent, int>(); foreach (GoLayoutLayeredDigraphNode node in layout.Network.Nodes) { if (node.GoObject is GoBasicNode n && components.FirstOrDefault(c => c.Id == n.Text) is WorkflowComponent wc) { modelLayersDictionary.Add(wc, node.Layer); } } var scheduledComponents = modelLayersDictionary.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key).ToList(); return(scheduledComponents); }