dev in the making

game development, maya and code by brainzizi

Posts Tagged ‘silverlight

Update on and some drawbacks again

leave a comment »

A couple of update’s:

If you’re interested in our little Silverlight project called, you can check out the latest build at Beware, it’s Croatian.

Second stage Web Startup Contest deadlines were 3.5.2009, and we had to post links to working prototypes, a “features” document and our source code.
If anyone’s interested the above-mentioned are:

A little babbling about the code now… It’s not exactly a role model for OOP design, some of it was seriously hacked using reflection, mostly because my lack of Silverlight experience and understanding. But hey, it’s a contest geared towards education and this is what I’m doing… Educating myself. I’m gonna list and comment a couple of serious party breakers I encountered:

If you thought you could use the browsers back and forward buttons for navigation, you weren’t thinking hard enough. I know I wasn’t.
You have two options. a) hook it up using javascript to the browsers functions and b) develop your own history system. I used the latter and that’s when I had to use reflection due to a seriously lacking model I made. The point: Don’t code empty-minded. Have a VERY GOOD plan. Or you shall regret it.

Setting up the web service
I’ve spent two days figuring out that dreaded web.config and bindings. The point: Customer support should be high up when considering a server.

Asynchronous web service calls
You make a couple of async calls to the web service, hooking events on their completion. You also hook a special method on the last one that you called, which fires an event telling I’m done fetching data. Eeeek! Wrong. Things don’t necessary end in the order you called them. You have to queue them on the completed event of the previously completed call. And that’s quite a lot of lambda expressions or use of reflection even. The point: More isn’t always better. The simplicity of PHP has it’s charms too.


Written by brainzizizi

05.10.2009 at 13:49

Client validation in Silverlight

Validation is the single most important thing in user interfaces. Go write an app. Like a simple calculator. Have textboxes and buttons and things like that. Does it work for 5+5? Yes? Good. Now see what your app thinks about the sum of “aklsgfjgbas” and “asjkhdgbas”. Preventing that and far more worse things is validation.

My validation mind map looks something like this. There are two types of validation: prevention and correction. Preventing would be to not let the user enter things like that at all. Correction would be if a user enters things he shouldn’t you just warn him. Maybe not even let him press the ok button or something. I use prevention in most cases, and that’s the next topic. Also formally there are 2 types of validation client side and server side. I’ll be talking about client side validation. has some controls which hack into javascript to do basic validation. I hate javascript. HTML also. That’s why I use Silverlight… Ok ’nuff of that.
Silverlight’s textbox is a plain one, like in WinForms but still a bit different. One thing different from WinForms is that WinForms can only run on Windows. Silverlight on the other hand runs on everything with a browser. And that’s the problem, you don’t have the WinKey on Apples, the keys are inconsistent on various platforms. When you do my type of validation you should hook a method on the KeyDown event of a textbox and check if the ascii is ok. And if it’s not a weird char allow it. First, you can’t get ascii of a char from the KeyPressEventArgs or whatever it’s called, you can get the platform specific code or an Key enumeration. Not good. Second that doesn’t prevent copy/pasting weird stuff in the text box. The way I solved it is hooking a method on TextChanged and checking all chars for weird stuff.
Example for allowing valid email chars below:

MyTextBox.TextChanged += (sender, e) =>
    foreach (char c in ret.Text.ToCharArray())
        if (!Char.IsLetterOrDigit(c) && c != '@' && c != '.' && c != '_' && c != '-')
        ret.Text = ret.Text.Replace(c.ToString(), "");

If you think that this is not C#, google lambda expressions. I’ll write a post about it soon I hope.

Written by brainzizizi

04.16.2009 at 13:04

April fool’s day and Silverlight

leave a comment »

Some nice jokes on this year’s april fool’s day… Loved the ones from Google and their GMail, but the one that I’m most impressed with is the Youtube flip. They probly had to change fonts, rotate images and bunch of other stuff. If Youtube was done in Silverlight 3, this whole effect would took exactly 10 min to implement. You would just write a flip shader effect, make an effect out of that and just attach it to any control you wish to flip. Easy as pie.

As I was talking to my friend yesterday (ASP enthuziast) and I’ve realized that everything you can do in Silverlight 2, you can do in ASP and AJAX. So why do Silverlight 2 then? First of all I’m terrified of HTML and CSS. Those things are a mess. And when I saw that the Visual Studio ASP designer “isn’t that great”, and relies on “accepting a CSS file” as the way of designing stuff I immediately droped the whole thing.  ASP and AJAX are build upon this big pile of HTML and Javascript. And dear god is HTML old; hasn’t been changed from probly 1991, and Javascript is a whole other story. HTML is something like Adobe Flash. People hack it to make it do something that wasn’t meant to do. And with time that became normal, and now everyone hacks away disscussing about “the right way” to do something. You all are doing it the wrong way, and by doing that halting the evolution of Web. That’s why I never did web until Silverlight, ‘cuz it was a big pile of rubbish you have to dig thru to get to even more rubbish at the bottom.

Silverlight brough in XAML. Now that’s modern HTML if there is one, but that’s not why I use Silverlight. The real reason is Blend. I’m not a designer, but Blend let’s me do really cool looking, neatly organized user interfaces in a matter of minutes. Not that I’m promoting Blend or Microsoft or anyone, but the workflow with Visual Studio, Silverlight and Blend is just amazing. Blend is like the Visual Studio designer on drugs. Apart from that, Silverlight 2 doesn’t bring any new wow usable features to the web scene.  But Silverlight 1 and 2, and even Blend 2 are all just sort of previews for Silverlight 3 and Blend 3.

Google Silverlight 3 and Blend 3 features, or watch MIX’09 videos about it. That’s amazing. GPU acceleration, pixel shaders, sketch flow. That makes a difference. So get aquainted with Silverlight, ‘cuz it’s gonna get a lot more cooler than this.

What’s New in Microsoft Silverlight 3

Written by brainzizizi

04.03.2009 at 04:46

Posted in silverlight

Tagged with , ,

The drawbacks of Silverlight

leave a comment »

A lot of people think that Silverlight is the Microsoft Flash, but that’s very far from the truth. Flash was made for creating animations with vector graphics. Silverlight was made for designing user interfaces. That’s why you got a bunch of controls like textbox, etc…  instead of kewl stuff for drawing vectors. But Silverlight and Flash do have some things in common; both are client side, both can be used to make Rich Internet Applications and both are having problems with the right click. I don’t think there is even a way in Flash to bind some action to the right mouse button. In Silverlight things are a little better (but still horible). Thank god half of Silverlight was hacked in JavaScript – and I hate JS, this is where things like that serve a purpose. Hack it with JS right back. I’m not going to reblog how to do that (

One other thing… Regarding the multi-page functionality, one major drawback when you have just one browser page and a lot of Silverlight pages (UserControls or whatever you want to call them), is that you cannot use the browser back and forward functionality. They should add a control like that to Blend 3.

And the last major drawback is working with links and html in Silverlight. There is no RichTextBox control in Silverlight. There are a couple of user made ones, but the problem with all of those is they use Run and LineBreak objects to construct a RichTextBox. And Run objects don’t allow OnMouse events. So what I wanted to do (and can’t) is this. A text with underlined words representing links, mini popups when you hover your mouse over the links, and redirect when you click the link. If anyone knows about a neat way to hack this, please let me know.

Written by brainzizizi

03.31.2009 at 04:47

Posted in silverlight

Tagged with , , , and Web Startup Contest

leave a comment »

I’ll be posting stuff here about the Microsoft sponsored Web Start Contest here in Croatia, and our competing social networking student project called (meaning “Where are you” in croatian).

It’s features:

  • done in Silverlight
  • combining Facebook functionality and Twitter simplicty
  • aimed at the local market
  • clean, sleek design
  • readabilty

Index page concept: index page concept

Written by brainzizizi

03.30.2009 at 04:15

Posted in silverlight

Tagged with , ,