[Mono-dev] Windows Shell

Steve K grokys at googlemail.com
Thu Nov 30 15:21:55 EST 2006

As far as I can tell, the interface exposed by the API I attached earlier
would be trivially implemented in a cross platform manner.

Here are the methods/properties exposed:

- string DisplayName: usually just the filename of the file.
- bool IsFolder: returns 'true' when the item is a folder.
- Icon LargeIcon: the large icon for the item
- ShellFolder Parent: the item's parent folder
- Path: the item's full filesystem path. If the folder is virtual, throws an
- Icon SmallIcon: the small icon for the item

- Implements IShellItem
- Can be constructed from a filesystem path, or from an
- IsImmediateParentOf(): tests to see if a folder is an immediate parent of
another folder.
- IsParentOf(): tests to see if a folder is a parent of another folder at
any level.
- HasFileSystemChildren: if the folder is a virtual folder, but it has
filesystem children, returns 'true'. Would probably always return 'true' on
non-Windows platforms.
- IsFileSystem: if the folder is a virtual folder, returns 'false'. Would
probably always return 'true' on non-Windows platforms.

- Implements IShellItem
- Can be constructed from a filesystem path or by iterating over a
- ToShellFolder(): Returns a ShellFolder representing this item if the item
is a folder. If the item is not a folder, throws an exception.

There are obvious missing pieces here, such as finding an item in a folder.
But I can't see anything that would cause problems on other platforms.



On 11/30/06, Charlie Poole <charlie at nunit.com> wrote:
>  Would it be useful to first have a hypothetical common interface, with a
> definition of what the
> semantics would be under different desktops?
> I've done a lot of Shell programming, so maybe I'm thinking at too
> detailed a level, but is sounds
> to me like a Windows-specific thing to start out with. That's OK, but it
> would be good to know
> what parts are likely to be cross-platform, since you might want to
> package them separately.
> Just a thought :-)
> Charlie
>  ------------------------------
> *From:* mono-devel-list-bounces at lists.ximian.com [mailto:
> mono-devel-list-bounces at lists.ximian.com] *On Behalf Of *Steve K
> *Sent:* Thursday, November 30, 2006 6:37 AM
> *To:* Miguel de Icaza
> *Cc:* mono-devel-list at lists.ximian.com
> *Subject:* Re: [Mono-dev] Windows Shell
> I have created a first iteration of the windows implementation, attached.
> I have not integrated this into the mono build system, or indeed tried
> compiling it with mcs yet, as I am having difficulty building mono under
> cygwin.
> Here's a brief overview of the API:
> interface IShellItem -
> This acts as a common interface for ShellFolder and ShellItem. It exposes
> properties such as DisplayName, SmallIcon, LargeIcon, Parent, Path.
> class ShellFolder -
> Represents a folder in the Windows Shell Namepsace. ShellFolder can be
> constructed with an Environment.SpecialFolder value, or from a path. It
> implements IEnumerable, which allows a user to iterate over the folder's
> ShellItems.
> class ShellItem -
> Represents an item in a ShellFolder. If the item is itself a folder,
> ToShellFolder() will create a ShellFolder representation of the item.
> I have used the namespace Mono.WindowsShell for the moment.
> An example of a program using the API:
>         static void Main(string[] args) {
>             ShellFolder folder =
>                 new ShellFolder(Environment.SpecialFolder.Desktop);
>             foreach (ShellItem item in folder) {
>                 if (item.IsFolder) Console.Write("d ");
>                 Console.WriteLine(item.DisplayName);
>             }
>             ShellItem windows = new ShellItem(@"c:\progra~1");
>             Console.WriteLine();
>             Console.WriteLine(windows.DisplayName);
>             Console.WriteLine(windows.LargeIcon.Width);
>         }
> Comments welcome!
> Cheers
> Steve
> On 11/29/06, Miguel de Icaza <miguel at ximian.com> wrote:
> >
> > Hello,
> >
> > > Yes, I agree with your assesment.
> > >
> > > As for duplicating the Windows Shell API, it would need to be
> > > abstracted quite significantly, as it is the single worst API I have
> > > used, and very much tied to the win32 implementation.
> >
> > I would create an abstraction for what you are trying to solve, and have
> > one implementation call into the Windows space, and another that we do
> > to map into the Linux world.
> >
> > This is what we have in mind.
> >
> > Miguel.
> >
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061130/f6e9388c/attachment.html 

More information about the Mono-devel-list mailing list