All pastes #767632 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-09 22:30 UTC
rendered paste body
using System;
using System.Drawing;
using System.Windows.Forms;

class MainForm : Form
{
	[STAThread]
	static void Main ()
	{
		Application.Run (new MainForm ());
	}

	protected override void OnPaint (PaintEventArgs pevent)
	{
		base.OnPaint (pevent);
		
		Graphics g = pevent.Graphics;
		String s = "The quick brown fox jumped over the lazy dogs.";

		// Regular
		Rectangle r1 = new Rectangle (0, 0, 100, 14);
		g.DrawRectangle (Pens.Red, r1);
		g.DrawString (s, Font, Brushes.Black, r1);
		g.DrawString ("Regular", Font, Brushes.Black, 110, 5);
		
		// Line Limit
		Rectangle r2 = new Rectangle (0, 40, 100, 14);
		StringFormat sf = new StringFormat ();
		sf.Trimming = StringTrimming.EllipsisCharacter;
		g.DrawRectangle (Pens.Red, r2);
		g.DrawString (s, Font, Brushes.Black, r2, sf);
		g.DrawString ("Line Limit - 2 Lines", Font, Brushes.Black, 110, 45);

		// Line Limit - Not enough room for any lines
		Rectangle r3 = new Rectangle (0, 80, 100, 14);
		g.DrawRectangle (Pens.Red, r3);
		g.DrawString (s, Font, Brushes.Black, r3, sf);
		g.DrawString ("Line Limit - 1 Line", Font, Brushes.Black, 110, 85);
	}
}