One of my goals after Brent’s DNUG talk was to port my old QuickBasic Line Curve (not sure what other people call them) to C# code. So this evening that’s what I’ve been doing.
My first big thanks is to the Visual Studio team, because VS2005 can open and understand old QuickBasic .BAS files. I’m sure it actually basic of VB.Net, but it colour codes correctly and every thing. This made cut-n-pasting the code so much easier. Previously I’d opened QB and screen scraped it out 19 lines at a time.
An odd side effect of this was that when I had a .BAS file open, and did a Solution Build, the .BAS file would be compiled and it’s errors highlighted, even though it is not in any of my projects. So I keep closing and opening the file. Only with the power of hindsight do I even think of the remotely clever idea I opening it file in a second instance of VS.
So I got the code drawing the pretty graph. In the original I had it animated to appear to scroll, giving a pseudo 3D effect. Which I’d always wanted to use in a game. So I rigged up the MouseWheel event. For quite some time I couldn’t get it to work. I finally wired up MouseClick and then the mouse wheel event would fire after the first click. It appears to be a focus related issue, so I made my panel get Focus() when ever the MouseEnter event fires.
It is working pretty neat I think. The only current bug is the scrolling is done by drawing the four sub-polygon in each polygon, but you can see a tear between polygons as the outer points are not common. This will be my next task to fix.
After that I want to be able to drag the three control points of the graph around. I have some ideas that should be cool for focus of the drag points. So I’m looking forward to battling with those.