. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Wednesday, October 18, 2006

Technorati, Rubbish!

For the life of me (Not literally!) No matter how many times I update my ping on Technorati it never updates the its representation of my blog! Grrr.

No matter how many times I email support, I still get no response!  Good work Technorati!

tags: ,

Saturday, October 14, 2006

Solution to my "Problem with List<T> and TypeConverter" Problem

I had a major problem with type converters the other week (see Problem with List <T> and TypeConverter), I could never get them to work as I wanted. 

I had a Generic list that held a list of objects of type T, simple enough.  However when I came to try and use the typeconverter in a component on an XNA Game form or a Windows form they would not work, as expected, additionally the Visual Studio Designer would not create the code for the properties that.

All I wanted was for the code to be created by the designer to look like:

LayerList.Add(new Backgound("c:\\test.bmp"));


The type converter I was creating would take a simple string from the Visual Studio Designer, and apply it to the default constructor which would in turn populate the associated member variable and public property.  The rest of the properties did not need to be designed. 


My type converter was getting complex for such a simple task, it was overriding:



  • CreateInstance
  • GetCreateInstanceSupported
  • CanConvertFrom
  • CanConvertTo
  • ConvertTo
  • ConvertFrom
  • GetProperties
  • GetPropertiesSupported

I really didn't believe that I needed all this complexity, but all the examples I had seen on the Internet were quite complex.  My typeconverter was getting still more complex, I was also attaching a debugger to the Visual Studio IDE and debugging the type converters as they were getting used in my project, just so that I could see what was happening.


In the end I reverted to the best motto I have ever heard, KISS, keep it simple stupid!


I thought that I don't need to be able to edit all the properties on my control from the designer in one string, especially because if I add more complexity to the control it would be hard for developers to use the property designer.  It just didn't make sense to have the designer require a formatted string such as {"C:\test.bmp", 10, 10} to create an object on the form, especially when the designer supports expandable object property editors, which make more sense to use.


Therefore, I thought that I should try a simple override of CanConvertTo and ConvertTo and see what happens.


public class LayerConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context,
Type destType)
{
if (destType == typeof(InstanceDescriptor))
return true;
return base.CanConvertTo(context, destType);
}

public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture,
object value, Type destType)
{
if (destType == typeof(InstanceDescriptor))
{
ConstructorInfo ci
=
typeof(Layer).GetConstructor(
System.Type.EmptyTypes);
return new InstanceDescriptor(ci, null, false);
}
return base.ConvertTo(context, culture, value, destType);
}
}

The above code was all that I needed for the designer to correctly serialize the object in the List of types and all the properties.


For instance now, if I added a list of two elements of type Layer to the list, each of the list has a couple of properties on, the code that Visual Studio Produces is:



bg1.FileName = "Media\\cloud.dds";
bg1.LayerDepth
= 0.1F;
bg1.Offset
= new Microsoft.Xna.Framework.Vector2(150F, 100F);
bg1.TileX
= true;
bg1.TileY
= false;

bg2.FileName
= "Media\\cloud.dds";
bg2.LayerDepth
= 0.5F;
bg2.Offset
= new Microsoft.Xna.Framework.Vector2(0F, 0F);
bg2.TileX
= true;
bg2.TileY
= false;

this.component.Backgrounds.Add(bg1);
this.component.Backgrounds.Add(bg2);


tags: , , , , ,

Friday, October 13, 2006

iforgive.eu up for sale

Following on from on of my previous blog entries [http://www.kinlan.co.uk/2006/07/project-that-i-thought-was-good-idea.html]
  • Iforgive.eu - The Flower shop for all your forgivness needs
  • Iforgive.eu - The forgivness website where you put your sins for all to see on the site and then you will be peer assesed as to whether you derve forgiveness
  • Iforgive.eu - The forgivness website where you send an open email to the person you wronged and then the public will see if they forgive you or not.

The first idea was okay, but I would not have been able to get it off the ground. It would have been trading soley on the name. That and right now I don't particularly want to run a shopping site at the moment (especially since we have a young toddler to contend with)

The latter two ideas really were open to abuse. I like the idea of these social networking sites, so I was trying to play off that. However there would be no way to stop slander, fraudulent posts and also defamation. Futhermore, what about victim support, someone has been wronged, and their purportrator is openly harrasing them in public.

That put three ideas in the bin straight after I had spent the money on the domains. Being the tightwad I am with money I decided to think some more about what I can do with it. So I came up with a couple more ideas. I got my lateral thinking cap on and tried to think of things soley associated with the name. I came up with plenty of ideas, but the two that stuck out where:

  • If Or Give - The open experiment with social charity giving. The site would exist only to generate revenue to be given to charity any person could donate money to the site or they could decide to give all the money in the pot at that time to a particular charity.
  • If Or Give - The open experiment into questions and answers.

The first idea seems reasonable, but at the time I don't think I could set it up. Likewise I also am not too sure how to get the money in to the charity. And also I am not too sure if it would be ethical or open to abuse.

The second idea has been done before! Grr

My final idea, is one where I set it up as a simple site that hosts my .Net 2.0 experiments that I might talk about on this blog.

So here I am at the end of this. I am asking you to leave comments to recommend suggests as to what I should do with the domain name. The suggestions can be funny, serious etc, what ever you can think of.

I may even implement one of them.

Also, may this be a lesson to anyone about starting a business or site etc. Think of what you want to do BEFORE you buy the domain name. :)

I am selling the domain name iforgive.eu. If you want to buy it you can find it at http://www.iforgive.eu or on www.sedo.co.uk. Tags: , ,

Thursday, October 12, 2006

Window Live OneCare Beta 1.5.1785.18

I have just installed Windows Live OneCare Beta 1.5.1785.18.  I was in the past using Windows Defender.  I have only really tried the TuneUp and the Protection Plus.

My problem with the OneCare Tuneup is that it doesn't really do much and what it does do it doesn't tell you what it is doing, for instance when defragging all it said was "C:\" only at the end of the process did I find that it did not do it because it didn't have enough space.  It would have been nice to say how much space I needed!

Additionally the only thing that the Tune up does in relation to tuning the system is to defrag the drives and also remove some redundant files.  It sounds like it should be tweaking system settings to make sure that I am getting the optimal performance out of my system.  With the Microsofts recent purchase of SysInternals I would liked to have seen things like the Registry and Page file defragmentation, however I have no idea if it does this at all [note to MS:  make it so that we can view more detailed information about what has happened.]

I suppose on the plus side, it does the things that I should do manually, such as defrag and check for updates... and the firewall alerts in the protection plus are useful to see, but if that is all that it does then I am not that impressed.  It is not even a "not seen or heard" application because it makes a mince meat of my system resources when it is running!

There is an activation portion of the program too, but because it is Beta it says not to activate it, however I don't think I would want to pay for this application at the moment.

Long Tail is a Long Tale

I have been reading "Long Tail" by Chris Anderson.  A lot of blogs I have been reading recently all talk about the long tail as in the phenomenon and not the book, but when you trace the history of the phenomenon it all points back to this book (or blog)

I thought the book was good, I read it quickly.  I found myself saying "well that is obvious" on every other page when Chris was talking about limited choice against infinite choice, aggregators and filters etc, but that is not a bad thing, it points out the obvious to make you realise you can that the answers are right in front of you.

I do feel that it could be shorter, perhaps just reading the blog would have been better for me.  That is not say I didn't enjoy it, it is just that I feel that the whole book was very verbose, using words just to fill the pages.

Without realising I had already implemented a "Long Tail" Feature on this blog. In the past I used to constantly put related links, pictures and other artifacts to help the readers of my posts discover more about what I am talking about.  The only problem about this was that it bloated each post up to enormous proportions and that is why I made my own mini tag directory (http//:www.kinlan.co.uk/tag/{anytag}), this would link to all related posts that I have made and also related resources.  This was actually quite sucsesful and led to me creating Topicala (http://www.topicala.com/) which was my own meta search engine.  I use it a lot and a few other people use it.  Topicala is a tag directory that allows users to search across many search engines at once to find the information they need in just one place.

Tags: ,

Amazon UK LongTail, Amazon USA Long Tail

F14 XNA Game should use XNA Parallax Engine

I was looking at the F14 XNA game that ARogan produced [http://aroganworld.blogspot.com/2006/09/f14-xna-game.html].  Some of the features are:

- 1 level of play including 3 enemy types and a boss
- 3 levels of parallax scrolling
- sound
- high score
- animated sprites, rotation, scaling
- basic enemy ai, track the player, movement patterns
- robust scripting engine so making your own levels would be easy.
- "realistic" graphics (ha!)
- keyboard and Xbox 360 wired controller including rumble support.

The interesting thing is that he uses 3 levels of parallax scrolling. 

That is why I would love to see this use the XNA Parallax Engine that I have been working on.  If I can't get someone to port it, I wil do it because he includes the complete source code to the project.  

It will be interesting to see the port in action and how long it takes to do.  It will then show how flexible my engine is.  It should be easy to port, because the Parallax Scrolling would be handled by my engine. 

I will let you know how I get on.

 

Tuesday, October 03, 2006

Assigining a TypeConverter to a class you don't own

I ran into problems with the XNA Beta1, where by I had a class that had a Vector2 struct in.  The problem with the XNA Vector2 struct is that there is no TypeConverter for it at the moment.  This means that there is no support in the designer. 

I initially solved this problem by assigning a type converter to the public property on my class that used the Vector2. (see below)

public class A
{
private Vector2 v;

[TypeConverter(typeof(Vector2Converter))]
public Vector2 Vec
{
get{ return v; }
set{ v= value}
}
}

However, VS2005, when serializing out to code from the designer, it will not obey the TypeConverter on the property, but will try to use the Type's Conveter eventhough the designer will use the TypeConverter on your class to edit the control... clear as mud? :)


This leads to ugly code in the InitializeCode method that tries to look in the resource file to get the object out.  I didn't like this solution because it looks ugly and is hard to maintain.


I solved this problem by forcing the TypeConverter on to the Vector2.  In my classes constructor I called the following code I have created.

public static void Register<T, TC>() where TC: TypeConverter
{
Attribute[] attr = new Attribute[1];
TypeConverterAttribute vConv = new TypeConverterAttribute(typeof(TC));
attr[0] = vConv;
TypeDescriptor.AddAttributes(typeof(T), attr);
}

The above code adds the TypeConverter (TC) to the Type (T) so that the designer can serialize to code correctly using my own TypeConverter.  The main thing it is doing is calling: TypeDescriptor.AddAttributes


The solution then allows the Designer to serialize to code and it gets rid of having to serialize the object to a resource file.  The solution would look like the code below.

public class A { 
private Vector2 v;

//Enables Designer support, so it can be edited
[TypeConverter(typeof(Vector2Converter))]
public Vector2 Vec {
get{ return v; }
set{ v= value}
}

public A()
{
//Enables designer serialization to code
ConverterRegistration.Register<Vector2 , Vector2Converter>();
}
}