xnaandbeyond_src.zip
XnaAndBeyond_src
XNA GS and VS2008
Compilation
SharedXnaGameLibrary
Content
bin
x86
Debug
Release
Content.contentproj
MyFont.spritefont
obj
x86
Debug
Refactor
ResolveAssemblyReference.cache
TempPE
Release
Refactor
TempPE
Properties
SharedGameLibrary.csproj.user
XnaGameInControlSample.suo
XnaGameInWinForm
Game.ico
Properties
Settings.settings
XnaGameInWinForm.csproj.user
XnaGameInWinWpfWindow
Game.ico
Properties
Settings.settings
XnaGameInWinWpfWindow.csproj.user
XNA GS and WinForms (VS2005)
WindowsGame1
Content
bin
x86
Debug
Release
Content.contentproj
MyFont.spritefont
obj
x86
Debug
ResolveAssemblyReference.cache
TempPE
Release
TempPE
Game.ico
GameThumbnail.png
Properties
WindowsGame1.csproj.user
xnaandbeyond_src.zip.zip
XNA GS and VS2008
WindowsGame1.suo
WindowsGame1
bin
Debug
x86
Debug
Content
MyFont.xnb
WindowsGame1.exe
WindowsGame1.pdb
WindowsGame1.vshost.exe
WindowsGame1.vshost.exe.manifest
WindowsGame1_WPF.exe
WindowsGame1_WPF.pdb
WindowsGame1_WPF.vshost.exe
WindowsGameLibrary1.dll
WindowsGameLibrary1.pdb
Release
WindowsGame1.vshost.exe
WindowsGame1.vshost.exe.manifest
WindowsGame1_WPF.vshost.exe
WindowsGame1_WPF.vshost.exe.manifest
Game.ico
obj
Debug
TempPE
x86
Debug
ResolveAssemblyReference.cache
TempPE
WindowsGame1.csproj.GenerateResource.Cache
WindowsGame1.exe
WindowsGame1.Form1.resources
WindowsGame1.pdb
WindowsGame1.Properties.Resources.resources
Release
TempPE
Properties
Settings.settings
WindowsGame1.csproj.user
WindowsGame1_WPF
Game.ico
obj
x86
Debug
ResolveAssemblyReference.cache
TempPE
Properties.Resources.Designer.cs.dll
Window1.baml
WindowsGame1_WPF.csproj.GenerateResource.Cache
WindowsGame1_WPF.exe
WindowsGame1_WPF.g.resources
WindowsGame1_WPF.Properties.Resources.resources
WindowsGame1_WPF_MarkupCompile.cache
Properties
Settings.settings
WindowsGameLibrary1.suo
WindowsGameLibrary1
Content
bin
x86
Debug
Release
Content.contentproj
MyFont.spritefont
obj
x86
Debug
TempPE
Release
TempPE
obj
x86
Debug
TempPE
WindowsGameLibrary1.dll
WindowsGameLibrary1.pdb
Release
TempPE
WindowsGameLibrary1.dll
WindowsGameLibrary1.pdb
Properties
WpfApplication1
bin
Debug
WpfApplication1.vshost.exe
WpfApplication1.vshost.exe.manifest
obj
Debug
TempPE
Properties
Settings.settings
XNA GS and WinForms (VS2005)
WindowsGame1.suo
WindowsGame1
bin
x86
Debug
Content
MyFont.xnb
WindowsGame1.exe
WindowsGame1.pdb
Release
Content
bin
x86
Debug
Release
Content.contentproj
MyFont.spritefont
obj
x86
Debug
ResolveAssemblyReference.cache
TempPE
Release
TempPE
Game.ico
GameThumbnail.png
obj
x86
Debug
Refactor
ResolveAssemblyReference.cache
TempPE
WindowsGame1.csproj.GenerateResource.Cache
WindowsGame1.exe
WindowsGame1.Form1.resources
WindowsGame1.pdb
Release
TempPE
Properties
WindowsGame1.csproj.user
xnaonawebsite_src.zip
XnaOnAWebSite_src
Extras
WindowsGameLibrary1
Content
bin
x86
Debug
Release
Content.contentproj
MyFont.spritefont
obj
x86
Debug
TempPE
Properties
WindowsGameLibrary1.csproj.user
XnaGameControl
Properties
XnaGame.csproj.user
XnaGameKeyFile.snk
XnaOnWebSite
App_Data
Content
MyFont.xnb
Properties
WindowsGameLibrary1.dll
WindowsGameLibrary1.pdb
XnaOnWebSite.csproj.user
|
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using SysWinForms = System.Windows.Forms; // to avoid conflicts with namespaces
namespace WindowsGame1_WPF
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class SampleGameInWpfWindow : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont Font1;
Vector2 FontPos;
IntPtr myXnaControlHandle;
public SampleGameInWpfWindow( IntPtr myXnaControlHandle )
{
graphics = new GraphicsDeviceManager( this );
Content.RootDirectory = "Content";
this.myXnaControlHandle = myXnaControlHandle;
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
SysWinForms.Form gameWindowForm = ( SysWinForms.Form )SysWinForms.Form.FromHandle( this.Window.Handle );
gameWindowForm.Shown += new EventHandler( gameWindowForm_Shown );
gameWindowForm.Opacity = 0.0;
base.Initialize();
}
void gameWindowForm_Shown( object sender, EventArgs e )
{
( ( SysWinForms.Form )sender ).Hide();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch( GraphicsDevice );
Font1 = Content.Load<SpriteFont>( "MyFont" );
// TODO: Load your game content here
FontPos = new Vector2( graphics.GraphicsDevice.Viewport.Width / 2,
graphics.GraphicsDevice.Viewport.Height / 2 );
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update( GameTime gameTime )
{
// Allows the game to exit
if ( GamePad.GetState( PlayerIndex.One ).Buttons.Back == ButtonState.Pressed )
this.Exit();
// TODO: Add your update logic here
base.Update( gameTime );
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw( GameTime gameTime )
{
graphics.GraphicsDevice.Clear( Color.CornflowerBlue );
spriteBatch.Begin();
// Draw the current date and time
string output = DateTime.Now.ToString();
// Find the center of the string
Vector2 FontOrigin = Font1.MeasureString( output ) / 2;
// Draw the string
spriteBatch.DrawString( Font1, output, FontPos, Color.LightGreen,
0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f );
spriteBatch.End();
base.Draw( gameTime );
// This one will do the trick we are looking for!
this.GraphicsDevice.Present( this.myXnaControlHandle );
}
/// <summary>
/// Ends the drawing of a frame. This method is preceeded by calls to Game.Draw and Game.BeginDraw.
/// </summary>
protected override void EndDraw()
{
//base.EndDraw();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.