This is my code:
[code]using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Orbs;
namespace Begy_Modeler
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{
//variables
public Control[] Particles = new Control[200];
public int n = 0;
public MainForm()
{
InitializeComponent();
InitializeSpace();
}
public void InitializeSpace()
{
Space.Focus();
Graphics G;
G = Space.CreateGraphics();
Pen SpacePen = new Pen(Color.White);
G.DrawLine(SpacePen, Space.Width/2,0,Space.Width/2, Space.Height/2);
}
public void CreateParticle()
{
if(n<200)
{
Particles[n] = new Orb
{
Top = 10 * n,
Left = 10 * n,
Width = 10,
Height = 10,
BackColor = Color.Transparent,
BackgroundImage = new Bitmap("Proton.png"),
Visible = true
};
Space.Controls.Add(Particles[n]);
Particles[n].Show();
n++;
}
}
void ToolStripButton1Click(object sender, EventArgs e)
{
CreateParticle();
}
}
}[/code]
When I click and add a new "Particle" I get a "Parameter is not valid" error... I am sure someone has an answer, I am new at creating and accessing system resources. Thx!