Since you progammed your application in C# using WinForms, I assume you used a PrintDocument and your printing takes place in a PrintPage
event using PrintPageEventArgs.Graphics
.
If this is the case, it should be possible to refractor the code which prints into a seperate method, which takes a an instance of Graphics
as parameter (and probably additional parameters, like page size and so on).
Then, you could create a (white) Bitmap
object with sufficient size (and the same aspect ratio as your paper), and supply it to the method described above. Then, you can go and count the pixels which have been colored and thus, caculate the percentage of the page which the printer would have printed on.
Keep in mind that you probably have to respect the margin around the printing area and different paper sizes for your calculation.
If the refractoring of the code prooves to heavy, you could create a wrapper for the Graphics
object, which "duplicates" all draw calls to a Bitmap
while printing, and then continue with counting the pixels.
(This answer assumes you want to monitor your application, not other applications on the system)