Click here to Skip to main content
16,004,686 members
Home / Discussions / C#
   

C#

 
GeneralRe: regex exclusion Pin
Christian Graus17-Mar-05 12:29
protectorChristian Graus17-Mar-05 12:29 
GeneralRe: regex exclusion Pin
Anonymous17-Mar-05 12:33
Anonymous17-Mar-05 12:33 
GeneralRe: regex exclusion Pin
Anonymous17-Mar-05 12:30
Anonymous17-Mar-05 12:30 
GeneralRe: regex exclusion Pin
Christian Graus17-Mar-05 12:38
protectorChristian Graus17-Mar-05 12:38 
GeneralRe: regex exclusion Pin
Anonymous17-Mar-05 12:41
Anonymous17-Mar-05 12:41 
GeneralSeperate Thread Crash when Right Click in Windows Task Bar Pin
Tristan Rhodes17-Mar-05 10:40
Tristan Rhodes17-Mar-05 10:40 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Heath Stewart17-Mar-05 14:38
protectorHeath Stewart17-Mar-05 14:38 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Tristan Rhodes17-Mar-05 23:56
Tristan Rhodes17-Mar-05 23:56 
All the graphics are double buffered on a seperate thread.

The OnPaint event of the control calls the enviroment with a graphics handler:

My enviroment contains the following code:

<br />
		public void RenderEnviroment(Graphics g, int width, int height)<br />
		{<br />
			Image i = new Bitmap(width,height);<br />
			Graphics gfx = Graphics.FromImage(i);<br />
			<br />
			int buffer = 5;<br />
			gfx.FillRectangle(new SolidBrush(Color.Black),0,0,buffer+(buffer+100)*WIDTH, buffer+(buffer+100)*HEIGHT);<br />
<br />
			for (int x=1;x<WIDTH-1;x++)<br />
			{<br />
				for(int y=1;y<HEIGHT-1;y++)<br />
				{<br />
					Tile t = this.g_Enviroment[x,y];<br />
					if (t != null)<br />
						gfx.DrawImage(t.TileImage,buffer + (100*(x-1)) + (buffer*(x-1)),buffer + (100*(y-1)) + (buffer*(y-1)));<br />
				}<br />
			}<br />
<br />
			gfx.DrawString("Permutations Tested: " + permChecked.ToString(),<br />
				new Font(FontFamily.GenericMonospace,14),<br />
				new SolidBrush(Color.White),<br />
				buffer,height-100);<br />
<br />
			g.DrawImage(i,0,0);<br />
		}<br />


This is called from the OnPaint method of my form, where env is a gloval Enviroment variable:

<br />
		protected override void OnPaint(PaintEventArgs e)<br />
		{<br />
			env.RenderEnviroment(e.Graphics,this.ClientRectangle.Width,this.ClientRectangle.Height);<br />
			Thread.Sleep(100);<br />
			<br />
			Region r = env.GetInvalidatedRegion();<br />
			this.Invalidate(r);<br />
		}<br />


The Tree is largely irellevant, as it runs on a seperate thread and does not interact with the form at any point. Enviroment contains a 2D grid, which is modified by the spawned thread, but is only read by the Painting thread.

Hope that helps

Cata
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Heath Stewart18-Mar-05 8:28
protectorHeath Stewart18-Mar-05 8:28 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Tristan Rhodes20-Mar-05 4:21
Tristan Rhodes20-Mar-05 4:21 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Heath Stewart20-Mar-05 6:08
protectorHeath Stewart20-Mar-05 6:08 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Tristan Rhodes20-Mar-05 10:00
Tristan Rhodes20-Mar-05 10:00 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Heath Stewart20-Mar-05 11:37
protectorHeath Stewart20-Mar-05 11:37 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Tristan Rhodes20-Mar-05 13:22
Tristan Rhodes20-Mar-05 13:22 
GeneralRe: Seperate Thread Crash when Right Click in Windows Task Bar Pin
Heath Stewart22-Mar-05 2:31
protectorHeath Stewart22-Mar-05 2:31 
GeneralNetwork programming Pin
felopater17-Mar-05 10:19
felopater17-Mar-05 10:19 
GeneralRe: Network programming Pin
Heath Stewart17-Mar-05 14:30
protectorHeath Stewart17-Mar-05 14:30 
GeneralRe: Network programming Pin
felopater18-Mar-05 10:52
felopater18-Mar-05 10:52 
GeneralRe: Network programming Pin
Heath Stewart18-Mar-05 20:06
protectorHeath Stewart18-Mar-05 20:06 
QuestionXMLSerializer and a collection of collections? Pin
Kasdoffe17-Mar-05 10:10
Kasdoffe17-Mar-05 10:10 
AnswerRe: XMLSerializer and a collection of collections? Pin
Kasdoffe17-Mar-05 10:13
Kasdoffe17-Mar-05 10:13 
GeneralCrystal Reports .NET Pin
SignMan35917-Mar-05 9:02
SignMan35917-Mar-05 9:02 
GeneralRe: Crystal Reports .NET Pin
Heath Stewart17-Mar-05 14:34
protectorHeath Stewart17-Mar-05 14:34 
GeneralProperty question Pin
thepersonof17-Mar-05 6:52
thepersonof17-Mar-05 6:52 
GeneralRe: Property question Pin
DavidNohejl17-Mar-05 7:08
DavidNohejl17-Mar-05 7:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.