Drag & Drop

It is sad how often I see applications that could have use of drag&drop mechanism but are blissfully unaware of it. Sad part is that half of those annoying applications are mine. :)

And it is annoyingly easy to implement. In addition to setting AllowDrop=true on your favorite control or form you need to implement two events:

private void list_DragEnter(object sender, DragEventArgs e) {
    e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Move : DragDropEffects.None;
}

private void list_DragDrop(object sender, DragEventArgs e) {
    if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
        var files = (string[])e.Data.GetData(DataFormats.FileDrop);
        DoSomething(files);
    }
}

And this is all there is to it.

8 Grams of Bullshit

Illustration

My last visit to McDonald I noticed that my meal has “8 grams of whole wheat” printed on package. I was quite surprised to see US company use Système international d’unités to express how much of health they pack in the box.

To put things into perspective 8 grams is almost 4 times less than legal amount of marijuana in California. That whole grain thing is really potent stuff indeed.

While someone might say that McDonald is not doing anything wrong and that this is just reporting fact I would not agree. I think that this is pure game of numbers that targets USA citizens that quite often have no feeling what grams are (as I have no feeling for ounces). This is pure sham intended to represent their food as a healthy choice.

McDonald food is probably the next best thing one can do to his body after a car crash and that probably holds true for fast food in general. Of course I will grab occasional meal or two because I don’t have time for anything better and because (shame) I do like taste of it. Just please stop bullshitting be. Let my cholesterol rise in peace.

P.S. For my SI challenged USA friends 8 grams is 0.28 ounces. :)

VHD on ExFAT

Illustration

One of nicest hidden gems in Windows 7 is exFAT. It’s a simple file system with support for huge files (16 EB) but without any support for access control. Pretty straightforward replacement for FAT32.

As leap of faith action I decided to format one whole disk with it. It was disk that kept my multimedia files and occasional virtual disk. I wasn’t troubled by security since BitLocker works like a charm even inside of VHD. Unfortunately that plan was snipped in the bud.

As soon as I created virtual disk I was greeted with “The requested operation cannot be completed due to file system limitation”. Even worse, you cannot attach already existing VHD that happens to be there. It simply refuses to do anything.

While I haven’t done any detailed analysis, it seems that exFAT and VHD do not work together.

Ping

Few days ago I needed to check whether certain server was dead or alive. Any network guy will tell you that ping is your mate. While he also might tell you that ping might not work at all times (damn you firewall) I will ignore this unfortunate part for a moment. Suffice to say that ping works for my scenario.

While I used to solve this issues with good old P/Interop, I decided to check whether .NET Framework 3.5 (one that I used) is smarter that old grandpa 2.0. And what do you know, there is Ping class available inside System.Net.NetworkInformation namespace.

Class was made by someone who clearly hadn’t read Framework Design Guidelines but it does provide complete solution. At least code is easy enough:

var ping = new Ping();
var reply = ping.Send("www.example.com");
if (reply.Status == IPStatus.Success) {
    Debug.WriteLine(reply.RoundtripTime + " ms.");
}

Focus Thief

Illustration

There is NO REASON WHATSOEVER to make a window top-most if user has not explicitly requested so. And no application should make that sin.

Let’s imagine a scenario in which your server temporarily refuses connection. Outlook detects that password/user-name fails and decides to ask you. Since this is so important it shows window in foreground as A FUCKING TOP-MOST window. You dismiss it with cancel in order to continue with your work. In three seconds FUCKING TOP-MOST window reappears and you click it away, again. And it appears again. And you dismiss it again. And you start writing something only to have that FUCKING TOP-MOST window steal focus again. Most viruses/worms/diseases I know are not annoying as much as Outlook 2010.

I believe that developer who implemented this should be forced to do team programming with whichever moron manager thought this was a good idea. And they should kick each other in balls every time window pops-up.