Disney Count support may be spotty from here. We apologize for the inconvenience.

.Net question

Is there a good way to accomplish the following:

Given a set of icons and coordinates for where to place them, I need to assemble a larger image that places the icons in the correct places and then annotates them dynamically by doing things like drawing arrows between some of them, placing other icons nearby as flags, labelling them with text, etc.

I'm doing this in a web app using asp.net and C# for the code-behind.  I'm a .NET newbie (only been doing it for a few weeks) and I'm not sure where to look.
Permalink the great purple 
July 12th, 2007 1:15pm
There may be some custom controls for plotting flow charts and such that could help with something like that.

I don't know the included controls inside-and-out, but none come to mind immediately that would help you significantly.
Permalink Send private email JoC 
July 12th, 2007 1:19pm
I'd done almost the same thing as you describe. Here're snapshots of the software.

http://www.vbforums.com/showthread.php?t=260412&highlight=Workflow+Designer

But this was in 2002 and I'd used VB 6.0 with the Win32 API GDI functions (BitBlt, StretchBlt, IntersectRect etc.) to do the drawing at runtime.

You can do the same thing today with .NET's in built GDI support much more easily.

I'll dig out some relevant code snippets out of my code (for reasons you'll understand, I can't send you the full source code) to give you an idea.
Permalink Send private email jingalala jingalala ™ 
July 12th, 2007 1:22pm
Syncfusion has a diagramming library for doing this stuff, but I don't think it's for the web.
Permalink Send private email xampl 
July 12th, 2007 2:10pm
Alright, I'll point my research in the GDI direction.  I'm sure this is possible, even if it will be annoying.  Thanks.
Permalink the great purple 
July 12th, 2007 2:46pm
Actually, it is not that difficult.

-- Use photoshop or paintshop to assemble your icons into a single picture. That way you can place the whole toolbox into just one control.

That is because each control you take (for example, a picture box, is a windowed control and has its own expensive resources such as a handle, a device context, its own stack, local thread storage etc.)

-- When the mouse hovers over the control, do a hit-test. You can do this by handling the MouseMove event if the control provides one (pictures boxes do). If not, you can set a local mouse hook over the control (http://www.vbforums.com/showthread.php?t=342209&highlight=mouse+hook).

-- Maintain a data structure/class that represents each icon. Store the dimensions, an id and a name for that icon, along with other custom properties you might want (such as the text associated with it that the user may enter when he places the icon on the canvas)

-- Maintain a data structure/class to represent the toolbox. This will contain a collection of icons, along with the co-ordinates of each icon so that you know which icon the user selects in the hit-test.

-- In the MouseMove and MouseDown events, redraw the client area ( Paint event, BitBlt, InvalidateRect, Update() ).

-- For the lines, use a raster operation (SetROP2) with an XOR operation to reverse the ink he is drawing with each time so that with the first move the ink is black and in the next move, you erase the black by re-drawing on the same co-ordinate with the color of the background.

-- Rinse and repeat.

Let me know if you need any help. I'll be glad to help out.
Permalink Send private email jingalala jingalala ™ 
July 12th, 2007 5:31pm
Visio.

Or, reinvent Visio from scratch.

Your call. :)
Permalink Send private email Philo 
July 12th, 2007 6:34pm
lol.  jingalala has entirely misunderstood what I want to do.  Philo has only mostly misunderstood.  But it's ok.  I'll go exploring the wide world of GDI and I'll figure it out.
Permalink the great purple 
July 13th, 2007 12:22am
If you do this in a web application, I don't see how GDI is useful, unless you want to generate images dynamically and then display them in the web-page.

If that is what you want to do I have some example code (in the form of a Captcha component) in C# asp.net that can get you started.
Permalink Send private email Erik Springelkamp 
July 13th, 2007 6:15am
I want to generate images dynamically and display them on the web page.
Permalink the great purple 
July 13th, 2007 9:04am
http://springelkamp.nl/Files/Captcha.cs

This dynamically generates a Captcha.jpg (in the session object) that can be displayed in a webpage of the same session.

It was only a proof of concept, but it should get you started.
Permalink Send private email Erik Springelkamp 
July 13th, 2007 11:17am
Erik, nice. I was wondering why you wrote an ISAI Extension/IHttpHandler for a single page.
Permalink Send private email jingalala jingalala ™ 
July 13th, 2007 4:00pm
> an ISAI Extension/IHttpHandler

ISAPI Extension/IHttpHandler
Permalink Send private email jingalala jingalala ™ 
July 13th, 2007 4:01pm
> I was wondering why you wrote an HttpHandler for a single page.

Because there is no use for an aspx "user-interface".

I find the single file HttpHandler more elegant than an empty aspx page that only uses the code behind. And it is easier to reuse over projects.
An aspx page is for producing html, and has no use in other contexts. In the end it all comes down to the same thing.

Anyway, you can use the handler to produce more than one kind of content, by using querystrings for instance.
Permalink Send private email Erik Springelkamp 
July 13th, 2007 4:21pm
Hmm! Thanks.
Permalink Send private email jingalala jingalala ™ 
July 13th, 2007 5:04pm

This topic is archived. No further replies will be accepted.

Other topics: July, 2007 Other topics: July, 2007 Recent topics Recent topics