// Assume the header is at the top, and the lifeline stroke and port extend down // from the middle of the bottom of the header. // The Lifeline's Activations are arranged vertically according to their Begin // and End step values. // The stroke and port are just tall enough to accomodate all Activations and all // Messages that connect to this Lifeline. public override void LayoutChildren(GoObject childchanged) { if (this.Initializing) { return; } if (this.Count < 3) { return; } GoObject header = this[0]; GoStroke line = this[1] as GoStroke; GoObject port = this[2]; PointF p = header.GetSpotLocation(MiddleBottom); // find last step of an Activation on this Lifeline or a Message connected to this Lifeline float maxend = 0; foreach (GoObject child in this) { Activation act = child as Activation; if (act != null) { act.SetSpotLocation(MiddleTop, GetStepPoint(act.Begin)); act.Height = Math.Max(10, (act.End - act.Begin) * MessageSpacing); maxend = Math.Max(maxend, act.End); } } foreach (IGoLink link in this.Port.Links) { Message msg = link as Message; if (msg != null) { maxend = Math.Max(maxend, msg.Step); } } // line connects to bottom of header line.SetPoint(0, p); line.SetPoint(1, new PointF(p.X, LineStart + maxend * MessageSpacing)); // port always starts at LineStart port.Bounds = new RectangleF(p.X - port.Width / 2, LineStart, port.Width, maxend * MessageSpacing); }
internal PointF GetSideLinkPoint(GoBoxPortLinkInfo info) { GoObject goObject = PortObject; if (goObject == null || goObject.Layer == null) { goObject = this; } PointF spotLocation; PointF spotLocation2; switch (info.Side) { case 128: spotLocation = goObject.GetSpotLocation(8); spotLocation2 = goObject.GetSpotLocation(16); break; case 256: spotLocation = goObject.GetSpotLocation(16); spotLocation2 = goObject.GetSpotLocation(2); break; case 32: spotLocation = goObject.GetSpotLocation(2); spotLocation2 = goObject.GetSpotLocation(4); break; default: spotLocation = goObject.GetSpotLocation(4); spotLocation2 = goObject.GetSpotLocation(8); break; } float num = spotLocation2.X - spotLocation.X; float num2 = spotLocation2.Y - spotLocation.Y; float num3 = ((float)info.IndexOnSide + 1f) / ((float)info.CountOnSide + 1f); return(new PointF(spotLocation.X + num * num3, spotLocation.Y + num2 * num3)); }
/// <summary> /// Determine the link point by judging where the link is coming /// from, and at what angle. /// </summary> /// <param name="link"></param> /// <returns>a <c>PointF</c> on the edge of the port, in document coordinates</returns> public override PointF GetToLinkPoint(IGoLink link) { GoObject goObject = PortObject; if (goObject == null || goObject.Layer == null) { goObject = this; } if (ToSpot != 0 && ToSpot != 1) { return(goObject.GetSpotLocation(ToSpot)); } if (link == null || link.GoObject == null) { return(goObject.Center); } if (LinkPointsSpread) { GoBoxPortLinkInfo[] linkInfos = GetLinkInfos(); foreach (GoBoxPortLinkInfo goBoxPortLinkInfo in linkInfos) { if (goBoxPortLinkInfo.Link == link) { return(goBoxPortLinkInfo.LinkPoint); } } } int toSides = ToSides; switch (toSides) { case 128: return(goObject.GetSpotLocation(128)); case 256: return(goObject.GetSpotLocation(256)); case 32: return(goObject.GetSpotLocation(32)); case 64: return(goObject.GetSpotLocation(64)); default: { float num = GetAngle(link); switch (toSides) { case 160: if (num > 180f) { return(goObject.GetSpotLocation(32)); } return(goObject.GetSpotLocation(128)); case 320: if (num > 90f && num <= 270f) { return(goObject.GetSpotLocation(256)); } return(goObject.GetSpotLocation(64)); default: { float num2 = (float)(Math.Atan2(goObject.Height, goObject.Width) * 180.0 / Math.PI); switch (toSides) { case 288: if (num > num2 && num <= 180f + num2) { return(goObject.GetSpotLocation(256)); } return(goObject.GetSpotLocation(32)); case 96: if (num > 180f - num2 && num <= 360f - num2) { return(goObject.GetSpotLocation(32)); } return(goObject.GetSpotLocation(64)); case 192: if (num > num2 && num <= 180f + num2) { return(goObject.GetSpotLocation(128)); } return(goObject.GetSpotLocation(64)); case 384: if (num > 180f - num2 && num <= 360f - num2) { return(goObject.GetSpotLocation(256)); } return(goObject.GetSpotLocation(128)); case 352: if (num > 90f && num <= 180f + num2) { return(goObject.GetSpotLocation(256)); } if (num > 180f + num2 && num <= 360f - num2) { return(goObject.GetSpotLocation(32)); } return(goObject.GetSpotLocation(64)); case 224: if (num > 180f && num <= 360f - num2) { return(goObject.GetSpotLocation(32)); } if (num > num2 && num <= 180f) { return(goObject.GetSpotLocation(128)); } return(goObject.GetSpotLocation(64)); case 448: if (num > num2 && num <= 180f - num2) { return(goObject.GetSpotLocation(128)); } if (num > 180f - num2 && num <= 270f) { return(goObject.GetSpotLocation(256)); } return(goObject.GetSpotLocation(64)); case 416: if (num > 180f - num2 && num <= 180f + num2) { return(goObject.GetSpotLocation(256)); } if (num > 180f + num2) { return(goObject.GetSpotLocation(32)); } return(goObject.GetSpotLocation(128)); default: { if (IsOrthogonal(link) && toSides != 480) { num += 15f; if (num >= 360f) { num -= 360f; } } int num3 = 1; num3 = ((num > num2 && num < 180f - num2) ? 128 : ((num >= 180f - num2 && num <= 180f + num2) ? 256 : ((!(num > 180f + num2) || !(num < 360f - num2)) ? 64 : 32))); return(goObject.GetSpotLocation(num3)); } } } } } } }