using System; using System.Drawing; using HeuristicLab.Visualization; using Rectangle = HeuristicLab.Visualization.Rectangle; namespace HeuristicLab.EvolutionaryTracking.Views { public class VisualGenealogyGraphTextLabel : Rectangle { private string text; public string Text { get { return text; } set { text = value; } } private Font font; public Font Font { get { return font; } set { font = value; } } private Brush brush; public Brush Brush { get { return brush; } set { brush = value; } } public VisualGenealogyGraphTextLabel(IChart chart, PointD lowerLeft, PointD upperRight) : base(chart, lowerLeft, upperRight) { } public VisualGenealogyGraphTextLabel(IChart chart, double x1, double y1, double x2, double y2) : this(chart, new PointD(x1, y1), new PointD(x2, y2)) { } public VisualGenealogyGraphTextLabel(IChart chart, PointD lowerLeft, PointD upperRight, Pen pen, Brush brush) : base(chart, lowerLeft, upperRight, pen, brush) { } public VisualGenealogyGraphTextLabel(IChart chart, double x1, double y1, double x2, double y2, Pen pen, Brush brush) : this(chart, new PointD(x1, y1), new PointD(x2, y2), pen, brush) { } public override void Draw(Graphics graphics) { Point p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height)); Size s = Chart.TransformWorldToPixel(Size); float fontSize = s.Height; font = new Font(font.Name, fontSize, Font.Style, GraphicsUnit.Pixel); graphics.DrawString(text, font, brush, p.X, p.Y); } public EventHandler Update; protected virtual void OnUpdate() { if ((UpdateEnabled) && (Update != null)) { Update(this, new EventArgs()); } base.OnUpdate(); } } }