如何实现图标叠加 [英] How to Implement Icon Overlay

查看:158
本文介绍了如何实现图标叠加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows项目,但我真的很坚持的图标叠加的概念。我已经搜索了许多文章,但最后大部分成员建议以下链接:

I am developing a Windows project but I am really stuck with the Icon Overlay concept. I have searched many articles but finally most of the members suggested to below link:

  • How to overlay an icon over existing shell objects in 3 easy steps

不过,我无法理解如何在C#中使用它。你能帮我吗?

However I can't understand how to use it from C#. Could you please help me?

感谢您

推荐答案

下面是一个例如在C#中,虽然我很抱歉它更多的是代码转储比如何做到这一点的解释。

Here's an example in C#, although I apologise its more of a code dump than an explanation of how to do it.

http://alski.net/post/2012/01/11/WPF-Icon-Overlays.aspx

最重要的一点就是这个,这需要视觉并将其转换成一个位图。该IconOverlay绑定到生成的位图。

The important bit is this which takes a Visual and converts it into a bitmap. The IconOverlay is bound to the generated bitmap.

 public static BitmapSource GenerateBitmapSource(Visual visual, double renderWidth, double renderHeight)
    {
        var bmp = new RenderTargetBitmap((int)renderWidth, (int)renderHeight, 96, 96, PixelFormats.Pbgra32);
        var dv = new DrawingVisual();
        using (DrawingContext dc = dv.RenderOpen())
        {
            dc.DrawRectangle(new VisualBrush(visual), null, new Rect(0, 0, renderWidth, renderHeight));
        }
        bmp.Render(dv);
        return bmp;
    }

这篇关于如何实现图标叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆