I'm trying to put in a new feature into my level editor. Part of the feature is to bring up a form when a user places a new tile onto the map, but once the form is brought up the XNA embedded screen throws up a big red X. I think this is due to the embedded screen losing focus to the form and then crashing.
This is where the form is initialized
public Form1()
{
InitializeComponent();
//Node Editor
tileDisplay1.OnInitialize += new EventHandler(tileDisplay1_OnInitialize);
tileDisplay1.OnDraw += new EventHandler(tileDisplay1_OnDraw);
Microsoft.Xna.Framework.Input.Keys[] allKeys = (Microsoft.Xna.Framework.Input.Keys[])
Enum.GetValues(typeof(Microsoft.Xna.Framework.Input.Keys));
foreach (var key in allKeys)
KeyboardInput.AddKey(key);
KeyboardInput.KeyRelease += new KeyHandler(KeyboardInput_KeyRelease);
MouseInput.MouseMove += new MouseMoveHandler(MouseInput_MouseMove);
MouseInput.MouseDown += new MouseClickHandler(MouseInput_MouseDown);
MouseInput.MouseUp += new MouseClickHandler(MouseInput_MouseUp);
Application.Idle += delegate { tileDisplay1.Invalidate(); };
saveFileDialog1.Filter = "Map File|*.map";
Mouse.WindowHandle = tileDisplay1.Handle;
}
This is where the draw event is fired off
void tileDisplay1_OnDraw(object sender, EventArgs e)
{
Logic();
Render();
KeyboardInput.Update();
MouseInput.Update();
foreach (var actor in Actor.Actors)
actor.Update();
}
This is where the form is being called
private void Logic()
{
if (colIndex == 8 && AssociateBox.SelectedIndex == 0)
{
currentCollisionLayer.SetCellIndex(collideCellX, collideCellY,form.spawnNumber.ToString());
if(form.spawnNumber == "12")
{
camdetails.ShowDialog();
}
}
}