'Draw Text on Rectangle - Issue with Windows zoom function
I drawing a rectangle with a dynamic number as a string on it and use it for a windows taskbar icon (overlay icon):
private void DrawOverlayIcon(string queue_count) {
Bitmap bitmap = new Bitmap(30, 30, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bitmap);
g.FillRectangle(System.Drawing.Brushes.White, 0, 0, 30, 30);
Rectangle r = new Rectangle(0, 0, 30, 30);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center; // horizontal
sf.LineAlignment = StringAlignment.Center; // vertikal
Font f = new Font("Arial", 14, System.Drawing.FontStyle.Bold);
g.DrawString(queue_count, f, System.Drawing.Brushes.Black, r, sf);
IntPtr hBitmap = bitmap.GetHbitmap();
ImageSource wpfBitmap = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
_icon_overlay = wpfBitmap;
So far so good. But when a user set up the windows zoom function to maybe 120% or 150% the number becomes so large that it is only displayed as one digit.
Can anyone help?
Thanks a lot.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
