Game Development & Me

Everyone knows that if you win the lottery you should buy a big house, a boat, travel the world and/or other fantastical things. Whereas I am sure I would do all (and more) of those, I would also take myself back to university (controversialĀ amongst some) and learn to develop computer games

It is evident that this is not going to happen any time soon, so with a little bit of help and understanding I aim to acheive this on my own

scary maths … woooo

Continue reading

Devexpress ASPxPivotGrid Templates

A very useful piece of code for templating over field values and field headers in a Devexpress pivot grid

public class FieldValueTemplate_AbsColHeader 
{
    public FieldValueTemplate_AbsColHeader() { }

    public void InstantiateIn(Control container)
    {
        var c = (PivotGridFieldValueTemplateContainer)container;
        var cell = c.CreateFieldValue();

        var b = new ASPxLabel()
        {
            Text = cell.TextControl.Text.Split('|')[0],
            EnableDefaultAppearance = false,
            ClientInstanceName = cell.TextControl.Text.Replace("|", "_")
        };

        cell.Controls.AddAt(cell.Controls.IndexOf(cell.TextControl), b);
        cell.Controls.Remove(cell.TextControl);
        c.Controls.Add(cell);
    }
}

Continue reading

C# Appending to a File

As I have been mainly developing for the web … it’s easy to loose track of the simple things like this:

    string path = @"c:\temp\MyTest.txt";

    // This text is added only once to the file.
    if (!File.Exists(path)) 
    {
        // Create a file to write to.
        using (StreamWriter sw = File.CreateText(path)) 
        {
            sw.WriteLine("Hello");
            sw.WriteLine("And");
            sw.WriteLine("Welcome");
        }	
    }

    // This text is always added, making the file longer over time
    // if it is not deleted.
    using (StreamWriter sw = File.AppendText(path)) 
    {
        sw.WriteLine("This");
        sw.WriteLine("is Extra");
        sw.WriteLine("Text");
    }	

    // Open the file to read from.
    using (StreamReader sr = File.OpenText(path)) 
    {
        string s = "";
        while ((s = sr.ReadLine()) != null) 
        {
            Console.WriteLine(s);
        }
    }