public void Draw(Graphics g, DiagramPainter dp, ReferenceStyle style) { Pen pen = dp.GetPen(style.LineColor, style.LineWidth); if (style.LineWay == LineWayType.Rectangular) { if (Vector2D.AngleBetween(StartVec, EndVec) < 0.1) // asi to bude rovnobezne { /* * Start beglev * * m1 m2 * * endlev End */ Point2D beglev = new Line2D(Start, StartVec.NormalVector).ComPoint(new Line2D(End, EndVec)) ?? new Point2D(); Point2D endlev = new Line2D(End, EndVec.NormalVector).ComPoint(new Line2D(Start, StartVec)) ?? new Point2D(); Point2D m1 = Start + (endlev - Start) / 2; Point2D m2 = beglev + (End - beglev) / 2; g.DrawLine(pen, (Point)Start, (Point)m1); g.DrawLine(pen, (Point)m1, (Point)m2); g.DrawLine(pen, (Point)m2, (Point)End); ReferencePainter.DrawArrow(dp, g, (Point)m2, (Point)End, style.Arrow); } else { /* * Start * * * m End */ Point2D m = new Line2D(Start, StartVec).ComPoint(new Line2D(End, EndVec)) ?? new Point2D(); g.DrawLine(pen, (Point)Start, (Point)m); g.DrawLine(pen, (Point)m, (Point)End); ReferencePainter.DrawArrow(dp, g, (Point)m, (Point)End, style.Arrow); } } if (style.LineWay == LineWayType.Direct) { g.DrawLine(pen, Start, End); ReferencePainter.DrawArrow(dp, g, (Point)Start, (Point)End, style.Arrow); } }
public void Draw(Graphics g) { bool again = false, wasdraw = false;; do { again = false; using (DiagramPainter dp = new DiagramPainter(this, g)) { try { if (m_styleChanged) { throw new DiagramEntityDrawNeededException(); } ReferencePainter.DrawReferences(this, g, dp, Style.Reference); } catch (DiagramEntityDrawNeededException) { if (wasdraw) { throw; } again = true; } Size = new Size(0, 0); int minx = Int32.MaxValue, miny = Int32.MaxValue; foreach (DiagramTableItem item in Tables) { item.Draw(dp); if (item.X + item.Size.Width > Size.Width) { Size.Width = item.X + item.Size.Width; } if (item.Y + item.Size.Height > Size.Height) { Size.Height = item.Y + item.Size.Height; } if (item.X < minx) { minx = item.X; } if (item.Y < miny) { miny = item.Y; } } if (minx < Int32.MaxValue && miny < Int32.MaxValue && minx > 3 && miny > 3) { Size.Width += minx; Size.Height += miny; } else { Size.Width += 3; Size.Height += 3; } } m_styleChanged = false; wasdraw = true; } while (again); }