将通知图标与文本叠加

发布于 2024-08-15 05:32:22 字数 741 浏览 2 评论 0原文

经过一些帮助后,我使用 windows.forms notifyIcon 类获得了 WPF(这不是一个主要的应用程序,所以不用担心纯度)。我想知道是否可以在 icom 上覆盖一些文本?

基本上我需要它来直观地显示我的网格视图中有多少条目。并在每次 SizeChanged 事件时运行它。这是我到目前为止所想到的,但不确定如何从这里继续。

  Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/ReturnJourneyPreparation;component/Resources/favicon.ico")).Stream;
  System.Drawing.Icon notIcon = new Icon(iconStream);
  System.Drawing.Image canvas = new Bitmap(notIcon.Width, notIcon.Height);
  Graphics artist = Graphics.FromImage(canvas);
  artist.DrawString(_Messages.Count().ToString(), new Font("Arial", 4), System.Drawing.Brushes.Black, (float)(notIcon.Width), (float)(notIcon.Height));

(PS。我无法使用 Philipp Sumi 的 NotifyIcon 模块)

谢谢,Psy

After some help here, I've got WPF using the windows.forms notifyIcon class (It's not a major app so not worried about purity). And I was wondering if its possible to overlay some text on the icom?

Basically I need it to visually show how many entries is in my gridview. And run this on everytime the SizeChanged event. This is what I have come up with so far, but not sure how to go on from here.

  Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/ReturnJourneyPreparation;component/Resources/favicon.ico")).Stream;
  System.Drawing.Icon notIcon = new Icon(iconStream);
  System.Drawing.Image canvas = new Bitmap(notIcon.Width, notIcon.Height);
  Graphics artist = Graphics.FromImage(canvas);
  artist.DrawString(_Messages.Count().ToString(), new Font("Arial", 4), System.Drawing.Brushes.Black, (float)(notIcon.Width), (float)(notIcon.Height));

(PS. I can't use Philipp Sumi's NotifyIcon module)

Thanks, Psy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不回头走下去 2024-08-22 05:32:22

您似乎正在尝试在图像/图标顶部添加水印。有关详细信息,请查看以下网站: http://www.c -sharpcorner.com/UploadFile/scottlysle/WatermarkCS05072007024947AM/WatermarkCS.aspx

您将能够在原始图标图形的顶部添加自定义文本。如果您不经常更新,这是一个很好的解决方案 - 但如果它会在短时间内运行多次(我在这里考虑进度条),您将为您的程序添加不必要的延迟。

It looks like you're trying to add a watermark on top of your image/icon. For more information check out the following site: http://www.c-sharpcorner.com/UploadFile/scottlysle/WatermarkCS05072007024947AM/WatermarkCS.aspx

You'll be able to add custom text on top of the original icon graphic. This is a great solution if you're not updating often--but if it's something that will be run many times in a short period of time (I'm thinking progress bar here) you'll be adding unneeded lag to your program.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文