Cubism
Remember Rubik’s cube? How about if it was… you know… LARGER? Watch this (hit Start): http://www.speedcubing.com/chris/20cube.html

Remember Rubik’s cube? How about if it was… you know… LARGER? Watch this (hit Start): http://www.speedcubing.com/chris/20cube.html
A good hint by Scott Hanselman: FeedBlitz can publish my blog by email automatically. If you want to use it, just enter your email address in the small form on the left and hit the button, or click here.
Developer Developer Developer day 2 was yesterday and it was fantastic. I met a bunch of people there and at the geek dinner afterwards. If you were there and we didn’t meet, bad luck… I’m sure we’ll manage next time - or you could just drop me a line. Anyway, don’t forget to leave your feedback about the event!
In a newsgroup I replied to a question about calculating average data throughput during data reception over the network. A simple average bytes per second calculation needs only a few lines of code:
The problem with this is that it may not render very exact values over a longer download period because actual network throughput tends to change a lot over WAN connections. It would be more accurate to work out an average over a number of most recent measured values instead. As this requires some handling of a store of measured samples, I decided to create a reusable class that can hold a number of samples in a ring buffer and calculate the current average from these samples. The class takes a weighting of each sample into account, because in scenarios like the one above it’s not always guaranteed that new samples can be measured in an exact frequency. Here’s the class:
Now the receive loop above could look like this:
This is the eighth article in my mini series about object pooling. Be sure to read part 1, part 2, part 3, part 4, part 5, part 6 and part 7 first.
So, although the number of downloads of the sample program hasn’t been exactly great, I’m finally continuing the series. As I said in a previous article, I’d like to factor out the resizing behaviour - but before I do that, I want to integrate functionality that’ll let me evaluate the pool’s performance with regard to resizing, so I can assess the different resizing approaches reliably.
Fortunately performance monitoring is something that needs to be integrated into the pool implementation anyway and Windows has all the tools on board. So I only need to configure a few performance counters in Windows, make sure that these counters are updated with current numbers and the Windows performance monitoring frontend is available to the user to show it all in a nice graph. (I’m sure some of you have never heard of the performance monitor application - it’s available on the Administrative tools menu and it’s called, not surprisingly, Performance.)
Here’s the download for the current version, including these changes: ObjectPooling-2.zip

And these are the changes - at the end of the pool class:
In the ExtendPoolBy method:
In the ShrinkPoolBy method:
… and similar code for the other counter in the GetObject and ReleaseObject methods.
And another piece of good news that had so far escaped me: in .NET 2, it’s finally possible to explicitely configure the order in which class members are serialized to XML. See the XmlElementAttribute.Order property.
Using a new feature called Version Tolerant Serialization in .NET 2, it becomes possible to change class definitions and still deal with old serialized data versions after an application has been updated. This is actually extremely easy to do. Consider this code:
Now say you have deployed version 1 of your application with this class definition and used serialization to save instances of class Test to some kind of storage. Users of your application have megabytes of data stored away in that specific format.
Now you continue developing your application and you find the need to add properties to Test. The problem is, once you do that, you’ll no longer be able to deserialize the earlier version of the class, resulting in huge data loss for your users! Version Tolerant Serialization is the feature that comes to the rescue here. You can now define your new class version like this:
In many cases, dedicated fixup code may not really be necessary, but it’s certainly possible to work with older data definitions in this way, at least for most kinds of changes. There are also corresponding attributes OnSerializing and OnSerialized, in case a hook into the serialization process is needed as well.
This page describes a problem with .NET simple data binding - a property of a custom type couldn’t be bound correctly to the Text property of a standard TextEdit, because the internal logic would never convert the string value back to the object type. A given TypeConverter would simply be ignored in the process. The only workaround was to use the Parse event of the Binding object - not a nice way to go because the code wouldn’t be central to the class and its type converter any more.
While looking at the reasons behind this, I found a workaround for this in .NET 2: the FormattingEnabled property of the Binding object. While this is documented to do something quite different, the changed logic of the Binding.OnParse method actually checks for this parameter and the problem doesn’t show when FormattingEnabled is set to true for the binding.
It’s possible to pass true for this parameter right when creating the binding, like this:
Now I’m still wondering if I’m missing something here… the original problem, although it seems to be as described on the NoiseEHC page, sounds so… stupid? And the small change in .NET 2, while it does the trick, doesn’t look like a purposeful fix of the issue to me. Hm.
Just bragging
Here it is: The Daily Grind 725
If you haven’t seen my Electric Editing plugin, look here.
Update: I just noticed that Jim Holmes also wrote a report about it on Visual Studio Hacks.
Just saw this post in a newsgroup about how to show the horizontal lines that Microsoft likes to use in their dialogs. A lot of people replied with ideas of using other controls, like panels, to achieve the desired effect - to me, a much simpler and more effective idea is to just create a control myself.
So, the specific style described by the OP seems to be this:

This is what you get by using a label set to a height of 2 and with a BorderStyle of Fixed3D. The OP said explicitely that this was what he wanted, which I find curious because the lines in my Word Options dialog, for instance, look quite different:

So, to account for both needs, I included the etched border as well as the single line border in my sample. I’m sure there are millions of other line styles out there, but these should be simple to include once the framework is there. Here’s the control source code:
This was done in VS 2005 beta 2. You might have to make minor changes for .NET 1 if needed - I’m not 100% sure about the flags in the SetStyle call, look them up if you need to.
… for the sheer number of opportunities it provides? Opportunities to waste lots of time with non-essential things, is what I mean.
My highscore is 321.
Powered by WordPress
© Copyright 2005-2008 Oliver Sturm