protected override void OnPaint(PaintEventArgs e) { if (_labelVisible && root != null) { MathNode mv = var as MathNode; if (mv != null) { SizeF s = mv.CalculateDrawSize(e.Graphics); this.Size = new Size((int)s.Width, (int)s.Height); mv.Draw(e.Graphics); } } }