1

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:

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

Thank you

Rup
  • 33,765
  • 9
  • 83
  • 112
  • Are you trying to add overlays in the shell (i.e. Windows Explorer), or are you trying to use icon overlays in your own ListView inside a WinForms application? (Or are you using WPF or Silverlight or LightSwitch?) – Joe White Feb 13 '12 at 13:27

2 Answers2

1

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

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;
    }
AlSki
  • 6,868
  • 1
  • 26
  • 39
0

As i already wrote here, you can simply take a look into the sources of TortoiseSVN to find how to do this.

Community
  • 1
  • 1
Oliver
  • 43,366
  • 8
  • 94
  • 151