Click here to Skip to main content
15,885,757 members
Articles / Desktop Programming / Win32

.NET Shell Extensions - Shell Icon Overlay Handlers

Rate me:
Please Sign up or sign in to vote.
5.00/5 (32 votes)
14 Sep 2013CPOL7 min read 185.6K   6.5K   83  
Create Shell Icon Overlay Handlers using .NET!
using System.Collections.Generic;
using System.Runtime.InteropServices;
using SharpShell.Attributes;
using SharpShell.SharpPropertySheet;
using System.Linq;

namespace TextFilePropertySheet
{
    /// <summary>
    /// The TextFilePropertySheet is a property sheet extension for text files.
    /// </summary>
    [ComVisible(true)]
    [COMServerAssociation(AssociationType.ClassOfExtension, ".txt")]
    public class TextFilePropertySheet : SharpPropertySheet
    {
        /// <summary>
        /// Determines whether this instance can show a shell property sheet, given the specified selected file list.
        /// </summary>
        /// <returns>
        ///   <c>true</c> if this instance should show a shell property sheet for the specified file list; otherwise, <c>false</c>.
        /// </returns>
        protected override bool CanShowSheet()
        {
            //  We can show the properties only if we have a single text file selected.
            return SelectedItemPaths.Count() == 1;
        }

        /// <summary>
        /// Creates the pages.
        /// </summary>
        /// <returns>
        /// The property sheet pages.
        /// </returns>
        protected override IEnumerable<SharpPropertyPage> CreatePages()
        {
            //  Return the text file property page.
            yield return new TextFilePropertyPage();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions