
Hi Everyone, I'm migrating an old VB6 app to .NET. It used a PictureBox control and of course that had all sorts of options for drawing all over it. In the end, it was used to generate JPG images that were printed. I'd really prefer to use PDF as output anyway. Does anyone have a favourite control that presents a drawable surface that you can output as a PDF? (Or ideally as a JPG as well?) I get the impression that the .NET version of the PictureBox is way different, although it does seem to expose a Graphics object that you can then draw on. Is it better to stick with the standard .NET control and work out how to migrate the code? Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> | About Greg: https://about.me/greg.low

Hi Greg, The WinForms PictureBox control is pretty basic, it's mostly designed for displaying images, not really for drawing. In the distant past I've used Leadtools Imaging Pro for a WinForms document management project that required annotation, but that can get expensive if your needs are basic and looking towards the future I can't quite tell what their .NET 7+ story is anymore. These days it might be worth looking into SkiaSharp canvas drawing, and there are also some PDF export samples in the github repository. cheers, Tony On 16/03/2023 09:45, Dr Greg Low via ozdotnet wrote:
Hi Everyone,
I’m migrating an old VB6 app to .NET. It used a PictureBox control and of course that had all sorts of options for drawing all over it.
In the end, it was used to generate JPG images that were printed.
I’d really prefer to use PDF as output anyway.
Does anyone have a favourite control that presents a drawable surface that you can output as a PDF? (Or ideally as a JPG as well?)
I get the impression that the .NET version of the PictureBox is way different, although it does seem to expose a Graphics object that you can then draw on. Is it better to stick with the standard .NET control and work out how to migrate the code?
Regards,
Greg
Dr Greg Low
1300SQLSQL (1300 775 775) office | +61 419201410 mobile
SQL Down Under| Web: https://sqldownunder.com <https://sqldownunder.com/>| About Greg:https://about.me/greg.low <https://about.me/greg.low>

Hi Tony, Thanks so much for the pointer to SkiaSharp. That certainly looks interesting. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> | About Greg: https://about.me/greg.low From: Tony McGee via ozdotnet <ozdotnet@ozdotnet.com> Sent: Thursday, 16 March 2023 12:32 PM To: ozdotnet@ozdotnet.com Cc: Tony McGee <tmcgee.au@gmail.com> Subject: Re: Replacement for old PictureBox Hi Greg, The WinForms PictureBox control is pretty basic, it's mostly designed for displaying images, not really for drawing. In the distant past I've used Leadtools Imaging Pro for a WinForms document management project that required annotation, but that can get expensive if your needs are basic and looking towards the future I can't quite tell what their .NET 7+ story is anymore. These days it might be worth looking into SkiaSharp canvas drawing, and there are also some PDF export samples in the github repository. cheers, Tony On 16/03/2023 09:45, Dr Greg Low via ozdotnet wrote: Hi Everyone, I’m migrating an old VB6 app to .NET. It used a PictureBox control and of course that had all sorts of options for drawing all over it. In the end, it was used to generate JPG images that were printed. I’d really prefer to use PDF as output anyway. Does anyone have a favourite control that presents a drawable surface that you can output as a PDF? (Or ideally as a JPG as well?) I get the impression that the .NET version of the PictureBox is way different, although it does seem to expose a Graphics object that you can then draw on. Is it better to stick with the standard .NET control and work out how to migrate the code? Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> | About Greg: https://about.me/greg.low

Dr L, About 15 years ago I recall drawing to Windows Forms Bitmap then drawing (blt-ing) it into a PictureBox. A timer would draw many times per second to create a primitive but acceptable animation. I can't find the code now. I'd construct a Bitmap, then g = bmp.CreateGraphics() and use the various Graphics methods to set pixels, draw rectangles, etc. Then g.DrawImageUnscaled into the PictureBox. The C# classes are clearly thin wrappers over GDI+ and the C# code looks a bit like C++ code from the 1990s. If you have VB6 code that "draws", then maybe a translation to GDI calls would be easy (?!). I haven't used Skia, but some friends like it in Xamarin apps. *Greg K*

Thanks Greg. I do wonder how I’ll push it into a PDF later but I’m trying the drawing part first. Not sure what I did in a past life to end up doing this at present 😊 Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> | About Greg: https://about.me/greg.low From: Greg Keogh via ozdotnet <ozdotnet@ozdotnet.com> Sent: Thursday, 16 March 2023 1:17 PM To: ozDotNet <ozdotnet@ozdotnet.com> Cc: Greg Keogh <gfkeogh@gmail.com> Subject: Re: Replacement for old PictureBox Dr L, About 15 years ago I recall drawing to Windows Forms Bitmap then drawing (blt-ing) it into a PictureBox. A timer would draw many times per second to create a primitive but acceptable animation. I can't find the code now. I'd construct a Bitmap, then g = bmp.CreateGraphics() and use the various Graphics methods to set pixels, draw rectangles, etc. Then g.DrawImageUnscaled into the PictureBox. The C# classes are clearly thin wrappers over GDI+ and the C# code looks a bit like C++ code from the 1990s. If you have VB6 code that "draws", then maybe a translation to GDI calls would be easy (?!). I haven't used Skia, but some friends like it in Xamarin apps. Greg K

To summarise, I did get the new standard picturebox, etc. working as I needed. Thanks to all who tried to help. Hats off to anyone who finds that current doco useful though. Seems a complete mess. As an example from today, I was super-impressed with the quality of the TreeView documentation. [cid:image001.png@01D95921.AE4412F0] That’s pretty but pretty much completely useless. I did click on the ContextMenuStrip link in the middle of the text, and it has a bit more but again, it has an auto-generated description, one example that’s not great (under a heading of “Examples” – that’s funny), then auto-generated lists of properties, methods, and events. I mean, how could anyone not find that useful? There continues to be a basic misconception about the purpose of this documentation. Somewhere it really needs to actually be helpful. What’s concerning is that it’s still at the level that it was in the early 2000’s. It’s lucky we have Google and YouTube and helpful souls who describe what they’ve learned the hard way. Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> | About Greg: https://about.me/greg.low From: Tony McGee via ozdotnet <ozdotnet@ozdotnet.com> Sent: Thursday, 16 March 2023 12:32 PM To: ozdotnet@ozdotnet.com Cc: Tony McGee <tmcgee.au@gmail.com> Subject: Re: Replacement for old PictureBox Hi Greg, The WinForms PictureBox control is pretty basic, it's mostly designed for displaying images, not really for drawing. In the distant past I've used Leadtools Imaging Pro for a WinForms document management project that required annotation, but that can get expensive if your needs are basic and looking towards the future I can't quite tell what their .NET 7+ story is anymore. These days it might be worth looking into SkiaSharp canvas drawing, and there are also some PDF export samples in the github repository. cheers, Tony On 16/03/2023 09:45, Dr Greg Low via ozdotnet wrote: Hi Everyone, I’m migrating an old VB6 app to .NET. It used a PictureBox control and of course that had all sorts of options for drawing all over it. In the end, it was used to generate JPG images that were printed. I’d really prefer to use PDF as output anyway. Does anyone have a favourite control that presents a drawable surface that you can output as a PDF? (Or ideally as a JPG as well?) I get the impression that the .NET version of the PictureBox is way different, although it does seem to expose a Graphics object that you can then draw on. Is it better to stick with the standard .NET control and work out how to migrate the code? Regards, Greg Dr Greg Low 1300SQLSQL (1300 775 775) office | +61 419201410 mobile SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> | About Greg: https://about.me/greg.low
participants (3)
-
Dr Greg Low
-
Greg Keogh
-
Tony McGee