BSA – Copy Diagram to Clipboard

In my first clipboard example I borrowed some code that copied a UserControl “as is” to the clipboard. If you study that code you will notice that it performs two steps:

  • Create a bitmap from a UI Control
  • Copy Bitmap to Clipboard

As the Canvas I use is dark theme background and the UserControl have grid lines and controls that is not part of the diagram that comes out a bit grim, so what I do next is to create a Canvas, copy symbols I need to the Canvas and then create a bitmap from this Canvas. In my case that is basically a copy of the code I used for Print/Preview.

  • Create new Canvas
  • Copy graphics you want to new Canvas
  • call canvas.Arrange()
  • Create a bitmap
  • Copy bitmap to clipboard and voila…

This gives me a solution to copy a diagram, change background/colors and copy that to the clipboard. The result can be seen below.

I still need to convert some colors correctly – or more correctly set up a editable conversiontable between light and dark theme since I use dark theme on screens and print and clipboard is light color themes.

 

Categories: BSA

Leave a Reply