public override IGoLink CreateLink(IGoPort from, IGoPort to) { IGoLink il = base.CreateLink(from, to); if (il != null) { GoLabeledLink l = il.GoObject as GoLabeledLink; if (l != null) { GraphNode fromNode = from.Node.GoObject as GraphNode; if (fromNode != null && fromNode.Kind == GraphNodeKind.Decision) { GoText t = new GoText(); t.Text = "yes"; t.Selectable = false; t.Editable = true; l.FromLabel = t; } l.Orthogonal = true; l.Style = GoStrokeStyle.RoundedLine; l.ToArrow = true; } } return(il); }
public HostLink(Flow flow, GoLabeledLink link) { if (!flow.IsLocalA) { Status = LinkStatus.OutLocal; } else if (!flow.IsLocalB) { Status = LinkStatus.LocalOut; } Link = link; Flows.Add(flow); }
public void SendTopology(RouterNode node, GoLabeledLink link) { List <TopologyEntry> tempTable; lock (tablesLock) { tempTable = TopologyTable.ToList(); } foreach (var topology in TopologyTable) { node.AddTopology(new TopologyEntry(topology.Destination, Text, topology.Feasible + link.UserFlags, topology.Feasible)); } }
private GoLabeledLink getMapLink(GoIconicNode n1, GoIconicNode n2) { GoLabeledLink link = new GoLabeledLink(); link.Style = GoStrokeStyle.Bezier; link.ToolTipText = n1.Text + ", " + n2.Text; link.ToArrow = true; link.ToArrowLength = 9; link.ToArrowShaftLength = 6; link.ToArrowFilled = true; link.Shadowed = false; n1.Port.AddDestinationLink(link); n2.Port.AddSourceLink(link); return(link); }
public async Task ReceiveHello(RouterNode sender, GoLabeledLink link) { var existing = NeighborhoodTable.FirstOrDefault(n => n.Address.Equals(sender.Text)); if (existing != null) { existing.ExtendHold(); } else { AddNeighbor(sender, link.UserFlags); sender.AddNeighbor(this, link.UserFlags); await Task.Delay(200); await SendAckTo(sender, link); } }
/// <summary> /// Determine the angle the port at the other end makes with this port. /// </summary> /// <param name="link"></param> /// <returns>the angle in degrees</returns> public virtual float GetAngle(IGoLink link) { if (link == null) { return(0f); } IGoPort goPort = link.GetOtherPort(this); if (goPort == null) { if (link.FromPort != null && link.FromPort.GoObject != null && link.FromPort.GoObject.Bounds == Bounds) { goPort = link.ToPort; } else if (link.ToPort != null && link.ToPort.GoObject != null && link.ToPort.GoObject.Bounds == Bounds) { goPort = link.FromPort; } } if (goPort == null) { return(0f); } GoObject goObject = goPort.GoObject; if (goObject == null) { return(0f); } PointF pointF = goObject.Center; PointF center = base.Center; GoLink goLink = link as GoLink; if (goLink == null) { GoLabeledLink goLabeledLink = link as GoLabeledLink; if (goLabeledLink != null) { goLink = goLabeledLink.RealLink; } } if (goLink != null && goLink.PointsCount > 0) { pointF = ((goLink.FromPort != goPort) ? goLink.GetPoint(checked (goLink.PointsCount - 1)) : goLink.GetPoint(0)); } return(GoStroke.GetAngle(pointF.X - center.X, pointF.Y - center.Y)); }
private async Task SendAckTo(RouterNode node, GoLabeledLink link) { try { lock (link.UserObject) { link.PenColor = Color.Green; SendTopology(node, link); node.SendTopology(this, link); //TakeTopologyTable(node.TopologyTable, node.Text, link, Guid.NewGuid()); //node.TakeTopologyTable(TopologyTable, Text, link, Guid.NewGuid()); Task t = Task.Delay(100); t.Wait(); link.PenColor = Color.Black; } } catch (InvalidAsynchronousStateException) { } }
private async Task SendHelloTo(RouterNode destination) { try { GoLabeledLink link = Links.FirstOrDefault(l => l.ToNode.Equals(destination) || l.FromNode.Equals(destination)) as GoLabeledLink; if (link.UserFlags < 1) { return; } await destination.ReceiveHello(this, link); while (link.PenColor != Color.Black) { await Task.Delay(50); } link.PenColor = Color.Red; await Task.Delay(100); link.PenColor = Color.Black; } catch (InvalidAsynchronousStateException) { } }
public override IGoLink CreateLink(IGoPort from, IGoPort to) { IGoLink il = base.CreateLink(from, to); if (il != null) { GoLabeledLink l = il.GoObject as GoLabeledLink; if (l != null) { FlowBlock fromNode = from.Node.GoObject as FlowBlock; if (fromNode != null && fromNode.Kind == BlockType.Condition) { GoText t = new GoText(); t.Text = "yes"; t.Selectable = false; t.Editable = true; l.FromLabel = t; } //l.Orthogonal = true; //l.Style = GoStrokeStyle.RoundedLine; //l.ToArrow = true; } } return il; }
public override IGoLink CreateLink(IGoPort from, IGoPort to) { IGoLink il = base.CreateLink(from, to); if (il != null) { GoLabeledLink l = il.GoObject as GoLabeledLink; if (l != null) { GraphNode fromNode = from.Node.GoObject as GraphNode; if (fromNode != null /* && fromNode.Kind == "Decision"*/) { GoText t = new GoText(); t.Text = ""; t.Selectable = false; t.Editable = true; l.MidLabel = t; //(l as GraphLink).FromOrTo = "To"; } //GraphNode toNode = to.Node.GoObject as GraphNode;//bylzydecision //if (toNode != null && toNode.Kind == "Decision") //{ // GoText t = new GoText(); // t.Text = "y"; // t.Selectable = false; // t.Editable = true; // l.MidLabel = t; // //(l as GraphLink).FromOrTo = "From"; //} //l.Orthogonal = true; //l.Style = GoStrokeStyle.RoundedLine; //l.ToArrow = true; } } return(il); }
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); }