如何实现图标叠加

时间:2012-02-13 10:05:51

标签: c#

我正在开发一个Windows项目,但我真的陷入了Icon Overlay概念。我搜索了很多文章,但最后大多数成员建议在下面链接:

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

谢谢

2 个答案:

答案 0 :(得分:1)

这里是C#中的一个例子,虽然我为其更多的代码转储道歉而不是解释如何做到这一点。

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

重要的是这个,它采用Visual并将其转换为位图。 IconOverlay绑定到生成的位图。

 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;
    }

答案 1 :(得分:0)

由于我已经wrote here,您只需查看into the sources TortoiseSVN即可了解如何执行此操作。

相关问题