0

I am trying to use the PDFsharp library in an XNA game. The example code I am trying to get to work is:

 static void Main() 
    {
      Renderer renderer = new Renderer();
      PreviewForm form = new PreviewForm();
      form.RenderEvent = new PagePreview.RenderEvent(renderer.Render);
      Application.Run(form);
    }

But I don't know how to get this to run in XNA.

Is it possible to pass the graphics that are passed to the winform to the XNA graphics engine instead?

Austin
  • 3
  • 2

2 Answers2

0

The First thing you need to do is to create the login form. in this form create the fields you need as public properties

public string userName {get;set;} 
public string password {get;set;}

in the login form you need to write the user info to those properties:

private void btnOk_Click(object sender,EventArgs e)
{
    this.userName = txtName.Text;
    this.password = txtPass.Text;
    this.Close();
}

then, in the game (in the part you need) write something like this:

using (var form = new frmLogin())
{
    var result = form.ShowDialog();
    if (result == DialogResult.OK)
    {
        string user = form.userName;
        string pass = form.password;
    }
}

But as an FYI - winforms don't look so good in XNA Hope it helps

YuriG
  • 368
  • 3
  • 14
0

update 2

It appears that the original links to MSDN have been broken, I can't seem to find them on MSDN anymore, if someone does, please update the post. In the mean time you may want to check out this codeproject article -- http://www.codeproject.com/Articles/21330/Easy-Rendering-with-XNA-Inside-a-Windows-Form

update after a quick check, looks like the first link at (See also: XNA and WinForms) is the same one I found.

I recommend you look into mixing winforms and XNA, try this: http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1

Community
  • 1
  • 1
Nate
  • 30,286
  • 23
  • 113
  • 184
  • @user1306322 I have updated my post with another link and a request for anyone who finds the new location of the broken link to update the post. – Nate Jan 22 '13 at 16:01