New Adventure: How to build a game in XNA without any knowledge about it?!
As I said on my previous post, I decided to build one game in order to learn something different and also to keep myself trying the “Monetization path” for my Apps.
I ended up making this tutorial from MSDN site… Really high quality material! If you wanna to learn something about XNA, you have to take this tutorial!
This was a very nice Tutorial and it really helped me to do my first steps on the XNA world. Thanks Microsoft for that. Really good stuff!
As a developer I simply cannot learn things by “reading”/”repeating”(from tutorials…) stuff. I have to do something by myself! Then that’s the time when MathFly came in, after few weeks:
|
|
|
|
|
|
|
|
|
|
|
|
The main drivers of the game were:
- Have fun and learn (my daughter is just learning Math and the game fits perfectly!)
- Create a “Competition” environment by creating a worldwide Leaderboard!
The Game just got certified and very soon it will be available on the WP marketplace! Enjoy!
More infos can be found here.
Soon I plan to post also something on a new project coming for Windows 8! Yes! Metro Style Apps Rocks! J
A lot of work, but a lot of fun!!!!
Some News after being so quiet…
Yes! I Know!! That was a long time not posting anything here. This is bad but was needed…
I have been quite busy and did not managed myself to keep the blog up-to-date…
But I have some news! About a month and half ago I started to look for better the possibilities that I can get from Microsoft Advertising when it comes to “making money” with my WP apps. If you are not aware about that, I strongly encourage you to jump on this boat!
As an exercise I have made a very simple App which is bringing a good feedback: Verse Of The Day. The Idea of the application is Very simple… The user would get a daily bible verse on his phone… After a couple of hours I came up with something somehow like this:
|
|
|
|
|
|
|
|
You can download the App to your phone (IT IS FREE!) by clicking on the image bellow:
A quite interesting feature is the Live Tile feature, which change it to a set of nice pictures and also keep the daily verse updated!
After a nice feedback I ended up releasing an updated version few days ago, this time supporting a feature to Share to the user preferred Social Networks and also one option to get some random verses:
|
|
|
I have to confess that I did not get rich with the advertising on this App but it was a very nice exercise! J
By doing this App I realized it was time to make a bigger step and make a GAME!!! That’s where XNA came in!
On the next post I will keep telling the news!!
So you want to provide a DataSet to your WP7 app?!
Hi folks,
It is not new (wow, more than 2 years) that MS announced that there’s no plan to support dataset on Silverlight (currently WP7 is based on Silverlight 3 based).
http://blogs.msdn.com/b/adonet/archive/2009/05/26/dataset-and-silverlight.aspx
But we all know that life is not so easier and we cannot just change to LINQ to Entities. I’m not even going to jump in this discussion here. Actually I am assuming that you need an alternative. One possible alternative is the SilverlightDataset project, created by Laskarzhevsky Software Inc. I have to be honest that I did not used this solution mainly because at the first moment I’m trying to do something really simple.
My general idea is to create a WCF Service that will expose dynamically new types (POCO) which will be created based on a dataset. I played a little bit with Reflection & Emit to do this job. Here is a code that, given a DataTable returns a dynamically created type:
public class Functions
{
public static Type CreateType(DataTable table)
{
//Obtaining DataContract & DataMember Attribute
CustomAttributeBuilder dataContractAttribute = new CustomAttributeBuilder(typeof(DataContractAttribute)
.GetConstructor(System.Type.EmptyTypes), new object[] { });
CustomAttributeBuilder dataMemberAttribute = new CustomAttributeBuilder(typeof(DataMemberAttribute)
.GetConstructor(System.Type.EmptyTypes), new object[] { });
AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = string.Format("DynamicType.{0}", table.TableName);
AppDomain appDomain = AppDomain.CurrentDomain;
//Later you just change it to AssemblyBuilderAccess.Run and remove the file saving process to save some time...
AssemblyBuilder assemblyBuilder = appDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name,"dynamic.dll");
TypeBuilder typeBuilder = moduleBuilder.DefineType(string.Format("Data.{0}", table.TableName), TypeAttributes.Public, typeof(BaseType));
//decorating as DataContract
typeBuilder.SetCustomAttribute(dataContractAttribute);
//calling base contructor passing thw datarow to it
ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(DataRow) });
ILGenerator constructorIL = constructorBuilder.GetILGenerator();
constructorIL.Emit(OpCodes.Ldarg_0);
constructorIL.Emit(OpCodes.Ldarg_1);
constructorIL.Emit(OpCodes.Call, typeof(BaseType).GetConstructor(new Type[] { typeof(DataRow) }));
constructorIL.Emit(OpCodes.Ret);
//Creating one property per column
foreach (DataColumn column in table.Columns)
{
createDataMemberProperty(dataMemberAttribute, typeBuilder, column);
}
Type toReturn = typeBuilder.CreateType();
// Save the assembly so it can be examined with Ildasm.exe,
// or referenced by a test program.
assemblyBuilder.Save("dynamic.dll");
return toReturn;
}
private static void createDataMemberProperty(CustomAttributeBuilder dataMemberAttribute, TypeBuilder typeBuilder, DataColumn column)
{
string propertyName = column.ColumnName;
string fieldName = string.Format("_{0}", propertyName.ToLower());
//Creating Field that will be set/get on the properties
FieldBuilder propertyField = typeBuilder.DefineField(fieldName,
column.DataType,
FieldAttributes.Private);
// The last argument of DefineProperty is null, because the
// property has no parameters. (If you don't specify null, you must
// specify an array of Type objects. For a parameterless property,
// use an array with no elements: new Type[] {})
PropertyBuilder property = typeBuilder.DefineProperty(column.ColumnName,
System.Reflection.PropertyAttributes.None,
CallingConventions.Standard, column.DataType, null);
//decorating with DataMember attribute
property.SetCustomAttribute(dataMemberAttribute);
// The property set and property get methods require a special
// set of attributes.
MethodAttributes getSetAttr =
MethodAttributes.Public | MethodAttributes.SpecialName |
MethodAttributes.HideBySig;
// Define the "get" accessor method for CustomerName.
MethodBuilder propGetMethod =
typeBuilder.DefineMethod("get_" + propertyName,
getSetAttr,
column.DataType,
Type.EmptyTypes);
ILGenerator getIL = propGetMethod.GetILGenerator();
getIL.Emit(OpCodes.Ldarg_0);
getIL.Emit(OpCodes.Ldfld, propertyField);
getIL.Emit(OpCodes.Ret);
// Define the "set" accessor method for CustomerName.
MethodBuilder propSetMethod =
typeBuilder.DefineMethod("set_" + propertyName,
getSetAttr,
null,
new Type[] { column.DataType });
ILGenerator setIl = propSetMethod.GetILGenerator();
setIl.Emit(OpCodes.Ldarg_0);
setIl.Emit(OpCodes.Ldarg_1);
setIl.Emit(OpCodes.Stfld, propertyField);
setIl.Emit(OpCodes.Ret);
// Last, we must map the two methods created above to our PropertyBuilder to
// their corresponding behaviors, "get" and "set" respectively.
property.SetGetMethod(propGetMethod);
property.SetSetMethod(propSetMethod);
}
}
The code look a bit scary… And it really is… Use emit is like develop in IL directly… J Anyway, if you give this datatable:

It will return something like this:
[DataContract]
public class Students : BaseType
{
private int _age;
private string _name;
[DataMember]
public int Age
{
get
{
return this._age;
}
set
{
this._age = ;
}
}
[DataMember]
public string Name
{
get
{
return this._name;
}
set
{
this._name = ;
}
}
public Students(DataRow ) : base()
{
}
}
You can see that it is deriving from a base type, called BaseType…
[DataContract]
public class BaseType
{
public BaseType(DataRow row)
{
foreach (DataColumn column in row.Table.Columns)
{
var field = this.GetType().GetField(string.Format("_{0}",column.ColumnName.ToLower())
,BindingFlags.NonPublic|BindingFlags.Instance);
if (field != null && !row.IsNull(column))
field.SetValue(this, row[column]);
}
}
}
As you can see the base type has a constructor that given a dataRow, it will set the fields of the type. I could implement this logic on the Contructor but I was really lazy to find out how to do it using Emit… Could take some hours to find out… Then I just made the easy way… Another thing that you should not is the WCF attributes [DataContract] and [DataMember] that are decorating the types and properties…
Now we want to expose this datatable through a WCF service… The service contract is quite simple:
[ServiceContract]
public interface IDataSetService
{
[OperationContract]
[ServiceKnownType("GetKnownTypes", typeof(DataSetService))]
DataSet.BaseType GetData();
}
You can see that it returns the BaseType, which is the basetype of my dataset elements. Another important thing to remark is the ServiceKnownType attribute that I’m using to dynamically add KnowTypes(like this Students class that I showed above). Here you can have the service implementation:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class DataSetService : IDataSetService
{
#region [ServiceKnownType("GetKnownTypes", typeof(DataSetService))]
/// <summary>
/// Detects all KnownTypes that should be published by the Service WSDL
/// Basically we will find all DataContracts, ServiceCommandRequest and ServiceCommandResponses
/// </summary>
/// <param name="provider"></param>
/// <returns></returns>
public static IEnumerable<Type> GetKnownTypes(ICustomAttributeProvider provider)
{
Type dynamicType = DataSet.Functions.CreateType(new Students.StudentsDataTable());
dynamicTypes = new Dictionary<Type, Type>();
dynamicTypes.Add(typeof(Students.StudentsDataTable), dynamicType);
System.Collections.Generic.List<System.Type> knownTypes =
new System.Collections.Generic.List<System.Type>();
knownTypes.Add(dynamicType);
// Add any types to include here.
return knownTypes;
}
#endregion
static Dictionary<Type, Type> dynamicTypes;
public DataSet.BaseType GetData()
{
Students.StudentsDataTable table = new Students.StudentsDataTable();
table.Rows.Add("Pedro", 28);
DataSet.BaseType toReturn = (DataSet.BaseType)System.Activator.CreateInstance(dynamicTypes[table.GetType()],
new object[] { table.Rows[0] });
return toReturn;
}
}
Just to remember, AspNetCompatibilityRequirements is required by the Silverlight 3 Service client. The GetKnownTypes method is doing the miracle to allow me to return dynamic types to my client. Actually when my client generates the proxy classes, the Students class will be available as well! Finally, you can see that the service is returning a created type based on a row with the values “Pedro” and 28.
Let’s add the reference to our Web Service from our WP7 Client…


One you add the Service reference, you can take a look on the generated proxy code

The most important thing to see is that our Students type was created, even if our main WebService API do not refer to it. Actually that GetKnownTypes made this “miracle”!

Now it is time to consume the service from our WP7 app… Look this very simplistic code:
// Constructor
public MainPage()
{
InitializeComponent();
// Set the data context of the listbox control to the sample data
DataContext = App.ViewModel;
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
DataSetService.DataSetServiceClient cli = new DataSetService.DataSetServiceClient();
cli.GetDataCompleted += new EventHandler<DataSetService.GetDataCompletedEventArgs>(cli_GetDataCompleted);
cli.GetDataAsync();
}
void cli_GetDataCompleted(object sender, DataSetService.GetDataCompletedEventArgs e)
{
DataSetService.Students students = (DataSetService.Students)e.Result;
MessageBox.Show(string.Format("{0}, {1}", students.Name, students.Age));
}
Basically this code just call the method GetData from our service… Look that when the GetDataCompleted event we just cast the result to (DataSetService.Students) . Then we just show a messageBox… Really simple… And it worked nicely!

Well… This is it! That was an easy way to expose your dataset to WP7 clients using WCF without bigger issues. Of COURSE this sample is really simplistic but I’m sure that it can handle a lot of situations. In case of some special data editing support we would need some extra code to synchronize the POCO class with the dataset… But you know… this is just the start…. J
DOWNLOAD: Naturally you can have the sourceCode of this sample here.
Moving on…
Hi Folks!
I know I have been away! There are a set of reasons for that. But one thing that I can say is that I’m always taking some free time to play around with the development of TFS On the Road.
Currently I’m working on the possibility to add attachments to Work items but I have found some “challenges”. Therefore I’m in contact with the TFS Odata Service guys trying to help them to simulate the issues that I’m having. I’m sure that we will have a solution to the issues that I’m finding. One big limitation that I see is that I cannot attach files bigger than 64kb at the current version of TFS Odata… So my plan was to allow the attachment of voice notes and this will be difficult with this limitation of 64 kb. But I’m still looking for possibilities. Besides that one of the next features is to support some basic WI edition. A lot of work to do, but I’m sure we will get there, step by step.
I have been using http://www.mopapp.com/ to monitor the market place data. From this site I can get very nice reports from the Market Place data. Take a look on the report print bellow:
As you can see, on average there’s about 9,9 downloads per day of the app since it was launch, number that I consider nice to a very specific niche application like this… 358 downloads so far. And growing!
I have to say a big thank you especially to Brian Keller. He made a blog post that is up for almost a month! J This is really helping on my website traffic and app downloads.
http://blogs.msdn.com/b/briankel/archive/2011/06/07/tfs-on-the-road-a-new-windows-phone-7-app-for-team-foundation-server.aspx
And to make things even better, yesterday Brian Harry also made one post where he mentioned TFS On The road as well!
http://blogs.msdn.com/b/bharry/archive/2011/07/04/odata-access-to-tfs.aspx
The app has been also for a while on the Visual Studio Spotlight sessions of the Visual Studio website (http://msdn.microsoft.com/en-us/vstudio/default) …
This king of so positive feedback from MS and the community itself are the fuel to keep myself moving on with this project! J
Thanks all my friends that tweeted, re-tweeted and posted something else about this app! Nice!
Let’s move on!!!
TFS On The Road v1.5 just published
Hi Folks,
The v1.5 of the TFS On The Road was just published to the Market Place. This new version holds the interesting feature that I showed on the post Improving TFS On The Road chart capabilities .
Basically this feature will allow you to drill down on your work items through different levels.
Let me show some pictures to explain better. Bellow you can see the stacked chart of WI types per State. Note that there’s a Settings Link up-right of the chart. When you click there you will see one screen to select some chart settings. You can select between a set of chart types. Stacked charts supports two fields.




I will change it to show a pie chart of Work Item states on the project summary, as shown below. As soon as you click on the OK button the chart will be rendered and the settings will be saved for this level (1st level). On tis sample I will drill down to the Active work Items just taping the chart area…



As soon as I do this I will see the list of work items filtered by state=’Active’. Note that you have the option to show a chart for this Work items list as well. Just tap the Chart button(bottom right). First you will see the default chart(stacked by WI type/State). This time I will change to Pie by Iteration Path. Then I can immediately see all Active Wi’s by Iteration Path! Awesome!




And I can always drill down! On the sample I will go to the Yellow Area of the char t(Wave Twelve…)… Then I will get to the work items list again! And if you note on the top part you will see the applied Filter…



And you can take a look on the chart as well for this level (3rd level). It starts with the default chart… Of course you can change it as well. On the last level I Changed to show Bar charts by “Assigned to”.



And Of Course I can move On!!!! I will click on the last bar to drill down again (pedro’s active tasks on the Iteration ‘Wave Twelve’)… Look the list and the applied Filter… And Of course you could drill down again! J But I think it’s deep enough on this sample. Theoretically you could drill down as much as you can.



Really nice, isn’t it? J As you could see, we navigate in 4 drill-down levels:
- Pie chart by WI States, selected the Active Work Items
- Then Pie Chart by Iteration Paths, we selected “Wave Twelve”
- Then we made a bar chart by “Assigned to”
- Finally we got to the last level on this sample
What is interesting is that every settings that you defined so far were saved per level! Next time you will not need to configure the chart(by tapping on settings) again! J
Cool!!!
If you still did not got the 1.5 version… Just take it to play around with this feature!
Now I’m preparing myself to start adding support to work items basic edition/creation and also to add attachments…
Let’s move on! I keep you updated! J
Round 1, fight! Windows Phone 7 emulator x VmWare
Hi Folks,
I have been using VMware Server (free edition under here) to run some 64bit machines under my Windows 7…
So basically my idea is to have some “heavy” stuff defined on a 64 bit machine like database servers, iis and so on… This has been working quite nicely until I run the Windows Phone 7 emulator…. Or actually even if a I run Virtual PC XP Mode…
Basically VMWare crashes all running virtual machines as soon as any other process using Hardware virtualization starts… The error is something like:
VMware Server unrecoverable error: (vcpu-1)VCPU 1 RunVM failed
Look the solution that VMWare recommends as resolution here:
“This issue can occur when you are running VMware Workstation and another organization’s virtualization software at the same time. Running Workstation and another organization’s virtualization software simultaneously on the same system is not supported.
VMware recommends uninstalling the other virtualization software to allow Workstation to operate without errors. “
OMFG, I would love to say this to my customers: Hey, our software is not running because competitor’s software is breaking it. The solution is to remove the competitor software! Hahaha! Life is not so easy! Mainly because in my case I’m talking about an Emulator which visual studio needs to connect and so on… Not so easy…
So I have been searching all around and I(not really, read on another blog) that it is all about the usage of Hardware virtualization… On Virtual PC you can just disable (or enable which is the best…) it very easy:
But what about the Windows Phone emulator??
Well, what I’m going to show next was the first solution that I found out by myself doing some trials to workaround this… At the moment I have the lattest Windows Phone Tools running(7.1 beta), so All paths will be referring to it… Basically I fould out that there are 2 files with extension “.decfg” on the XDE Folder:
I modified the first one, disabling the HW acceleration (EnableHWAssist):
<?xml version=”1.0″ encoding=”utf-8″?>
<WindowsPhoneEmulator xmlns=”http://schemas.microsoft.com/WindowsPhoneEmulator/2009/08/Configuration”>
<EmulatorSettings>
<ConsoleWindow Reconfigurable=”static” Type=”bool”>false</ConsoleWindow>
<ZoomFactor Reconfigurable=”dynamic” Type=”dword”>66</ZoomFactor>
<Displacement>
<X Reconfigurable=”dynamic” Type=”int”>0</X>
<Y Reconfigurable=”dynamic” Type=”int”>0</Y>
</Displacement>
</EmulatorSettings>
<Board>
<CoreSystem>
<EnableHWAssist Reconfigurable=”static” Type=”bool”>false</EnableHWAssist>
<VTT>
<GuestQPF Reconfigurable=”static” Type=”dword”>10000000</GuestQPF>
</VTT>
</CoreSystem>
<Peripherals>
<VBUS>
<GPU>
<GPUEnabled Type=”bool”>true</GPUEnabled>
</GPU>
<Orientation>
<Enabled Type=”bool”>true</Enabled>
</Orientation>
</VBUS>
<PCMCIA>
<VMNetEnabled Reconfigurable=”static” Type=”bool”>false</VMNetEnabled>
</PCMCIA>
</Peripherals>
</Board>
</WindowsPhoneEmulator>
Next step after doing this is to create the new command line which will run the XDE. The one that I found out is:
XDE.EXE “C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Emulation\Images\WM70C1.en-US.bin” /decfg “C:\Program Files (x86)\Microsoft XDE\1.0\config_board0.decfg” /VMID {08F58FF1-69CE-4427-B8E7-D16FEEBD3791}
Where:
- “C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Emulation\Images\WM70C1.en-US.bin” is the Image to load up
- “C:\Program Files (x86)\Microsoft XDE\1.0\config_board0.decfg” is the modified setting file
- {08F58FF1-69CE-4427-B8E7-D16FEEBD3791} is the ID of the machine…. Don’t ask me why?! I found out that there are two ID’s on my machine, under the “C:\ProgramData\Microsoft\XDE” folder.
I tried with both but it just allowed me to debug from Visual Studio when I renamed this first one…. Then it runned properly(made a full boot). Of course it runs slowler than normal, but at least my VM’s are still running! J
So basically what I’m going to do is just run this command line before I run Visual Studio. Then it will not launch the “default” emulator that kills all my vmware machines. Actually I tried also with VirtualBOX and same issue happened…
For now that’s it. I made this post in a hurry… Hope that it helps someone else that has this issues..
Things are getting interesting
Hi Folks!
I write this post exactly 10 days after Tfs On The Road was published on the Market Place. First of all I would like to thanks every supporter of the App. Iha!
I want to share some statics…
First thing to share is the number of downloads (source Reports from MSDN App Hub). On the first two days the App got more than 155 downloads! I think this is a reasonable number for my first app. J

And it is really coming from everywhere… Take a look:
| country | type | units |
| Australia | Free | 7 |
| Austria | Free | 1 |
| Belgium | Free | 3 |
| Canada | Free | 6 |
| France | Free | 6 |
| Germany | Free | 24 |
| Hong Kong SAR | Free | 1 |
| Italy | Free | 2 |
| Mexico | Free | 4 |
| New Zealand | Free | 1 |
| Singapore | Free | 2 |
| Spain | Free | 4 |
| Switzerland | Free | 1 |
| United Kingdom | Free | 10 |
| United States | Free | 77 |
Source=MSDN AppHub
Besides this, the main App page(http://pcbl.de/tfs-on-the-road/) had about 620 Pageviews! I consider this also a good achievement due to my limited possibilities to actually share the app properly on some channels.
What really make things move faster are the folks that post something about the app to their friends. Some blogs that I found mentioning the App are:
http://blogs.msdn.com/b/slange/archive/2011/06/08/steve-s-newsletter-june-2011.aspx
http://blogs.msdn.com/b/buckh/archive/2011/04/10/odata-service-for-tfs.aspx
http://coolthingoftheday.blogspot.com/2011/05/on-road-again-with-tfs-on-road-free-wp7.html
There’s a lot more. Thanks for the support! Special thanks goes to Brian Keller, which really made a huge impact on this Traffic site(J) and also for the open channel to collect my feedback as a consumer of TFS Odata Services.
I could not forget also all the mentions on Twitter… Thanks Felipao(or Felipin?), André, Idevar, Alfredex, Kono, Lino and everyone else that I forgot to mention… J Thanks!
I’m happy with this scenario and I can see very nice steps ahead… I hope that soon I can release the new version of the App with the extensive chart supporting possibilities.
Let’s keep up the hard work! J
Improving TFS On The Road chart capabilities
Hi Folks,
During this weekend I have been playing around on charting possibilities on TFS On The Road.
Just for information, on this project I’m using the Silverlight Toolkit Chart component, which is doing a very nice job so far. To check some online samples form the Toolkit, click here. Really nice stuff.
I have been thinking on a way to allow the user generate some “quick” charts on the mobile. My idea is just to give the user the chart type possibilities and also the fields to generate the chart. The base chart settings screen looks like this:


For stacked charts you can use up to 2 fields. The chart types and fields are:


Once the user provides this information he can see his chart. When possible the charts are supporting drill-down navigation, which allows you to see the work Items behind a certain chart area.
To show this feature working I prepared one video to show it. Please take a look:
I still need to do some more testing and as soon as possible there will be an update available (the update version will be possibly 1.5.0).
I’m delighted to get your feedback on this feature.
The Show must go on…
Hi Folks,
Since the first release of the “TFS On The Road” I have been getting a very feedback from the community! Many thanks!
Today I just made a new branch on the CodePlex Project for the Version 2.0 of the App! Actually I just implemented a new and very important feature which will come on the next release: “Goto Work Item”.
Basically this feature allows you at any point to give a Work Item ID and then “jump” straight to it. To show it working I made one video:
As soon as more features appear, they will be shown here. Depending on the community feedback we might have one intermediate release between the current version (1.2) and 2.0. For now, that’s it.
I enjoyed this possibility to create videos and I’m going to make several other videos to present the TFS On The Road Features.
See you!


















