on food, photo's, diving

Volkskrantdag IFFR

Route 14

10:00 Schouwburg Grote Zaal Nebraska

12:30 Pathe 2 Vergiss mein Ich

15:00 Doelen Grote Zaal Finsterworld

17:30 Cinerama 1 Han Gong-Ju

20:30 Luxor The Reunion



Beauty in chaos

As always there’s beauty to find in chaos. This time the credits go to the route planning site of TomTom,



The picture shows traffic congestion in the urban area called “de Randstad” in The Netherlands.

The total length of congested high ways in the morning of december 17th 2010 is 275 km, for all the Netherlands.
The maximum recorded length is 966km on monday evening, november 29th of 2010 after heavy snow. 

Diving equipment: Scubapro MK20


Diving gear is beautiful in its own way (should you have a passion for fine mechanics, anyway)

The MK20 is a first stage, part of a series of equipment to provide a diver with air. Its function is to bring the pressure in the cylinder (about 200 – 300 bar) down to about 10 bar. The second stage brings the pressure down to the pressure of the surrounding water. (picture below: A R190 second stage, known as the workhorse of the Scubapro line of second stages)  





Comment spam


After al long time away from the blogosphere I am up to the task again. At least so I thought. It seems I have a lot of comment scam to cleanup.
Well, the first part I’ve cleaned up is the link in this blog’s comments as it is the prime reason for spamming.

One comment by payday loan I’ll quote:
“Good post but not cool enough to rule. I usually never comment on posts, and yet I can't help leaving a comment: people never learn, they will always spam you! Amazing work.. beautiful”

Thank you, payday loan, for your kind words. But I do not agree: People are very quick to learn new ways to make some money. If there no more money to gain the spam comments will dwindle (so I hope).

Patee of grilled herring

In Portugal there’s a delicious fish paste called “Patê de sardinha”. It’s served with bread as a small bite before dinner or as small snack accompanying drinks.
Unfortunately it’s not easy to come by in Holland. So once in a while I try to make a substitute. Here’s the one for today:

Two BBQ grilled herrings (left over from yesterday, grilled with a basil and olive oil dressing)
50 ml of walnut oil
One small tin of tomato puree (about 70 grams)
Salt and pepper to taste

Remove fish bones if there are any left
Mash the fish in a blender together with the tomato paste
Add walnut oil until the paste is creamy
season with salt and pepper

Serve with fresh baked Baguette in slices

Suggestions to drink:
Ice cold vinho verde when it’s really hot or
Joãn Pirez (Even harder to come by then Patê de sardinha, sadly)

In the nick of time: element to element binding in Silverlight 2


In the previous post about the fillet code I showed a Silverlight demonstration of various connected lines that can be dragged around.

Since binding is a great mechanism to update various elements, and using events is sooo nineties. I implemented a small utility class that does the job.
The issue is that in Silverlight 2 binding between two FrameworkElements is not possible. The workaround is simple but not elegant: you create a intermediate object class that both the frameworks elements can bind to:

Technorati Tags: ,,


Though it’s a simple solution, its also annoying:

Creating an Intermediate class that holds exactly that specific  value;
It’s not XAML-able (though you could thing of a construction with an object in the page resources). If you are looking for a in-XAML solution, check out this article by Colin Eberhardt.

So I created a utility class that does the work and is reusable:

The object has four exposed properties and a private Object that got bounded to. Using an Object is very convenient because casting is done by the Binding framework 
FrameWorkElement BindingHelper.Source
DependencyProperty BindingHelper.SourcePoperty

FrameWorkElement BindingHelper.Target
DependencyProperty BindingHelper.TargetPoperty

The binding can be made OneWay, by making the binding of the target OneWay, The binding of the source has always to be TwoWay, since I’m using the binding between the Source and the BindingObject in a reverse way: from Source to Object.

After I bound several lines to a single Point, I realised that such an approach was not feasible: the last binding object removed a previous one from the SourceProperty.
So I extended the BindingHelper class to a BindingDispenser that used one Source Framework Element with one SourcePoperty and several Targets.
The Targets Subscribed to the Source-SourcePoperty  combination. That works ok, except for the declaration of each of the individual dispensers:

private ElementBindingDispenser Line1StartPoint;
        private ElementBindingDispenser Line1EndPoint;
        private ElementBindingDispenser Line2StartPoint;
        private ElementBindingDispenser Line2EndPoint;

        private ElementBindingDispenser Line1MidPoint;
        private ElementBindingDispenser Line2MidPoint;

        private ElementBindingDispenser RadiusValue;

        private ElementBindingDispenser CenterConnectorMidpoint;
        private ElementBindingDispenser EndValue;
        private ElementBindingDispenser StartValue;

        public Page()

            Line1StartPoint = new ElementBindingDispenser() {Source = MainLine1, SourceProperty = DraggableLineControl.StartPointProperty, AllowContributers = false};
            Line1EndPoint = new ElementBindingDispenser() {Source = MainLine1, SourceProperty = DraggableLineControl.EndPointProperty, AllowContributers = false};
            Line2StartPoint = new ElementBindingDispenser() {Source = MainLine2, SourceProperty = DraggableLineControl.StartPointProperty, AllowContributers = false};
            Line2EndPoint = new ElementBindingDispenser() {Source = MainLine2, SourceProperty = DraggableLineControl.EndPointProperty, AllowContributers = false};
            Line1MidPoint = new ElementBindingDispenser() {Source = MainLine1, SourceProperty = DraggableLineControl.MidPointProperty, AllowContributers = false};
            Line2MidPoint = new ElementBindingDispenser() {Source = MainLine2, SourceProperty = DraggableLineControl.MidPointProperty, AllowContributers = false};

            RadiusValue = new ElementBindingDispenser() { Source = slRadius, SourceProperty = Slider.ValueProperty, AllowContributers = false };

            ConnectionLine1.Subscribe(Line1StartPoint, DraggableLineControl.StartPointProperty);
            ConnectionLine1.Subscribe(Line2StartPoint, DraggableLineControl.EndPointProperty);

            ConnectionLine2.Subscribe(Line1EndPoint, DraggableLineControl.StartPointProperty);
            ConnectionLine2.Subscribe(Line2EndPoint, DraggableLineControl.EndPointProperty);

            ConnectionLine3.Subscribe(Line1StartPoint, DraggableLineControl.StartPointProperty);
            ConnectionLine3.Subscribe(Line2EndPoint, DraggableLineControl.EndPointProperty);

            ConnectionLine4.Subscribe(Line1EndPoint, DraggableLineControl.StartPointProperty);
            ConnectionLine4.Subscribe(Line2StartPoint, DraggableLineControl.EndPointProperty);

            MPConnectionLine1.Subscribe(Line1MidPoint, DraggableLineControl.StartPointProperty);
            MPConnectionLine1.Subscribe(Line2MidPoint, DraggableLineControl.EndPointProperty);

            MPConnectionLine1.Subscribe(Line1MidPoint, DraggableLineControl.StartPointProperty);
            MPConnectionLine1.Subscribe(Line2MidPoint, DraggableLineControl.EndPointProperty);

            TheFilletArc.Subscribe(Line1StartPoint, FilletArc.Line1StartProperty);
            TheFilletArc.Subscribe(Line1EndPoint, FilletArc.Line1EndProperty);
            TheFilletArc.Subscribe(Line2StartPoint, FilletArc.Line2StartProperty);
            TheFilletArc.Subscribe(Line2EndPoint, FilletArc.Line2EndProperty);
            TheFilletArc.Subscribe(RadiusValue, FilletArc.RadiusProperty);

it would be nicer to have a central place to subscribe, and to unsubscribe from.

Something like this:

private void CmdSubscribe_Click(object sender, RoutedEventArgs e)
    Dispensers.Subscribe(MainLine1, DraggableLineControl.StartPointProperty, TheFilletArc, FilletArc.Line1StartProperty);
    Dispensers.Subscribe(MainLine1, DraggableLineControl.EndPointProperty, TheFilletArc, FilletArc.Line1EndProperty);

    Dispensers.Subscribe(MainLine2, DraggableLineControl.StartPointProperty, TheFilletArc, FilletArc.Line2StartProperty);
    Dispensers.Subscribe(MainLine2, DraggableLineControl.EndPointProperty, TheFilletArc, FilletArc.Line2EndProperty);

    Dispensers.Subscribe(slRadius, RangeBase.ValueProperty, TheFilletArc,FilletArc.RadiusProperty);

private void CmdUnSubscribe_Click(object sender, RoutedEventArgs e)
    Dispensers.UnSubscribe(TheFilletArc, FilletArc.RadiusProperty);

Unfortunately Silverlight does not provide a way to retrieve binding settings. So UnSubscribing would  be a matter of setting the value and thus abandoning the binding.

If Silverlight 3 were years away, it would be a nice concept to work-out and refine further. But as it is, I ‘ll use this as a temporary solution.
If your interested: here’s a zip with the helper classes (NB: not tested for production, just for demo purposes)

Fillet and the point inside

A while ago Yu-Chung Chen commented on my post The fillet pseudo code. He reminded me of a small issue that remained unsolved: the point inside. Though the algorithm worked fine finding which of the four possible fillets was the right one should still be decided. I imagined that the intersection of the connection lines between start en end point of the two main lines would be a nice indicator. I decided to make a small Silverlight demonstration to show my point (pun intended).
A good point I did so: Immediately became clear that such a solution worked in a limited number of cases:



Only after I added a line between the the midpoints of both lines it became clear that the midpoint of this line was the most suitable candidate for the point inside. And indeed:


The FilletArc I’ve made into a control, to use binding on the endpoints of the mainlines (In Silverlight element binding is possible but you do need some extra objects to intermediate)

The fillet arc is drawn (adjusted) in the invalidate method, that  will be called from DependencyPropertyChanged callback:

private void Invalidate()
            Point L11 = Line1Start;
            Point L12 = Line1End;
            Point L21 = Line2Start;
            Point L22 = Line2End;
            double radius = Radius;
            Point mid = new Point((L11.X + L12.X + L21.X + L22.X)/4,(L11.Y + L12.Y + L21.Y + L22.Y)/4);
            ArcSeg arcseg = LineUtilities.FilletArc(new LineSeg(L11, L12), new LineSeg(L21, L22), Radius, mid);
            double sA = arcseg.StartAngle * 180 / Math.PI; 
            double eA = arcseg.EndAngle * 180 / Math.PI; 
            //We only want the inner arcs
            if (eA - sA > 180) sA += 360;
            if (sA - eA > 180) eA += 360;
            FilletArcSegment.IsLargeArc = Math.Abs(eA - sA) > 180;
            FilletArcSegment.SweepDirection = eA > sA ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
            FilletArcSegment.Size = new Size(radius, radius);
            FilletArcSegment.Point = FromPolarPoint(eA, radius, arcseg.Center);
            ArcPathFigure.StartPoint = FromPolarPoint(sA, radius, arcseg.Center);

The utility arcseg holds the data of the fillet. In the helper class LineUtilities it shows the (pseudo) code I posted before:


public static ArcSeg FilletArc(LineSeg Line1, LineSeg Line2, double Radius, Point pointOnInside)
           Point center = (Point)Line1.Offset(Radius, pointOnInside).Intersect(Line2.Offset(Radius, pointOnInside));
           return new ArcSeg()
                      Center = center,
                      // P2 is the intersection point of the returned linesegment
                      StartPoint = Line1.PerpendicularLine(center).P2,
                      EndPoint = Line2.PerpendicularLine(center).P2,


Both the fillet arc and the line segment utilities you can find in


Shooting pictures gets you in weird places. I was taking some close-ups of a tech-game-gadget called Magnetix.




We build a dodecahedron consisting of fragments of pentagon pyramids

20090628_1739 20090628_1739

And found a beautiful artefact hidden in the construction*


* No, the artefact was not the photographer:

A Silverlight gadget in four steps

  • Create the solution
  • Add a post build action utility project
  • Add the Silverlight projects to the web project
  • Create the settings  of the gadget

1 Create the solution

If you have installed the templates I wrote about in a previous post, you can find a new solution template here:


If you run this template you end up with a solution with several projects.


Silverlight gadget solution

As you can see the template created 5 Silverlight projects, each for a different part of the gadget. It also created a web project. This is the actual project where all the Silverlight application come together.

2 Add Post build utility project

Also, as I posted before, I have added an empty utility project to package the generated files into a zip with extension “.gadget”. That would be a nice addition to the template. For now the post build project hast to be added by hand.
Here you’ll find a zip with both the batch file and the list file:

The batch file and the listfile

The post build action itself:

cd "$(SolutionDir)$(SolutionName)\SilverlightSidebarGadgetWeb\" 

By now you might be tempted to build your project and install the generated gadget (I know I did). But there’s two more things to do before you get a valid gadget.

3 Add the Silverlight to the web project:

The template has no means to add the Silverlight projects to the web project so You’ll have to add them yourself. Go to the property page of the web project and add each of the projects



Make sure the Destination folder is the same you specified in the post build project, and check the Enable Silverlight debugging checkbox.

4 Create the settings for your gadget.

In the web project you’ll find the file gadget.xml in which the settings of your gadget are defined. The important parts are marked by square brackets. Change these to indentify your gadget, and be sure to think about the name of the gadget file. Vista uses both the filename and gadget.xml to show information about your gadget.

Now you can build and add your Silverlight Gadget to your toolbar. Hello docked!

And now you’re ready for the real stuff: Silverlight. I’ll show you about continuous animation in a next post.

Boris Isnietsch at the “Mooi Weer Spelen”

A hilarious act with three man and a coffee making contraption the size of a car.
Never mind the rain!