Category Archives: C#

Balder 0.8.8.5 pulled – why ?

A couple of days ago I published a new version of Balder; 0.8.8.5. It had a bunch of improvements in it, especially when it comes to the Silverlight Control support. I had to pull the release mere hours after its release. The reason for pulling it was that I did a lot of optimizations in the rendering, or at least I thought I did. Turns out that when running on a very fast Dual core or Quad core computer, it was faster – but on slower machines, it turned out to be quite slow. 

Instead of reverting the entire optimization, I've decided to actually get the performance up quite a bit. I've been working on a new rendering pipeline that would increase the performance dramatically, so no time like the present.

The biggest change however with the release was the Xaml support. In the Development branch over at GitHub you will find source code with the rendering pipeline being the same as in version 0.8.8.0, but with all the new Xaml support. So if you can't wait for the optimizations and want to get your Xaml right from the start – you should go pull the latest on the Development branch and compile the binaries yourself. In fact, it should be fairly simple to do it, just download it and run the build.cmd file from a command prompt and it will output a Drop directory with all the binaries in it.

Speaking at Software 2010 with Petri Wilhelmsen

On the 9th of February, Software 2010 is kicked off. Petri Wilhelmsen and myself will be holding an hour on game development with managed code using Microsoft Xna and Silverlight (featuring Balder). We will be focusing on 3D development and cross-platform using .net.

Really looking forward to doing a co-op with Petri.

For more details and signup, go here

Speaking at Software 2010 with Petri Wilhelmsen

On the 9th of February, Software 2010 is kicked off. Petri Wilhelmsen and myself will be holding an hour on game development with managed code using Microsoft Xna and Silverlight (featuring Balder). We will be focusing on 3D development and cross-platform using .net.

Really looking forward to doing a co-op with Petri.

For more details and signup, go here

Silverlight Courses 2010

2010 is going to be a busy year for me, along side consultancy for several customers, I've been scheduled to do a few courses. Silverlight is the topic for all but one of the courses.

You'll find all the courses in this overview of all of Bouvets courses here.

Even though, listed as Silverlight 3 specific, they will be focusing on Silverlight in general and will include some of Silverlight 4 as well. We're looking into putting up a Silverlight 4 specific course as well. 

So, if you want to get your hands dirty and start learning Silverlight, these courses are the place to be. 

Update 9th of December 2009, direct links to the courses:

 

Silverlight Courses 2010

2010 is going to be a busy year for me, along side consultancy for several customers, I've been scheduled to do a few courses. Silverlight is the topic for all but one of the courses.

You'll find all the courses in this overview of all of Bouvets courses here.

Even though, listed as Silverlight 3 specific, they will be focusing on Silverlight in general and will include some of Silverlight 4 as well. We're looking into putting up a Silverlight 4 specific course as well. 

So, if you want to get your hands dirty and start learning Silverlight, these courses are the place to be. 

Update 9th of December 2009, direct links to the courses:

 

Balder 0.8.9.0 – features, feedback wanted

We're not about to slow down the development of Balder anytime soon, next release is something we're already hard at work with. 

If you want to be influence the priority or have features you'd love to see in it thats not already on the list, please don't hesitate to go to our Issue list over at GitHub and vote, comment or add new issues. You'll find the issue list here

Balder gets declarative

We're getting closer to the BETA mark for Balder, and we're starting to get most of the features we want in for version 1 ready. The latest feature is the ability to declaratively through Xaml get Balder up and running. Current release is versioned 0.8.7 and can be found over at the Balder page at Codeplex.

By adding the following namespace declaration in your Xaml file:

[code:c#]xmlns:Core="clr-namespace:Balder.Core;assembly=Balder.Core.Silverlight"[/code]

You now get a set of extra controls that can be used.

First off is the RenderingContainer:

[code:c#]
<balder:RenderingContainer x:Name="_renderingContainer" Width="800" Height="600" BackgroundColor="Black"/> 
[/code]

You need to specify the Width and Height, as that is used to setup the display properly. The BackgroundColor property can be any color, including transparent – which is great if you want to mix with existing Silverlight controls on your page. 

The next control we've added is the Mesh control, it enables you to add any Mesh from a file/resource to the RenderingContainer. You do this by accessing the Nodes property on the Container and putting up a RenderedNodeCollection and put your Mesh(es) within that.

[code:c#]
<balder:RenderingContainer.Nodes>
       <balder:RenderedNodeCollection>
             <balder:Mesh x:Name="_audi" AssetName="audi.ASE"/>
        </balder:RenderedNodeCollection>
</balder:RenderingContainer.Nodes>
[/code]

For now, there is a limited amount of DependencyProperties exposed, so manipulation via Storyboards aren't possible today, but will be very soon. The only way to access this is by hooking up the Updated event on the RenderingContainer and implement codebehind logic for it, something like this:

[code:c#]
private float _angle = 0f;

private void Updated(RenderingContainer renderingContainer)
{
    _audi.Node.World = Matrix.CreateRotationY(_angle);
    _angle += 0.5f;
    _renderingContainer.Camera.Position = new Vector(0,-5,-20);
}
[/code]

Last but not least, to get it all working, you need to initialize Balder. In your App.xaml.cs file, during the Application_Startup event, you need to add one line of code. It is very important for now that you add that line before your page (RootVisual) is created and set.

[code:c#]
  private void Application_Startup(object sender, StartupEventArgs e)
  {
   TargetDevice.Initialize();
   RootVisual = new Page();
  }
[/code]

I you want to use it the "conventional" way – non Xaml based, you need to add a similar line of code, but that line of code needs to be added after the page has been created. This is something that makes absolutely no sense and is something we're trying to fix and make it a lot more sense. Our goal is to get rid of that line of code all together.

A little note, we're not trying to mimick the WPF 3D namespaces at all, we're going our own direction. We don't feel the urge to replicate those, as the purpose of Balder is very different. 

Bing / Virtual Earth WPF MapControl – Localization issues

I just got an email from a guy that watched my WPF talk on the MSDN Live tour in Trondheim, he had downloaded one of my samples from that talk and gave it a go. But he constantly got this "Script Error" thing. The demo was using the WPF MapControl for Virtual Earth maps. It worked OK in all browsers he had tried. Kinda odd I thought. 

The error message was "String was not recognized as a valid boolean". I googled the error message without any concrete results.

Then it struck me; "could it be… Naahh.. It couldn't,  lets try switching regional format settings.." – I always set mine to English – U.S., without really having any good reason for doing so, seeing that I live in Norway. Anywho, I switched it to Norwegian, and there the same error was. 

The simple solution, codewize, is to set the CurrentCulture to be Invariant:

[code:c#]

System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; 

[/code]

I haven't had time to investigate why this happens, but it sure is kinda odd, since running the map in a browser works and the WPF Control is in fact just a WebBrowser control, using the same browser. 

Balder in the news.. sort of..

We're starting to get a little bit of publicity with regards to the Balder project, which of course can hardly ever be a bad thing. 🙂

Gastón Hillar has just published an article on the Dr.Dobbs blog about Balder and the optimizations we've been working on the past couple of months. I think it is pretty much thanks to Gastón that Balder was revitalized earlier this year, and he has been very active with testing all the new bits we've been putting in and given us pin-pointers to were to start looking for optimizations and so on. A huge thanks to him for the article and the go-go-spirit in using Balder and giving us the kick in the behind we needed to get the engine to a more decent level.

You can find the article here.

Gastón has written a few books earlier that can be found over at Packt Publishing.

Extensions and Helpers for Silverlight and WPF

Earlier I posted about some extensions I did for Silverlight handling INotifyPropertyChanged and helpers for DependencyProperties. Recently I've had a couple of request to release a downloadable source with samples of their use. Since the original posts (found here and here), I've refined them a little bit and worked out some quirks that was left in the originals.

So, why should one use these kind of extensions and what do they solve?

INotifyPropertyChanged and creating DependencyProperties rely on the usage of literals. When for instance notifying the PropertyChanged event with a change on a particular property, the argument one passes in is the literal holding the name of the property. This is bad for at least a couple of reasons:

  • Refactoring goes out the window – renaming the property means renaming the literals by hand
  • Obfuscation – if one were to obfuscate the code, literals will still stay the same but your propertynames will change – your code is broken

I've wrapped it all in a nice download with both a Silverlight and a WPF version of the code (actually pretty much the same code, you'll find #if(SILVERLIGHT) #else #endif statements where specifics are needed). Also in the download, you'll find a Silverlight sample with a usercontrol implementing a dependencyproperty and a data object using the INotifyPropertyChanged extensions. In addition to this, there are a few other nifty helper classes and extensions for other aspects of both Silverlight and WPF development. Hope you'll find it handy.

The download can be found here.