Pages Menu
TwitterRssFacebook
Categories Menu

Posted by on 25th December, 2008

Another Silverlight clock experiment…

Another Silverlight clock experiment…

I started working on enhancing the previous Silverlight 2.0 clock I had made, en then I saw a Flash implementation of another creative approach of a clock and wondered if I could do that in Silverlight. Needless to say, I started working on it immediately and below is the result. This is another experiment that I thought I could do in just a few hours and it ended up taking me a bit more. Mostly because of the uneven conversions between the units and the different sizes between the boxes. Anyways, in a nutshell here is my approach: I have a very simple XAML file with only defining seven empty canvasses as placeholders, organized from top to bottom by a StackPanel. I will create and populate every single object dynamically and on the fly: I have a single method (CreateBasicCancas) that generates all the textBoxes for each individual gear. Then I have a single Storyboard that iterates every millisecond and that storyboard calls one single method (MoveGears) for all...

Read More

Posted by on 18th December, 2008

Silverlight Error when adding objects

Silverlight Error when adding objects

I have done a couple of Silverlight experiments where I programmatically generate objects on the fly and then attempt to add them to the Canvas. In one scenario, I was trying to generate 10 circles, give them some properties and then add them to the parent object, a Canvas, in this case. However, when I did this, I got the following runtime error: “{System.ArgumentException: Value does not fall within the expected range.” right when I try to add the instances to the parent (Children.Add()). I wasn’t able to find out exactly why this is happening, but after some digging, I figured that this happens because the newly created object instances have not been given a name and therefore the runtime cannot dynamically add two instances with the same name, or no names, for that matter… So, to avoid this run time exception, all you have to do is to give your newly created instances a name, thus, in our case, simply add:  e.SetValue(Canvas.NameProperty, <name>); to your loop… for (int...

Read More

Posted by on 14th December, 2008

Random animated clock

Random animated clock

I have done some code samples in Silverlight 2.0, but nothing worth sharing. So over the weekend, I saw an pretty impressive clock written in Flash and had to try to emulate some of its functionality in Silverlight 2.0. The clock can be seen here and I just loved the creativity, attention to detail and the smooth motion of the digits. For my experiment, I am only trying to (somewhat) reproduce the gyration of the number cluster, based on their location and individual rotation. Eventually, I will have more time to do it with all the digits and get it as smooth as in the Flash clock, with the subtle movements. For now, this is just a quick attempt at recreating the concept and will hopefully do… 🙂 mainpage.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightRandomClock_Fixed { public partial class Page : UserControl { public Page() { InitializeComponent(); this.animateSeconds.Begin(); } private void...

Read More

Posted by on 14th December, 2008

Simulating snow…

Simulating snow…

With the winter not bringing us any snow so far, I thought I’d make some snow myself… I had seen some implementations of “snowmaking” here and there in Silverlight 2.0, but found that some implementations were too complex for just a Sunday morning project. So I figured I’d try it myself… It is a very simple concept: generate programmatically 200 Image objects, populate them and then have one Storyboard, that fires every milliseconds, go through each one of the flakes, and move them a few pixels further down. Of course, if this were a formal project, I would have made each flake their own class etc., just like Mike did in his example, but this experiment needed to be something simple, quick and still look somewhat realistic. As you can see from the amount of code, which is relatively little, a lot more can be done here. Maybe rotate the individual flakes, take them from randomly different images, so they are not all the same and speed up some...

Read More

Posted by on 1st December, 2008

Joining Microsoft…

Joining Microsoft…

Well, that didn't take very long… a good opportunity presented itself almost immediately and although I was hoping for some downtime, I have decided to accept a job offer at Microsoft's headquarters in Redmond Washington. I will be joining the development team of the brand new store.microsoft.com site as a software developer starting tomorrow. The store was launched just a couple of weeks ago and provides an online presence where one can buy any Microsoft product directly from the source. It sounds like a great opportunity that I don't want to let...

Read More