Using Direct X in a Winform application

Frasse

Newcomer
Joined
Jul 20, 2003
Messages
13
I'm thinking about writing a UserControl in VB.NET. If any of you have seen the nifty "LaunchBar" that Mac OS X uses you'll know what i mean.

The thing is that this control should be a control which you can use in any Winform application, it's purpose should be like the Outlook bar.

Anyway, I've been trying to write this control using GDI+ and I keep running into problems. I still don't know if the performance will be good enough. I really don't know if Direct X would solv the problem eidther since I'm doing my own manipulation of the bitmaps (based on my old school demo effect skills :D).

I'm not really sure if there are any nice lens effects in the DX API, or even if it's possible to do this in a easy way with DX.

Last time I coded DX was with version 5, and I really don't know if it's worth the effort relearning everything again.

Also if there are better ways to optimize the GDI+ code then there would be no point in rewriting it for DX. This is how I do it atm.

Startup:
- Create an instance of the UserControl (called LaunchBar)
- Set background image property (shadowed for my own purpose)
- Add Launch Items (Images)

The Launchbar keeps a:
- bitmap the size of the control called _Layer
- bitmap the size of the manipulation area called _LastSaved
- position of the _LastSaved bitmap called _LastPos

Initialize:
- Background image is tiled over the _Layer bitmap
- Each of the Launch item Icons are drawn on the _Layer bitmap aswell
- The _Layer bitmap is drawn on the UserControl

When mouse moves over the LaunchBar (MouseMove event):
- Check if the _LastSaved keeps a reference (If is Nothing) to a bitmap - If so, paint it back on the UserControl where it belongs
- Save the current mouse position in _LastPos and cut out the new _LastSaved bitmap (using Bitmap.Clone(Rect, PixelFormat))
- Send the _LastSaved bitmap into a method that creates a new bitmap called _Modified. The _Modified bitmap is based on the _LastSaved but the pixels are moved around to create a nifty effect. The _Modified bitmap is then returned to the caller.
- The _Modified bitmap is drawn on the UserControl

If there is a better way to do this, please give me feedback about it ;)

/Frasse
 
Back
Top