Website may be up and down over next few months. I'm currently doing a complete overhaul of everything. Going back to simple individual .htm pages, new overall site theme, sanitizing and cleaning up html of all pages and blog posts, attempting to implement a new tooling and publishing system etc etc.

I just gotta say DAM! Linq and Extension methods in .NET are cool. Not only do they get cooler the more you use them they make your code much easier to read and thus understand what is going on.

I was going back and refactoring my classes for reading various xml asset files for a silverlight game I am working on, and I have reduced the number of lines of code needed to read/write xml files by over half. The only problem I have now is trying to fight off those bad habits of writing code the old way. Just felt like sharing :P

I'm going to try to get the game uploaded to this site as soon as i get a little more work done on it.


Have not made any posts latley but have been pre occupied with other things. Firstly, me and my brother are trying to create a game for facebook similar to the Mafia Wars and Age of Castles games. Coding the game is easy. Comming up with a theme and content for the game .... not so easy :(

I have also been doing some programming in silverlight and playing around with making a RTS type game simlilar to the old warcraft 1/2/3 games. Part way through tweaking the games AI, I decided to refactor the whole thing so that the game code mirrors very closely the xna framework. This will allow me to more easily port my existing C# code back and fourth between silverlight and xna. It will also have the added benifit of allowing me to have a code base that i can build off of and reuse in any future silverlight projects.

Lastly there are some things on the internet, that there are really no words to describe how they make you feel other then they are enjoyable. Apparently back in january 2009, from what I have read, a internet civil war started over a few 4chan and youtube videos posted by user boxxybabee.

If you are unfamiliar with the back story, this blog is a good resource to start with and contains a full write up. The vidoes capture the same spirit, and infecious meme that other popular youtube videos have demonstrated such as the numa numa guy.

The boxxybabee videos and subsequent remixes have captured my attention for most of the last two days. Even working with limited content some of the remixes have created a near fully realized song. Sadly boxxybabe has not been see since these events. But in her own words, that would lose the mystery.


Sigh it can be frustrating sometimes working on my various programming projects. My main solution I work with now consists of  94 projects. View Screenshot

Some of the projects could be considered "Done" but I have yet to upload them to this website and some are still only partially written or working. I have been wanting to create a series of video tutorials that walk through each project but I keep finding myself putting it off, partly because making videos can be very time consuming, and I tend to have too high of standards when making them, "Dam, I should not have said that", "I keep rambling on about off topic stuff", "Forgot to mention this or that feature", "Stupid lispy voice :P" etc etc

It will probably be a while (possible never) before I get around to making any of the videos.

Besides all that I have been doing more work with using xna and winforms and have created a simplfied version of the control then what microsoft has on the xna creators club web site. The reason I created a simplified version of the control is because I needed the control to integrate better with my level editing window. I have provided a preview image below of the control in use in my level editor. The source code can be downloaded here. SimplifiedWinformControl.zip (1.58 mb) (XNA 3.1)

Also something to keep in mind that VS.NET 2008 seems to have issues when the name of the control is the same as the namespace that it resides in. In the example project you may encounter a compile error in the TextForm.Designer.cs file on this line of code "this.xnaControl = new SimplifiedWinformControl.SimplifiedWinformControl();" just delete the namespace off the begining so that it reads like this "this.xnaControl = new SimplifiedWinformControl();". To avoid the error be sure to name your control something other then the namespace that it belongs to. Something else to remember is that if the control is resized larger then the main game windows backbuffer then the control will only display what it can.

public class SimplifiedWinformControl : Control
{
    private Game game;
    public Texture2D Texture { get; set; }
    private SpriteBatch spriteBatch;

    public Game Game
    {
        get { return this.game; }
        set
        {
            // hold onto the game reference
            this.game = value;
            if (this.game == null) return;
            // create the sprite batch
            this.spriteBatch = new SpriteBatch(this.game.GraphicsDevice);
        }
    }

    /// <summary>
    /// Ignores WinForms paint-background messages. The default implementation
    /// would clear the control to the current background color, causing
    /// flickering when our OnPaint implementation then immediately draws some
    /// other color over the top using the XNA Framework GraphicsDevice.
    /// </summary>
    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
        // do nothing here. If this is not overridden the control may have drawing issues O.o 
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        if (this.game == null)
        {
            // draw normal winform way
            e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, this.ClientRectangle);
            e.Graphics.DrawString(this.GetType().FullName, this.Font,
                                    System.Drawing.SystemBrushes.ControlText, 0, 0);
        }
        else
        {
            // draw xna way 
            var gr = this.game.GraphicsDevice;
            var oldVP = gr.Viewport;

            // set the graphics viewport to the size the the controls client area
            var newVP = new Viewport()
            {
                Width = this.ClientSize.Width,
                Height = this.ClientSize.Height,
                MinDepth = 0,
                MaxDepth = 1
            };

            gr.Viewport = newVP;

            // clear then draw something onto the control
            gr.Clear(Color.CornflowerBlue);
            this.spriteBatch.Begin();
            this.spriteBatch.Draw(this.Texture, Vector2.Zero, Color.White);
            this.spriteBatch.End();

            // display it onto the control
            try
            {
                var rect = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height);
                gr.Present(rect, null, this.Handle);
            }
            catch (Exception)
            {
                // Present might throw if the device became lost while we were
                // drawing so we just swallow the exception.
            }

            // restore previous viewport
            gr.Viewport = oldVP;
        }
    }

    protected override void OnCreateControl()
    {
        // check if we are not in design mode and if not hook into the application idle event
        if (!this.DesignMode)
        {
            // just invalidate the control so that it will be redrawn
            // you could also put in some logic to restrict how often the control get invalidated
            Application.Idle += ((sender, e) => { this.Invalidate(); });
        }
        base.OnCreateControl();
    }

    // not really nessary in this simple example to have a dispose here but i put it in anyway
    protected override void Dispose(bool disposing)
    {
        // perform some cleanup
        if (this.spriteBatch != null) this.spriteBatch.Dispose();
        this.spriteBatch = null;
        // we dont need to dispose of the texture here but I did anyway it will be
        // disposed by the content manager. :P But if you have texture(s) you created 
        // your self then this is where they would get disposed
        if (this.Texture != null) this.Texture.Dispose();
        this.Texture = null;
        base.Dispose(disposing);
    }
}

Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume