How to add dynamic text as Taskbar Icon overlay?

非 Y 不嫁゛ 提交于 2019-12-01 00:55:23
ceciliaSHARP

You can only add an Image so you have to create that:

    RectangleF rectF = new RectangleF(0, 0, 40, 40);
    Bitmap bitmap = new Bitmap(40, 40, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    Graphics g = Graphics.FromImage(bitmap);
    g.FillRectangle(System.Drawing.Brushes.White, 0, 0, 40, 40);
    g.DrawString("5", new Font("Arial", 25), System.Drawing.Brushes.Black, new PointF(0, 0));

    IntPtr hBitmap = bitmap.GetHbitmap();

    ImageSource wpfBitmap =
        Imaging.CreateBitmapSourceFromHBitmap(
            hBitmap, IntPtr.Zero, Int32Rect.Empty,
            BitmapSizeOptions.FromEmptyOptions());

    TaskbarItemInfo.Overlay = wpfBitmap;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!