Tuesday, March 25, 2008

Flashing and Flickering


Since its creating a couple years ago, our C# charting product has had an issue with flashing and flickering. Several of us have tried several different ways to enable double buffering. This seemed like the solution, especially drawing from our experience in Java. But no matter how we set it, nothing ever changed. So I figured we must just be calling some Paint() method somewhere too many times. I dug through our source again with a debugger trying to figure things out. On occasion, Paint() methods were being called twice, but this didn't seem to correlate with flashing at all. And it was probably part of the setup as well to make sure things appeared correctly.

I then embarked on another search of the Internet trying to find out how to really enable double buffering in .NET. I stumbled upon an answer that was slightly different than anything I've tried before. Specifically, I've always been trying to use various versions of

this.SetStyle(ControlStyles.DoubleBuffer, true);

in various different places. There seemed to be a lot of potential places due to the object hierarchy we have in place. But the latest suggestion I found this morning was to set

this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

and set all those bits on the Control object in its constructor. Well, this was new to me and actually points to one specific object in the package - the Panel that holds the Charts. I added this line to each of its constructors, rebuilt the package and ran our tests. Everything not only passed, but there was no more flashing! Then I ran our demo gallery (a set of examples and much more demanding than the simple tests) and everything looked great!

So thank you to random forum poster somewhere!

Saturday, March 22, 2008

Ubuntu and WEP


I installed Ubuntu Linux on my old work laptop. I'll probably have to give this back to work at some point, but I have the option to buy it too. It's an old Dell Latitude (D600) that's a bit banged up from lots of time on the road. But it still works.

So I grabbed Ubuntu 7.10 Desktop and installed it. The LiveCD runs fine, but slow as it's all off the CD. Installing to hard disk is really straightforward, but it kept hanging at 90% when it was detecting hardware (or configuring hardware depending on when it actually hangs). Googling around a bit lead me to the answer to add "-noapic" and "-nolapic". It took me a minute to figure out where to do this, as the launcher for the installation program clearly wasn't the right place since these are basically options for starting Linux rather than an application. But the boot screen options from the LiveCD lets you add parameters then, so I stuck these on to the end of the initial startup command. The OS loaded OK again, and this time the installer completed. Reboot, everything looked good (better than "Error with OS" or something when rebooting after the stalled attempts).

The next step was to get wireless networking working. I've been working with Linux off and on for years, but never on a laptop. I'm very familiar with tools like "ifconfig" and "netstat" to get network bearings, but this doesn't help with wireless. I finally found "iwconfig" but couldn't get it to accept any settings -- just telling me it couldn't do the "SET" operation. The installer let me set up my username and password, but not the root password (I still need to figure out what that is!). Without the root password, I couldn't run "su" and test it as a permissions issue.

So I dug around the Internets a bit more and eventually hit somewhere and clicked the remnants of Linux days in my brain. The key of course is to use "sudo" which then just asked for my user's password (super user rights, without actually using root).

To cut this to the point, the key is to use "sudo" with "iwconfig" to set the key pieces of your wireless setup, as follows:

sudo iwconfig eth1 essid mysid

sudo iwconfig eth1 key a1b2c3d4e5

Just set the ID and the WEP key. And I just use 64-bit WEP, which needs just 5 hex bytes. Finally you need to set it up to use DHCP:

sudo dhclient3 eth0

Now, in theory all of this could be done in Ubuntu's Network Manager thing, but for some reason whatever I set there just wouldn't stick. I confirmed the Internet existed through Firefox, then rebooted and everything still worked. Wonderful.

I'll probably let the kids use this for a while for their Webkinz stuff and general email (how may 4 and 6 year olds can say they use Linux??). We'll see if it's actually worth buying from work, since I'd need to replace the battery to make it at all worthy.

Thursday, March 20, 2008

Resurrection Eggs ?!?


OK, I have lots of issues with Easter to begin with. Like any other Christian holiday, much of the themes are from much earlier pagan or local traditions. You bring fir trees inside at the winter solstice to celebrate life through the cold bleak winter season. You celebrate the rebirth of the earth in spring using symbols like eggs and bunnies. But Christian Easter jumps in here with their version of the resurrection story.

Of course, many grade school children who are forced into Sunday school eventually question what eggs and bunnies have to do with Christ being crucified and then apparently rising from the dead. Plus, if it's a Christian holiday, why does its date follow the Hebrew calendar? Except for "educated Christians" who have done their share of reading and comprehending the history of such holidays, most people would probably create some kind of kludgey circular answer.

Now in an apparent attempt to close this gap, some marketing genius has created "resurrection eggs" where you take plastic Easter eggs and fill them with little Christian symbols and hide them around the yard. Now you can turn that fun time into a "fun faith-filled Easter egg hunt". Woohoo - just what every kid wants is more brainwashing while hoping for chocolate goodies.

But just be sure to re-read the gospels before hand and highlight anywhere in there where eggs (plastic or otherwise) are mentioned. (hint: don't spend too much time on this, as there are zero references)

For another year in my household we will be celebrating the coming of spring. This will be via the American traditional Easter basket with colorful fake grass, various egg-shaped objects (plastic or jelly beans), and a chocolate bunny or two.

Happy Spring!