public Link(int s, int t, BreadQueue br) { if (s > t) { source = t; target = s; } else { source = s; target = t; } boundRectangle = new RectangleF(Math.Min(br.PointList.Locations[source].X, br.PointList.Locations[target].X), Math.Min(br.PointList.Locations[source].Y, br.PointList.Locations[target].Y), Math.Abs(br.PointList.Locations[s].X - br.PointList.Locations[t].Y), Math.Abs(br.PointList.Locations[s].X - br.PointList.Locations[t].Y)); key = ((ulong) source) << 32 | (ulong) target; }
private void InitializeOpen() { float minX = float.MaxValue, minY = float.MaxValue, maxX = float.MinValue, maxY = float.MinValue; YPos = -1; XPos= -1; LinksUniquePos = -1; LoopPos = -1; AgentIdPos = -1; sr = new StreamReader(txtFile.Text); if (hasHeaders.Checked) { string header = sr.ReadLine(); string [] headerParts = header.Split('\t'); for (int n = 0; n < headerParts.Length;n++) { if (headerParts[n].ToLower() == "linksunique") LinksUniquePos = n; if (headerParts[n].ToLower() == "loop") LoopPos = n; if (headerParts[n].ToLower() == "x") XPos = n; if (headerParts[n].ToLower() == "y") YPos = n; if (headerParts[n].ToLower() == "agentid") AgentIdPos = n; } headersLength = headerParts.Length; } if (LinksUniquePos == -1) { DoStop(); throw new Exception("Could not find the LinksUnique column at file headers"); } if (LoopPos == -1) { DoStop(); throw new Exception("Could not find the Loop column at file headers"); } if (XPos == -1) { DoStop(); throw new Exception("Could not find the X column at file headers"); } if (YPos == -1) { DoStop(); throw new Exception("Could not find the Y column at file headers"); } if (AgentIdPos == -1) { DoStop(); throw new Exception("Could not find the AgentId column at file headers"); } prevline = ""; // Lee toda una generación para ubicar los links br = new BreadQueue(); br.zoom = (float) zoom.Value; br.useRect = checkBox1.Checked; br.drawHeight = pictureBox1.Height; br.drawWidth = pictureBox1.Width; PointList pl = new PointList(); br.PointList = pl; // Le pone puntos // Trae hasta cambiar de loop string line = prevline; string [] parts; string links; int loop = -1; int lastLoop = -1; float x; float y; ArrayList ArrayPoints = new ArrayList(); LinkPos = new Hashtable(); while(true) { line = sr.ReadLine(); parts = line.Split('\t'); if (parts.Length < headersLength) break; x = float.Parse(parts[XPos]); y = float.Parse(parts[YPos]); if (x< minX) minX = x; if (y< minY) minY = y; if (x> maxX) maxX = x; if (y> maxY) maxY = y; // Guarda int id = Int32.Parse(parts[AgentIdPos].Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier); LinkPos[id] = (int)ArrayPoints.Count; ArrayPoints.Add(new PointF(x, y)); // Avanza... loop = Int32.Parse(parts[LoopPos]); if (loop != lastLoop) { if (lastLoop != -1) break; lastLoop = loop; } } sr.Close(); sr = new StreamReader(txtFile.Text); sr.ReadLine(); lastLoop = -1; // Los pasa a la oficial pl.Locations = (PointF []) ArrayPoints.ToArray(typeof(PointF));// new Point[ArrayPoints.Count]; /*for (int n = 0; n < ArrayPoints.Count; n++) { pl.Locations[n] = (Point) ArrayPoints[n]; }*/ br.minX = minX - 2; br.minY = minY - 2; br.maxX = maxX + 2; br.maxY = maxY + 2; }